Package ch.bailu.gtk.pango
Class GlyphString
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.type.Record
ch.bailu.gtk.pango.GlyphString
- All Implemented Interfaces:
PointerInterface
A `PangoGlyphString` is used to store strings of glyphs with geometry
and visual attribute information.
The storage for the glyph information is owned by the structure
which simplifies memory management.
and visual attribute information.
The storage for the glyph information is owned by the structure
which simplifies memory management.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncopy()
Copy a glyph string and associated storage.void
Compute the logical and ink extents of a glyph string.void
extentsRange
(int start, int end, Font font, Rectangle ink_rect, Rectangle logical_rect) Computes the extents of a sub-portion of a glyph string.void
free()
Free a glyph string and associated storage.static ClassHandler
int
number of glyphs in this glyph stringstatic int
void
getLogicalWidths
(Str text, int length, int embedding_level, Int logical_widths) Given a `PangoGlyphString` and corresponding text, determine the width
corresponding to each character.void
getLogicalWidths
(String text, int length, int embedding_level, Int logical_widths) Given a `PangoGlyphString` and corresponding text, determine the width
corresponding to each character.static long
static TypeSystem.TypeSize
static long
static TypeSystem.TypeSize
int
getWidth()
Computes the logical width of the glyph string.void
Converts from character position to x position.void
Converts from character position to x position.void
indexToXFull
(Str text, int length, Analysis analysis, LogAttr attrs, int index_, boolean trailing, Int x_pos) Converts from character position to x position.void
indexToXFull
(String text, int length, Analysis analysis, LogAttr attrs, int index_, boolean trailing, Int x_pos) Converts from character position to x position.void
setFieldNumGlyphs
(int num_glyphs) number of glyphs in this glyph stringvoid
setSize
(int new_len) Resize a glyph string to the given length.void
Convert from x offset to character position.void
Convert from x offset to character position.Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Field Details
-
NUM_GLYPHS
number of glyphs in this glyph string- See Also:
-
-
Constructor Details
-
GlyphString
-
GlyphString
public GlyphString()Create a new `PangoGlyphString`.
-
-
Method Details
-
getClassHandler
-
setFieldNumGlyphs
public void setFieldNumGlyphs(int num_glyphs) number of glyphs in this glyph string -
getFieldNumGlyphs
public int getFieldNumGlyphs()number of glyphs in this glyph string -
copy
Copy a glyph string and associated storage.- Returns:
- the newly allocated `PangoGlyphString`
-
extents
public void extents(@Nonnull Font font, @Nullable Rectangle ink_rect, @Nullable Rectangle logical_rect) Compute the logical and ink extents of a glyph string.
See the documentation for [method@Pango.Font.get_glyph_extents] for details
about the interpretation of the rectangles.
Examples of logical (red) and ink (green) rects:
![](rects1.png) ![](rects2.png)- Parameters:
font
- a `PangoFont`ink_rect
- rectangle used to store the extents of the glyph string as drawnlogical_rect
- rectangle used to store the logical extents of the glyph string
-
extentsRange
public void extentsRange(int start, int end, @Nonnull Font font, @Nullable Rectangle ink_rect, @Nullable Rectangle logical_rect) Computes the extents of a sub-portion of a glyph string.
The extents are relative to the start of the glyph string range
(the origin of their coordinate system is at the start of the range,
not at the start of the entire glyph string).- Parameters:
start
- start indexend
- end index (the range is the set of bytes with indices such that start <= index < end)font
- a `PangoFont`ink_rect
- rectangle used to store the extents of the glyph string range as drawnlogical_rect
- rectangle used to store the logical extents of the glyph string range
-
free
public void free()Free a glyph string and associated storage. -
getLogicalWidths
public void getLogicalWidths(@Nonnull Str text, int length, int embedding_level, @Nonnull Int logical_widths) Given a `PangoGlyphString` and 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 [method@Pango.GlyphItem.get_logical_widths].- Parameters:
text
- the text corresponding to the glyphslength
- the length of @text, in bytesembedding_level
- the embedding level of the stringlogical_widths
- an array whose length is the number of characters in text (equal to `g_utf8_strlen (text, length)` unless text has `NUL` bytes) to be filled in with the resulting character widths.
-
getLogicalWidths
public void getLogicalWidths(String text, int length, int embedding_level, @Nonnull Int logical_widths) Given a `PangoGlyphString` and 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 [method@Pango.GlyphItem.get_logical_widths].- Parameters:
text
- the text corresponding to the glyphslength
- the length of @text, in bytesembedding_level
- the embedding level of the stringlogical_widths
- an array whose length is the number of characters in text (equal to `g_utf8_strlen (text, length)` unless text has `NUL` bytes) to be filled in with the resulting character widths.
-
getWidth
public int getWidth()Computes the logical width of the glyph string.
This can also be computed using [method@Pango.GlyphString.extents].
However, since this only computes the width, it's much faster. This
is in fact only a convenience function that computes the sum of
@geometry.width for each glyph in the @glyphs.- Returns:
- the logical width of the glyph string.
-
indexToX
public void indexToX(@Nonnull Str text, int length, @Nonnull Analysis analysis, int index_, boolean trailing, @Nonnull Int x_pos) Converts from character position to x position.
The X position is measured from the left edge of the run.
Character positions are obtained using font metrics for ligatures
where available, and computed by dividing up each cluster
into equal portions, otherwise.
<picture>
<source srcset="glyphstring-positions-dark.png" media="(prefers-color-scheme: dark)">
<img alt="Glyph positions" src="glyphstring-positions-light.png">
</picture>- Parameters:
text
- the text for the runlength
- the number of bytes (not characters) in @text.analysis
- the analysis information return from [func@itemize]index_
- the byte index within @texttrailing
- whether we should compute the result for the beginning (%FALSE) or end (%TRUE) of the character.x_pos
- location to store result
-
indexToX
public void indexToX(String text, int length, @Nonnull Analysis analysis, int index_, boolean trailing, @Nonnull Int x_pos) Converts from character position to x position.
The X position is measured from the left edge of the run.
Character positions are obtained using font metrics for ligatures
where available, and computed by dividing up each cluster
into equal portions, otherwise.
<picture>
<source srcset="glyphstring-positions-dark.png" media="(prefers-color-scheme: dark)">
<img alt="Glyph positions" src="glyphstring-positions-light.png">
</picture>- Parameters:
text
- the text for the runlength
- the number of bytes (not characters) in @text.analysis
- the analysis information return from [func@itemize]index_
- the byte index within @texttrailing
- whether we should compute the result for the beginning (%FALSE) or end (%TRUE) of the character.x_pos
- location to store result
-
indexToXFull
public void indexToXFull(@Nonnull Str text, int length, @Nonnull Analysis analysis, @Nullable LogAttr attrs, int index_, boolean trailing, @Nonnull Int x_pos) Converts from character position to x position.
This variant of [method@Pango.GlyphString.index_to_x] additionally
accepts a `PangoLogAttr` array. The grapheme boundary information
in it can be used to disambiguate positioning inside some complex
clusters.- Parameters:
text
- the text for the runlength
- the number of bytes (not characters) in @text.analysis
- the analysis information return from [func@itemize]attrs
- `PangoLogAttr` array for @textindex_
- the byte index within @texttrailing
- whether we should compute the result for the beginning (%FALSE) or end (%TRUE) of the character.x_pos
- location to store result
-
indexToXFull
public void indexToXFull(String text, int length, @Nonnull Analysis analysis, @Nullable LogAttr attrs, int index_, boolean trailing, @Nonnull Int x_pos) Converts from character position to x position.
This variant of [method@Pango.GlyphString.index_to_x] additionally
accepts a `PangoLogAttr` array. The grapheme boundary information
in it can be used to disambiguate positioning inside some complex
clusters.- Parameters:
text
- the text for the runlength
- the number of bytes (not characters) in @text.analysis
- the analysis information return from [func@itemize]attrs
- `PangoLogAttr` array for @textindex_
- the byte index within @texttrailing
- whether we should compute the result for the beginning (%FALSE) or end (%TRUE) of the character.x_pos
- location to store result
-
setSize
public void setSize(int new_len) Resize a glyph string to the given length.- Parameters:
new_len
- the new length of the string
-
xToIndex
public void xToIndex(@Nonnull Str text, int length, @Nonnull Analysis analysis, int x_pos, @Nonnull Int index_, @Nonnull Int trailing) Convert from x offset to character position.
Character positions are computed by dividing up each cluster into
equal portions. In scripts where positioning within a cluster is
not allowed (such as Thai), the returned value may not be a valid
cursor position; the caller must combine the result with the logical
attributes for the text to compute the valid cursor position.- Parameters:
text
- the text for the runlength
- the number of bytes (not characters) in text.analysis
- the analysis information return from [func@itemize]x_pos
- the x offset (in Pango units)index_
- location to store calculated byte index within @texttrailing
- location to store a boolean indicating whether the user clicked on the leading or trailing edge of the character
-
xToIndex
public void xToIndex(String text, int length, @Nonnull Analysis analysis, int x_pos, @Nonnull Int index_, @Nonnull Int trailing) Convert from x offset to character position.
Character positions are computed by dividing up each cluster into
equal portions. In scripts where positioning within a cluster is
not allowed (such as Thai), the returned value may not be a valid
cursor position; the caller must combine the result with the logical
attributes for the text to compute the valid cursor position.- Parameters:
text
- the text for the runlength
- the number of bytes (not characters) in text.analysis
- the analysis information return from [func@itemize]x_pos
- the x offset (in Pango units)index_
- location to store calculated byte index within @texttrailing
- location to store a boolean indicating whether the user clicked on the leading or trailing edge of the character
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-