Class LayoutIter
- All Implemented Interfaces:
Proxy
PangoLayoutIter can be used to iterate over the visual
extents of a PangoLayout.
To obtain a PangoLayoutIter, use Layout.getIter().
The PangoLayoutIter structure is opaque, and has no user-visible fields.
-
Constructor Summary
ConstructorsConstructorDescriptionLayoutIter(MemorySegment address) Create a LayoutIter proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermines whether this LayoutIter is on the last line of the layout.@Nullable LayoutItercopy()Copies aPangoLayoutIter.voidfree()Frees an iterator that's no longer in use.intGets the Y position of the current line's baseline, in layout coordinates.voidgetCharExtents(Rectangle logicalRect) Gets the extents of the current character, in layout coordinates.voidgetClusterExtents(@Nullable Rectangle inkRect, @Nullable Rectangle logicalRect) Gets the extents of the current cluster, in layout coordinates.intgetIndex()Gets the current byte index.@Nullable LayoutGets the layout associated with aPangoLayoutIter.voidgetLayoutExtents(@Nullable Rectangle inkRect, @Nullable Rectangle logicalRect) Obtains the extents of thePangoLayoutbeing iterated over.@Nullable LayoutLinegetLine()Gets the current line.voidgetLineExtents(@Nullable Rectangle inkRect, @Nullable Rectangle logicalRect) Obtains the extents of the current line.@Nullable LayoutLineGets the current line for read-only access.voidgetLineYrange(@Nullable Out<Integer> y0, @Nullable Out<Integer> y1) Divides the vertical space in thePangoLayoutbeing iterated over between the lines in the layout, and returns the space belonging to the current line.@Nullable LayoutRungetRun()Gets the current run.intGets the Y position of the current run's baseline, in layout coordinates.voidgetRunExtents(@Nullable Rectangle inkRect, @Nullable Rectangle logicalRect) Gets the extents of the current run in layout coordinates.@Nullable LayoutRunGets the current run for read-only access.static @Nullable TypegetType()Get the GType of the LayoutIter classbooleannextChar()Moves this LayoutIter forward to the next character in visual order.booleanMoves this LayoutIter forward to the next cluster in visual order.booleannextLine()Moves this LayoutIter forward to the start of the next line.booleannextRun()Moves this LayoutIter forward to the next run in visual order.Methods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
LayoutIter
Create a LayoutIter proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
-
Method Details
-
getType
-
atLastLine
public boolean atLastLine()Determines whether this LayoutIter is on the last line of the layout.- Returns:
trueif this LayoutIter is on the last line
-
copy
Copies aPangoLayoutIter.- Returns:
- the newly allocated
PangoLayoutIter - Since:
- 1.20
-
free
public void free()Frees an iterator that's no longer in use. -
getBaseline
public int getBaseline()Gets the Y position of the current line's baseline, in layout coordinates.Layout coordinates have the origin at the top left of the entire layout.
- Returns:
- baseline of current line
-
getCharExtents
Gets the extents of the current character, in layout coordinates.Layout coordinates have the origin at the top left of the entire layout.
Only logical extents can sensibly be obtained for characters; ink extents make sense only down to the level of clusters.
- Parameters:
logicalRect- rectangle to fill with logical extents
-
getClusterExtents
Gets the extents of the current cluster, in layout coordinates.Layout coordinates have the origin at the top left of the entire layout.
- Parameters:
inkRect- rectangle to fill with ink extentslogicalRect- rectangle to fill with logical extents
-
getIndex
public int getIndex()Gets the current byte index.Note that iterating forward by char moves in visual order, not logical order, so indexes may not be sequential. Also, the index may be equal to the length of the text in the layout, if on the
nullrun (seegetRun()).- Returns:
- current byte index
-
getLayout
Gets the layout associated with aPangoLayoutIter.- Returns:
- the layout associated with this LayoutIter
- Since:
- 1.20
-
getLayoutExtents
-
getLine
Gets the current line.Use the faster
getLineReadonly()if you do not plan to modify the contents of the line (glyphs, glyph widths, etc.).- Returns:
- the current line
-
getLineExtents
Obtains the extents of the current line.Extents are in layout coordinates (origin is the top-left corner of the entire
PangoLayout). Thus the extents returned by this function will be the same width/height but not at the same x/y as the extents returned fromLayoutLine.getExtents(org.gnome.pango.Rectangle, org.gnome.pango.Rectangle).- Parameters:
inkRect- rectangle to fill with ink extentslogicalRect- rectangle to fill with logical extents
-
getLineReadonly
Gets the current line for read-only access.This is a faster alternative to
getLine(), but the user is not expected to modify the contents of the line (glyphs, glyph widths, etc.).- Returns:
- the current line, that should not be modified
- Since:
- 1.16
-
getLineYrange
Divides the vertical space in thePangoLayoutbeing iterated over between the lines in the layout, and returns the space belonging to the current line.A line's range includes the line's logical extents. plus half of the spacing above and below the line, if
Layout.setSpacing(int)has been called to set layout spacing. The Y positions are in layout coordinates (origin at top left of the entire layout).Note: Since 1.44, Pango uses line heights for placing lines, and there may be gaps between the ranges returned by this function.
- Parameters:
y0- start of liney1- end of line
-
getRun
Gets the current run.When iterating by run, at the end of each line, there's a position with a
nullrun, so this function can returnnull. Thenullrun at the end of each line ensures that all lines have at least one run, even lines consisting of only a newline.Use the faster
getRunReadonly()if you do not plan to modify the contents of the run (glyphs, glyph widths, etc.).- Returns:
- the current run
-
getRunBaseline
public int getRunBaseline()Gets the Y position of the current run's baseline, in layout coordinates.Layout coordinates have the origin at the top left of the entire layout.
The run baseline can be different from the line baseline, for example due to superscript or subscript positioning.
- Since:
- 1.50
-
getRunExtents
Gets the extents of the current run in layout coordinates.Layout coordinates have the origin at the top left of the entire layout.
- Parameters:
inkRect- rectangle to fill with ink extentslogicalRect- rectangle to fill with logical extents
-
getRunReadonly
Gets the current run for read-only access.When iterating by run, at the end of each line, there's a position with a
nullrun, so this function can returnnull. Thenullrun at the end of each line ensures that all lines have at least one run, even lines consisting of only a newline.This is a faster alternative to
getRun(), but the user is not expected to modify the contents of the run (glyphs, glyph widths, etc.).- Returns:
- the current run, that should not be modified
- Since:
- 1.16
-
nextChar
public boolean nextChar()Moves this LayoutIter forward to the next character in visual order.If this LayoutIter was already at the end of the layout, returns
false.- Returns:
- whether motion was possible
-
nextCluster
public boolean nextCluster()Moves this LayoutIter forward to the next cluster in visual order.If this LayoutIter was already at the end of the layout, returns
false.- Returns:
- whether motion was possible
-
nextLine
public boolean nextLine()Moves this LayoutIter forward to the start of the next line.If this LayoutIter is already on the last line, returns
false.- Returns:
- whether motion was possible
-
nextRun
public boolean nextRun()Moves this LayoutIter forward to the next run in visual order.If this LayoutIter was already at the end of the layout, returns
false.- Returns:
- whether motion was possible
-