neovim-gtk/src/sys/pango/mod.rs

50 lines
990 B
Rust
Raw Normal View History

2017-08-26 20:17:09 +00:00
mod item;
2017-08-20 18:09:57 +00:00
mod analysis;
2017-08-26 20:17:09 +00:00
pub use self::item::Item;
pub use self::analysis::Analysis;
use std::ptr;
use pango;
use pango_sys;
use glib::translate::*;
pub fn pango_itemize(
context: &pango::Context,
2017-09-01 10:14:16 +00:00
text: &str,
2017-08-24 14:41:20 +00:00
attrs: &pango::AttrList
2017-08-26 20:17:09 +00:00
) -> Vec<Item> {
unsafe {
FromGlibPtrContainer::from_glib_container(pango_sys::pango_itemize(
context.to_glib_none().0,
2017-08-24 14:41:20 +00:00
text.as_ptr() as *const i8,
0,
text.len() as i32,
attrs.to_glib_none().0,
ptr::null_mut(),
))
}
}
pub fn pango_shape(
2017-09-01 10:14:16 +00:00
text: &str,
2017-08-25 15:32:30 +00:00
offset: usize,
length: usize,
2017-08-26 20:17:09 +00:00
analysis: &Analysis,
glyphs: &mut pango::GlyphString,
) {
2017-08-25 15:32:30 +00:00
debug_assert!(offset + length <= text.len());
unsafe {
pango_sys::pango_shape(
2017-08-25 15:32:30 +00:00
(text.as_ptr() as *const i8).offset(offset as isize),
length as i32,
2017-08-20 18:09:57 +00:00
analysis.to_glib_ptr(),
glyphs.to_glib_none_mut().0,
);
}
}
2017-08-20 18:09:57 +00:00