2017-08-26 20:17:09 +00:00
|
|
|
mod item;
|
2017-08-20 18:09:57 +00:00
|
|
|
mod analysis;
|
2017-09-11 15:00:51 +00:00
|
|
|
mod attr_iterator;
|
2017-08-18 15:35:33 +00:00
|
|
|
|
2018-05-06 12:22:38 +00:00
|
|
|
pub mod attribute;
|
|
|
|
|
2017-08-26 20:17:09 +00:00
|
|
|
pub use self::item::Item;
|
|
|
|
pub use self::analysis::Analysis;
|
2017-09-11 15:00:51 +00:00
|
|
|
pub use self::attr_iterator::{AttrIterator, AttrIteratorFactory};
|
2017-08-26 20:17:09 +00:00
|
|
|
|
2017-08-18 15:35:33 +00:00
|
|
|
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-09-11 15:00:51 +00:00
|
|
|
start_index: usize,
|
|
|
|
length: usize,
|
|
|
|
attrs: &pango::AttrList,
|
|
|
|
cached_iter: Option<&mut AttrIterator>,
|
2017-08-26 20:17:09 +00:00
|
|
|
) -> Vec<Item> {
|
2017-08-18 15:35:33 +00:00
|
|
|
unsafe {
|
2018-03-18 21:15:58 +00:00
|
|
|
FromGlibPtrContainer::from_glib_full(pango_sys::pango_itemize(
|
2017-08-18 15:35:33 +00:00
|
|
|
context.to_glib_none().0,
|
2017-08-24 14:41:20 +00:00
|
|
|
text.as_ptr() as *const i8,
|
2017-09-11 15:00:51 +00:00
|
|
|
start_index as i32,
|
|
|
|
length as i32,
|
2017-08-18 15:35:33 +00:00
|
|
|
attrs.to_glib_none().0,
|
2017-12-10 09:46:36 +00:00
|
|
|
cached_iter
|
|
|
|
.map(|iter| iter.to_glib_none_mut().0)
|
|
|
|
.unwrap_or(ptr::null_mut()),
|
2017-08-18 15:35:33 +00:00
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
2017-08-18 15:35:33 +00:00
|
|
|
glyphs: &mut pango::GlyphString,
|
|
|
|
) {
|
2017-08-25 15:32:30 +00:00
|
|
|
debug_assert!(offset + length <= text.len());
|
|
|
|
|
2017-08-18 15:35:33 +00:00
|
|
|
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(),
|
2017-08-18 15:35:33 +00:00
|
|
|
glyphs.to_glib_none_mut().0,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|