Class GlyphItemIter
- All Implemented Interfaces:
Proxy
PangoGlyphItemIter
is an iterator over the clusters in a
PangoGlyphItem
.
The *forward direction* of the iterator is the logical direction of text.
That is, with increasing startIndex
and startChar
values. If glyphItem
is right-to-left (that is, if glyph_item->item->analysis.level
is odd),
then startGlyph
decreases as the iterator moves forward. Moreover,
in right-to-left cases, startGlyph
is greater than endGlyph
.
An iterator should be initialized using either pango_glyph_item_iter_init_start() or pango_glyph_item_iter_init_end(), for forward and backward iteration respectively, and walked over using any desired mixture of pango_glyph_item_iter_next_cluster() and pango_glyph_item_iter_prev_cluster().
A common idiom for doing a forward iteration over the clusters is:
PangoGlyphItemIter cluster_iter;
gboolean have_cluster;
for (have_cluster = pango_glyph_item_iter_init_start (&cluster_iter,
glyph_item, text);
have_cluster;
have_cluster = pango_glyph_item_iter_next_cluster (&cluster_iter))
{
...
}
Note that text
is the start of the text for layout, which is then
indexed by glyph_item->item->offset
to get to the text of glyphItem
.
The startIndex
and endIndex
values can directly index into text
. The
startGlyph
, endGlyph
, startChar
, and endChar
values however are
zero-based for the glyphItem
. For each cluster, the item pointed at by
the start variables is included in the cluster while the one pointed at by
end variables is not.
None of the members of a PangoGlyphItemIter
should be modified manually.
-
Constructor Summary
ConstructorDescriptionAllocate a new GlyphItemIter.GlyphItemIter
(Arena arena) Allocate a new GlyphItemIter.GlyphItemIter
(MemorySegment address) Create a GlyphItemIter proxy instance for the provided memory address.GlyphItemIter
(GlyphItem glyphItem, String text, int startGlyph, int startIndex, int startChar, int endGlyph, int endIndex, int endChar) Allocate a new GlyphItemIter with the fields set to the provided values.GlyphItemIter
(GlyphItem glyphItem, String text, int startGlyph, int startIndex, int startChar, int endGlyph, int endIndex, int endChar, Arena arena) Allocate a new GlyphItemIter with the fields set to the provided values. -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Make a shallow copy of an existingPangoGlyphItemIter
structure.void
free()
Frees aPangoGlyphItem
Iter.static MemoryLayout
The memory layout of the native struct.static Type
getType()
Get the GType of the GlyphItemIter classboolean
Initializes aPangoGlyphItemIter
structure to point to the last cluster in a glyph item.boolean
Initializes aPangoGlyphItemIter
structure to point to the first cluster in a glyph item.boolean
Advances the iterator to the next cluster in the glyph item.boolean
Moves the iterator to the preceding cluster in the glyph item.int
Read the value of the fieldend_char
.int
Read the value of the fieldend_glyph
.int
Read the value of the fieldend_index
.Read the value of the fieldglyph_item
.int
Read the value of the fieldstart_char
.int
Read the value of the fieldstart_glyph
.int
Read the value of the fieldstart_index
.readText()
Read the value of the fieldtext
.void
writeEndChar
(int endChar) Write a value in the fieldend_char
.void
writeEndGlyph
(int endGlyph) Write a value in the fieldend_glyph
.void
writeEndIndex
(int endIndex) Write a value in the fieldend_index
.void
writeGlyphItem
(GlyphItem glyphItem) Write a value in the fieldglyph_item
.void
writeStartChar
(int startChar) Write a value in the fieldstart_char
.void
writeStartGlyph
(int startGlyph) Write a value in the fieldstart_glyph
.void
writeStartIndex
(int startIndex) Write a value in the fieldstart_index
.void
Write a value in the fieldtext
.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
GlyphItemIter
Create a GlyphItemIter proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
GlyphItemIter
Allocate a new GlyphItemIter.- Parameters:
arena
- to control the memory allocation scope
-
GlyphItemIter
public GlyphItemIter()Allocate a new GlyphItemIter. The memory is allocated withArena.ofAuto()
. -
GlyphItemIter
public GlyphItemIter(GlyphItem glyphItem, String text, int startGlyph, int startIndex, int startChar, int endGlyph, int endIndex, int endChar, Arena arena) Allocate a new GlyphItemIter with the fields set to the provided values.- Parameters:
glyphItem
- value for the fieldglyphItem
text
- value for the fieldtext
startGlyph
- value for the fieldstartGlyph
startIndex
- value for the fieldstartIndex
startChar
- value for the fieldstartChar
endGlyph
- value for the fieldendGlyph
endIndex
- value for the fieldendIndex
endChar
- value for the fieldendChar
arena
- to control the memory allocation scope
-
GlyphItemIter
public GlyphItemIter(GlyphItem glyphItem, String text, int startGlyph, int startIndex, int startChar, int endGlyph, int endIndex, int endChar) Allocate a new GlyphItemIter with the fields set to the provided values. The memory is allocated withArena.ofAuto()
.- Parameters:
glyphItem
- value for the fieldglyphItem
text
- value for the fieldtext
startGlyph
- value for the fieldstartGlyph
startIndex
- value for the fieldstartIndex
startChar
- value for the fieldstartChar
endGlyph
- value for the fieldendGlyph
endIndex
- value for the fieldendIndex
endChar
- value for the fieldendChar
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readGlyphItem
Read the value of the fieldglyph_item
.- Returns:
- The value of the field
glyph_item
-
writeGlyphItem
Write a value in the fieldglyph_item
.- Parameters:
glyphItem
- The new value for the fieldglyph_item
-
readText
-
writeText
-
readStartGlyph
public int readStartGlyph()Read the value of the fieldstart_glyph
.- Returns:
- The value of the field
start_glyph
-
writeStartGlyph
public void writeStartGlyph(int startGlyph) Write a value in the fieldstart_glyph
.- Parameters:
startGlyph
- The new value for the fieldstart_glyph
-
readStartIndex
public int readStartIndex()Read the value of the fieldstart_index
.- Returns:
- The value of the field
start_index
-
writeStartIndex
public void writeStartIndex(int startIndex) Write a value in the fieldstart_index
.- Parameters:
startIndex
- The new value for the fieldstart_index
-
readStartChar
public int readStartChar()Read the value of the fieldstart_char
.- Returns:
- The value of the field
start_char
-
writeStartChar
public void writeStartChar(int startChar) Write a value in the fieldstart_char
.- Parameters:
startChar
- The new value for the fieldstart_char
-
readEndGlyph
public int readEndGlyph()Read the value of the fieldend_glyph
.- Returns:
- The value of the field
end_glyph
-
writeEndGlyph
public void writeEndGlyph(int endGlyph) Write a value in the fieldend_glyph
.- Parameters:
endGlyph
- The new value for the fieldend_glyph
-
readEndIndex
public int readEndIndex()Read the value of the fieldend_index
.- Returns:
- The value of the field
end_index
-
writeEndIndex
public void writeEndIndex(int endIndex) Write a value in the fieldend_index
.- Parameters:
endIndex
- The new value for the fieldend_index
-
readEndChar
public int readEndChar()Read the value of the fieldend_char
.- Returns:
- The value of the field
end_char
-
writeEndChar
public void writeEndChar(int endChar) Write a value in the fieldend_char
.- Parameters:
endChar
- The new value for the fieldend_char
-
copy
Make a shallow copy of an existingPangoGlyphItemIter
structure.- Returns:
- the newly allocated
PangoGlyphItemIter
-
free
public void free()Frees aPangoGlyphItem
Iter. -
initEnd
Initializes aPangoGlyphItemIter
structure to point to the last cluster in a glyph item.See
PangoGlyphItemIter
for details of cluster orders.- Parameters:
glyphItem
- the glyph item to iterate overtext
- text corresponding to the glyph item- Returns:
false
if there are no clusters in the glyph item
-
initStart
Initializes aPangoGlyphItemIter
structure to point to the first cluster in a glyph item.See
PangoGlyphItemIter
for details of cluster orders.- Parameters:
glyphItem
- the glyph item to iterate overtext
- text corresponding to the glyph item- Returns:
false
if there are no clusters in the glyph item
-
nextCluster
public boolean nextCluster()Advances the iterator to the next cluster in the glyph item.See
PangoGlyphItemIter
for details of cluster orders.- Returns:
true
if the iterator was advanced,false
if we were already on the last cluster.
-
prevCluster
public boolean prevCluster()Moves the iterator to the preceding cluster in the glyph item. SeePangoGlyphItemIter
for details of cluster orders.- Returns:
true
if the iterator was moved,false
if we were already on the first cluster.
-