pango_itemize/pango_shape implementation
This commit is contained in:
2
src/sys/mod.rs
Normal file
2
src/sys/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
pub mod pango;
|
||||
22
src/sys/pango/item.rs
Normal file
22
src/sys/pango/item.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
use std::ptr;
|
||||
use std::mem;
|
||||
|
||||
use pango_sys;
|
||||
|
||||
use glib_ffi;
|
||||
use glib::translate::*;
|
||||
|
||||
glib_wrapper! {
|
||||
pub struct Item(Boxed<pango_sys::PangoItem>);
|
||||
|
||||
match fn {
|
||||
copy => |ptr| pango_sys::pango_item_copy(ptr as *mut pango_sys::PangoItem),
|
||||
free => |ptr| pango_sys::pango_item_free(ptr),
|
||||
}
|
||||
}
|
||||
|
||||
impl Item {
|
||||
pub fn analysis(&self) -> &pango_sys::PangoAnalysis {
|
||||
&self.0.analysis
|
||||
}
|
||||
}
|
||||
44
src/sys/pango/mod.rs
Normal file
44
src/sys/pango/mod.rs
Normal file
@@ -0,0 +1,44 @@
|
||||
mod item;
|
||||
|
||||
use std::ptr;
|
||||
use std::ffi::CStr;
|
||||
|
||||
use pango;
|
||||
use pango_sys;
|
||||
|
||||
use glib::translate::*;
|
||||
|
||||
pub fn pango_itemize(
|
||||
context: &pango::Context,
|
||||
text: &CStr,
|
||||
start_index: usize,
|
||||
length: usize,
|
||||
attrs: &pango::AttrList,
|
||||
) -> Vec<item::Item> {
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_container(pango_sys::pango_itemize(
|
||||
context.to_glib_none().0,
|
||||
text.as_ptr(),
|
||||
start_index as i32,
|
||||
length as i32,
|
||||
attrs.to_glib_none().0,
|
||||
ptr::null_mut(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pango_shape(
|
||||
text: &CStr,
|
||||
length: usize,
|
||||
analysis: &pango_sys::PangoAnalysis,
|
||||
glyphs: &mut pango::GlyphString,
|
||||
) {
|
||||
unsafe {
|
||||
pango_sys::pango_shape(
|
||||
text.as_ptr(),
|
||||
length as i32,
|
||||
analysis as *const pango_sys::PangoAnalysis,
|
||||
glyphs.to_glib_none_mut().0,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user