Package com.mta.tehreer.sfnt
Class ShapingResult
java.lang.Object
com.mta.tehreer.sfnt.ShapingResult
- All Implemented Interfaces:
Disposable
A
ShapingResult
object is a container for the results of text shaping. It is
generated by a ShapingEngine
object to provide the information related to
characters, their glyphs, offsets, and advances.-
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
Releases the native memory of this object.static ShapingResult
finalizable
(ShapingResult shapingResult) Wraps a shaping result object into a finalizable instance which is guaranteed to be disposed automatically by the GC when no longer in use.float[]
Returns a list of caret edges having caret stop on every code unit.float[]
getCaretEdges
(boolean[] caretStops) Returns a list of caret edges.int
Returns the index after the last character in source text for thisShapingResult
object.int
Returns the index to the first character in source text for thisShapingResult
object.Returns a list of indexes, mapping each shaped character in source string to corresponding glyph.Returns a list of glyph advances in thisShapingResult
object.int
Returns the number of glyphs in thisShapingResult
object.Returns a list of glyph IDs in thisShapingResult
object.Returns a list of glyph offsets in thisShapingResult
object.boolean
Returnstrue
if the text flows backward for thisShapingResult
object.static boolean
isFinalizable
(ShapingResult shapingResult) Checks whether a shaping result object is finalizable or not.toString()
-
Method Details
-
finalizable
Wraps a shaping result object into a finalizable instance which is guaranteed to be disposed automatically by the GC when no longer in use. After calling this method,dispose()
should not be called on either original object or returned object. Callingdispose()
on returned object will throw anUnsupportedOperationException
.Note: The behavior is undefined if the passed-in object is already disposed or wrapped into another finalizable instance.
- Parameters:
shapingResult
- The shaping result object to wrap into a finalizable instance.- Returns:
- The finalizable instance of the passed-in shaping result object.
-
isFinalizable
Checks whether a shaping result object is finalizable or not.- Parameters:
shapingResult
- The shaping result object to check.- Returns:
true
if the passed-in shaping result object is finalizable,false
otherwise.
-
isBackward
public boolean isBackward()Returnstrue
if the text flows backward for thisShapingResult
object.- Returns:
true
if the text flows backward,false
otherwise.
-
getCharStart
public int getCharStart()Returns the index to the first character in source text for thisShapingResult
object.- Returns:
- The index to the first character in source text.
-
getCharEnd
public int getCharEnd()Returns the index after the last character in source text for thisShapingResult
object.- Returns:
- The index after the last character in source text.
-
getGlyphCount
public int getGlyphCount()Returns the number of glyphs in thisShapingResult
object.- Returns:
- The number of glyphs in this
ShapingResult
object.
-
getGlyphIds
Returns a list of glyph IDs in thisShapingResult
object.Note: The returned list might exhibit undefined behavior if the
ShapingResult
object is disposed.- Returns:
- A list of glyph IDs.
-
getGlyphOffsets
Returns a list of glyph offsets in thisShapingResult
object.Note: The returned list might exhibit undefined behavior if the
ShapingResult
object is disposed.- Returns:
- A list of glyph offsets.
-
getGlyphAdvances
Returns a list of glyph advances in thisShapingResult
object.Note: The returned list might exhibit undefined behavior if the
ShapingResult
object is disposed.- Returns:
- A list of glyph advances.
-
getClusterMap
Returns a list of indexes, mapping each shaped character in source string to corresponding glyph. The list might be empty if no glyph is produced.The map is produced according to following rules.
- If a single character translates into multiple glyphs, then it maps to the first glyph in the sequence.
- If multiple characters form a group, such as a grapheme, which in turn translates into multiple glyphs, then each character maps to the first glyph in the sequence.
- If nonconsecutive characters translate to a single glyph or ligature, then each participating character, and all in-between characters, map to this glyph or ligature.
Note: The returned list might exhibit undefined behavior if the
ShapingResult
object is disposed.- Returns:
- A list of indexes, mapping each shaped character in source string to corresponding glyph.
-
getCaretEdges
@NonNull public float[] getCaretEdges()Returns a list of caret edges having caret stop on every code unit.- Returns:
- A list of caret edges having caret stop on every code unit.
-
getCaretEdges
@NonNull public float[] getCaretEdges(@Nullable boolean[] caretStops) Returns a list of caret edges.- Parameters:
caretStops
- An array for caret stops of the code units represented by this object.- Returns:
- A list of caret edges.
-
dispose
public void dispose()Description copied from interface:Disposable
Releases the native memory of this object. Failing to call this method will cause memory leaks.Note: The behavior is undefined if this method is called more than once on the same object.
- Specified by:
dispose
in interfaceDisposable
-
toString
-