Class GlyphItem
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
LayoutRun
PangoGlyphItem
is a pair of a PangoItem
and the glyphs
resulting from shaping the items text.
As an example of the usage of PangoGlyphItem
, the results
of shaping text with PangoLayout
is a list of PangoLayoutLine
,
each of which contains a list of PangoGlyphItem
.
-
Constructor Summary
ConstructorDescriptionAllocate a new GlyphItem.Allocate a new GlyphItem.GlyphItem
(MemorySegment address) Create a GlyphItem proxy instance for the provided memory address.GlyphItem
(Item item, GlyphString glyphs, int yOffset, int startXOffset, int endXOffset) Allocate a new GlyphItem with the fields set to the provided values.GlyphItem
(Item item, GlyphString glyphs, int yOffset, int startXOffset, int endXOffset, Arena arena) Allocate a new GlyphItem with the fields set to the provided values. -
Method Summary
Modifier and TypeMethodDescriptionapplyAttrs
(String text, AttrList list) Splits a shaped item (PangoGlyphItem
) into multiple items based on an attribute list.copy()
Make a deep copy of an existingPangoGlyphItem
structure.void
free()
Frees aPangoGlyphItem
and resources to which it points.void
getLogicalWidths
(String text, int[] logicalWidths) Given aPangoGlyphItem
and the corresponding text, determine the width corresponding to each character.static MemoryLayout
The memory layout of the native struct.static Type
getType()
Get the GType of the GlyphItem classvoid
letterSpace
(String text, LogAttr[] logAttrs, int letterSpacing) Adds spacing between the graphemes of this GlyphItem to give the effect of typographic letter spacing.int
Read the value of the fieldend_x_offset
.Read the value of the fieldglyphs
.readItem()
Read the value of the fielditem
.int
Read the value of the fieldstart_x_offset
.int
Read the value of the fieldy_offset
.Modifies this GlyphItem to cover only the text aftersplitIndex
, and returns a new item that covers the text beforesplitIndex
that used to be in this GlyphItem.void
writeEndXOffset
(int endXOffset) Write a value in the fieldend_x_offset
.void
writeGlyphs
(GlyphString glyphs) Write a value in the fieldglyphs
.void
Write a value in the fielditem
.void
writeStartXOffset
(int startXOffset) Write a value in the fieldstart_x_offset
.void
writeYOffset
(int yOffset) Write a value in the fieldy_offset
.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
GlyphItem
Create a GlyphItem proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
GlyphItem
Allocate a new GlyphItem.- Parameters:
arena
- to control the memory allocation scope
-
GlyphItem
public GlyphItem()Allocate a new GlyphItem. The memory is allocated withArena.ofAuto()
. -
GlyphItem
public GlyphItem(Item item, GlyphString glyphs, int yOffset, int startXOffset, int endXOffset, Arena arena) Allocate a new GlyphItem with the fields set to the provided values.- Parameters:
item
- value for the fielditem
glyphs
- value for the fieldglyphs
yOffset
- value for the fieldyOffset
startXOffset
- value for the fieldstartXOffset
endXOffset
- value for the fieldendXOffset
arena
- to control the memory allocation scope
-
GlyphItem
Allocate a new GlyphItem with the fields set to the provided values. The memory is allocated withArena.ofAuto()
.- Parameters:
item
- value for the fielditem
glyphs
- value for the fieldglyphs
yOffset
- value for the fieldyOffset
startXOffset
- value for the fieldstartXOffset
endXOffset
- value for the fieldendXOffset
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readItem
-
writeItem
Write a value in the fielditem
.- Parameters:
item
- The new value for the fielditem
-
readGlyphs
Read the value of the fieldglyphs
.- Returns:
- The value of the field
glyphs
-
writeGlyphs
Write a value in the fieldglyphs
.- Parameters:
glyphs
- The new value for the fieldglyphs
-
readYOffset
public int readYOffset()Read the value of the fieldy_offset
.- Returns:
- The value of the field
y_offset
-
writeYOffset
public void writeYOffset(int yOffset) Write a value in the fieldy_offset
.- Parameters:
yOffset
- The new value for the fieldy_offset
-
readStartXOffset
public int readStartXOffset()Read the value of the fieldstart_x_offset
.- Returns:
- The value of the field
start_x_offset
-
writeStartXOffset
public void writeStartXOffset(int startXOffset) Write a value in the fieldstart_x_offset
.- Parameters:
startXOffset
- The new value for the fieldstart_x_offset
-
readEndXOffset
public int readEndXOffset()Read the value of the fieldend_x_offset
.- Returns:
- The value of the field
end_x_offset
-
writeEndXOffset
public void writeEndXOffset(int endXOffset) Write a value in the fieldend_x_offset
.- Parameters:
endXOffset
- The new value for the fieldend_x_offset
-
applyAttrs
Splits a shaped item (PangoGlyphItem
) 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(org.gnome.pango.AttrFilterFunc)
), 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 this GlyphItem; it will be reused as one of the elements in the list.
- Parameters:
text
- text thatlist
applies tolist
- aPangoAttrList
- Returns:
- a
list of glyph items resulting from splitting this GlyphItem. Free
the elements using
free()
, the list using g_slist_free().
-
copy
Make a deep copy of an existingPangoGlyphItem
structure.- Returns:
- the newly allocated
PangoGlyphItem
-
free
public void free()Frees aPangoGlyphItem
and resources to which it points. -
getLogicalWidths
Given aPangoGlyphItem
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.getLogicalWidths(java.lang.String, int, int, int[])
.- Parameters:
text
- text that this GlyphItem corresponds to (glyph_item->item->offset is an offset from the start oftext
)logicalWidths
- 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.
-
letterSpace
Adds spacing between the graphemes of this GlyphItem to give the effect of typographic letter spacing.- Parameters:
text
- text that this GlyphItem corresponds to (glyph_item->item->offset is an offset from the start oftext
)logAttrs
- logical attributes for the item (the first logical attribute refers to the position before the first character in the item)letterSpacing
- amount of letter spacing to add in Pango units. May be negative, though too large negative values will give ugly results.
-
split
Modifies this GlyphItem to cover only the text aftersplitIndex
, and returns a new item that covers the text beforesplitIndex
that used to be in this GlyphItem.You can think of
splitIndex
as the length of the returned item.splitIndex
may not be 0, and it may not be greater than or equal to the length of this GlyphItem (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.)
- Parameters:
text
- text to which positions in this GlyphItem applysplitIndex
- byte index of position to split item, relative to the start of the item- Returns:
- the newly allocated item
representing text before
splitIndex
, which should be freed with pango_glyph_item_free().
-