Class LayoutLine
- All Implemented Interfaces:
Proxy
PangoLayoutLine represents one of the lines resulting from laying
out a paragraph via PangoLayout.
PangoLayoutLine structures are obtained by calling
Layout.getLine(int) and are only valid until the text,
attributes, or settings of the parent PangoLayout are modified.
-
Constructor Summary
ConstructorsConstructorDescriptionAllocate a new LayoutLine.LayoutLine(Arena arena) Allocate a new LayoutLine.LayoutLine(MemorySegment address) Create a LayoutLine proxy instance for the provided memory address.LayoutLine(Layout layout, int startIndex, int length, SList<LayoutRun> runs) Allocate a new LayoutLine with the fields set to the provided values.LayoutLine(Layout layout, int startIndex, int length, SList<LayoutRun> runs, Arena arena) Allocate a new LayoutLine with the fields set to the provided values. -
Method Summary
Modifier and TypeMethodDescriptionvoidgetExtents(@Nullable Rectangle inkRect, @Nullable Rectangle logicalRect) Computes the logical and ink extents of a layout line.voidComputes the height of the line, as the maximum of the heights of fonts used in this line.intReturns the length of the line, in bytes.static MemoryLayoutThe memory layout of the native struct.voidgetPixelExtents(@Nullable Rectangle inkRect, @Nullable Rectangle logicalRect) Computes the logical and ink extents of this LayoutLine in device units.Returns the resolved direction of the line.intReturns the start index of the line, as byte index into the text of the layout.static @Nullable TypegetType()Get the GType of the LayoutLine classvoidgetXRanges(int startIndex, int endIndex, @Nullable Out<int[]> ranges) Gets a list of visual ranges corresponding to a given logical range.voidConverts an index within a line to a X position.booleanReturns whether this is the first line of the paragraph.Read the value of the fieldlayout.intRead the value of the fieldlength.readRuns()Read the value of the fieldruns.intRead the value of the fieldstart_index.@Nullable LayoutLineref()Increase the reference count of aPangoLayoutLineby one.voidunref()Decrease the reference count of aPangoLayoutLineby one.voidwriteLayout(Layout layout) Write a value in the fieldlayout.voidwriteLength(int length) Write a value in the fieldlength.voidWrite a value in the fieldruns.voidwriteStartIndex(int startIndex) Write a value in the fieldstart_index.booleanConverts from x offset to the byte index of the corresponding character within the text of the layout.Methods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
LayoutLine
Create a LayoutLine proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
LayoutLine
Allocate a new LayoutLine.- Parameters:
arena- to control the memory allocation scope
-
LayoutLine
public LayoutLine()Allocate a new LayoutLine. The memory is allocated withArena.ofAuto(). -
LayoutLine
Allocate a new LayoutLine with the fields set to the provided values.- Parameters:
layout- value for the fieldlayoutstartIndex- value for the fieldstartIndexlength- value for the fieldlengthruns- value for the fieldrunsarena- to control the memory allocation scope
-
LayoutLine
Allocate a new LayoutLine with the fields set to the provided values. The memory is allocated withArena.ofAuto().- Parameters:
layout- value for the fieldlayoutstartIndex- value for the fieldstartIndexlength- value for the fieldlengthruns- value for the fieldruns
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readLayout
Read the value of the fieldlayout.- Returns:
- The value of the field
layout
-
writeLayout
Write a value in the fieldlayout.- Parameters:
layout- The new value for the fieldlayout
-
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
-
readLength
public int readLength()Read the value of the fieldlength.- Returns:
- The value of the field
length
-
writeLength
public void writeLength(int length) Write a value in the fieldlength.- Parameters:
length- The new value for the fieldlength
-
readRuns
-
writeRuns
-
getExtents
Computes the logical and ink extents of a layout line.See
Font.getGlyphExtents(org.gnome.pango.Glyph, org.gnome.pango.Rectangle, org.gnome.pango.Rectangle)for details about the interpretation of the rectangles.- Parameters:
inkRect- rectangle used to store the extents of the glyph string as drawnlogicalRect- rectangle used to store the logical extents of the glyph string
-
getHeight
Computes the height of the line, as the maximum of the heights of fonts used in this line.Note that the actual baseline-to-baseline distance between lines of text is influenced by other factors, such as
Layout.setSpacing(int)andLayout.setLineSpacing(float).- Parameters:
height- return location for the line height- Since:
- 1.44
-
getLength
public int getLength()Returns the length of the line, in bytes.- Returns:
- the length of the line
- Since:
- 1.50
-
getPixelExtents
Computes the logical and ink extents of this LayoutLine in device units.This function just calls
getExtents(org.gnome.pango.Rectangle, org.gnome.pango.Rectangle)followed by twoPango.extentsToPixels(org.gnome.pango.Rectangle, org.gnome.pango.Rectangle)calls, roundinginkRectandlogicalRectsuch that the rounded rectangles fully contain the unrounded one (that is, passes them as first argument toPango.extentsToPixels(org.gnome.pango.Rectangle, org.gnome.pango.Rectangle)).- Parameters:
inkRect- rectangle used to store the extents of the glyph string as drawnlogicalRect- rectangle used to store the logical extents of the glyph string
-
getResolvedDirection
Returns the resolved direction of the line.- Returns:
- the resolved direction of the line
- Since:
- 1.50
-
getStartIndex
public int getStartIndex()Returns the start index of the line, as byte index into the text of the layout.- Returns:
- the start index of the line
- Since:
- 1.50
-
getXRanges
Gets a list of visual ranges corresponding to a given logical range.This list is not necessarily minimal - there may be consecutive ranges which are adjacent. The ranges will be sorted from left to right. The ranges are with respect to the left edge of the entire layout, not with respect to the line.
- Parameters:
startIndex- Start byte index of the logical range. If this value is less than the start index for the line, then the first range will extend all the way to the leading edge of the layout. Otherwise, it will start at the leading edge of the first character.endIndex- Ending byte index of the logical range. If this value is greater than the end index for the line, then the last range will extend all the way to the trailing edge of the layout. Otherwise, it will end at the trailing edge of the last character.ranges- location to store a pointer to an array of ranges. The array will be of length2*n_ranges, with each range starting at(*ranges)[2*n]and of width(*ranges)[2*n + 1] - (*ranges)[2*n]. This array must be freed with g_free(). The coordinates are relative to the layout and are in Pango units.
-
indexToX
Converts an index within a line to a X position.- Parameters:
index- byte offset of a grapheme within the layouttrailing- an integer indicating the edge of the grapheme to retrieve the position of. If > 0, the trailing edge of the grapheme, if 0, the leading of the graphemexPos- location to store the x_offset (in Pango units)
-
isParagraphStart
public boolean isParagraphStart()Returns whether this is the first line of the paragraph.- Returns:
trueif this is the first line- Since:
- 1.50
-
ref
Increase the reference count of aPangoLayoutLineby one.- Returns:
- the line passed in.
- Since:
- 1.10
-
unref
public void unref()Decrease the reference count of aPangoLayoutLineby one.If the result is zero, the line and all associated memory will be freed.
-
xToIndex
Converts from x offset to the byte index of the corresponding character within the text of the layout.If
xPosis outside the line,indexandtrailingwill point to the very first or very last position in the line. This determination is based on the resolved direction of the paragraph; for example, if the resolved direction is right-to-left, then an X position to the right of the line (after it) results in 0 being stored inindexandtrailing.An X position to the left of the line results inindexpointing to the (logical) last grapheme in the line andtrailingbeing set to the number of characters in that grapheme. The reverse is true for a left-to-right line.- Parameters:
xPos- the X offset (in Pango units) from the left edge of the line.index- location to store calculated byte index for the grapheme in which the user clickedtrailing- location to store an integer indicating where in the grapheme the user clicked. It will either be zero, or the number of characters in the grapheme. 0 represents the leading edge of the grapheme.- Returns:
falseifxPoswas outside the line,trueif inside
-