#[repr(transparent)]pub struct GlyphItem { /* private fields */ }
Expand description
Implementations§
source§impl GlyphItem
impl GlyphItem
sourcepub fn apply_attrs(&mut self, text: &str, list: &AttrList) -> Vec<GlyphItem>
pub fn apply_attrs(&mut self, text: &str, list: &AttrList) -> Vec<GlyphItem>
Splits a shaped item (GlyphItem
) into multiple items based
on an attribute list.
The idea is that if you have attributes that don’t affect shaping,
such as color or underline, to avoid affecting shaping, you filter
them out (AttrList::filter()
), apply the shaping process
and then reapply them to the result using this function.
All attributes that start or end inside a cluster are applied to that cluster; for instance, if half of a cluster is underlined and the other-half strikethrough, then the cluster will end up with both underline and strikethrough attributes. In these cases, it may happen that @item->extra_attrs for some of the result items can have multiple attributes of the same type.
This function takes ownership of @self; it will be reused as one of the elements in the list.
text
text that @list applies to
list
a AttrList
Returns
a
list of glyph items resulting from splitting @self. Free
the elements using Pango::GlyphItem::free()
, the list using
g_slist_free().
sourcepub fn split(&mut self, text: &str, split_index: i32) -> Option<GlyphItem>
pub fn split(&mut self, text: &str, split_index: i32) -> Option<GlyphItem>
Modifies @self to cover only the text after @split_index, and returns a new item that covers the text before @split_index that used to be in @self.
You can think of @split_index as the length of the returned item. @split_index may not be 0, and it may not be greater than or equal to the length of @self (that is, there must be at least one byte assigned to each item, you can’t create a zero-length item).
This function is similar in function to pango_item_split() (and uses it internally.)
text
text to which positions in @self apply
split_index
byte index of position to split item, relative to the start of the item
Returns
the newly allocated item representing text before @split_index, which should be freed with pango_glyph_item_free().
source§impl GlyphItem
impl GlyphItem
pub fn item(&self) -> Item
pub fn glyph_string(&self) -> GlyphString
sourcepub fn logical_widths(&self, text: &str) -> Vec<i32>
pub fn logical_widths(&self, text: &str) -> Vec<i32>
Given a GlyphItem
and the corresponding text, determine the
width corresponding to each character.
When multiple characters compose a single cluster, the width of the entire cluster is divided equally among the characters.
See also GlyphString::logical_widths()
.
text
text that @self corresponds to (glyph_item->item->offset is an offset from the start of @text)
logical_widths
an array whose length is the number of characters in glyph_item (equal to glyph_item->item->num_chars) to be filled in with the resulting character widths.
Trait Implementations§
source§impl Ord for GlyphItem
impl Ord for GlyphItem
source§impl PartialEq<GlyphItem> for GlyphItem
impl PartialEq<GlyphItem> for GlyphItem
source§impl PartialOrd<GlyphItem> for GlyphItem
impl PartialOrd<GlyphItem> for GlyphItem
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl StaticType for GlyphItem
impl StaticType for GlyphItem
source§fn static_type() -> Type
fn static_type() -> Type
Self
.