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 TypeMethodDescriptionvoiddispose()Releases the native memory of this object.static ShapingResultfinalizable(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.intReturns the index after the last character in source text for thisShapingResultobject.intReturns the index to the first character in source text for thisShapingResultobject.Returns a list of indexes, mapping each shaped character in source string to corresponding glyph.Returns a list of glyph advances in thisShapingResultobject.intReturns the number of glyphs in thisShapingResultobject.Returns a list of glyph IDs in thisShapingResultobject.Returns a list of glyph offsets in thisShapingResultobject.booleanReturnstrueif the text flows backward for thisShapingResultobject.static booleanisFinalizable(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:
trueif the passed-in shaping result object is finalizable,falseotherwise.
-
isBackward
public boolean isBackward()Returnstrueif the text flows backward for thisShapingResultobject.- Returns:
trueif the text flows backward,falseotherwise.
-
getCharStart
public int getCharStart()Returns the index to the first character in source text for thisShapingResultobject.- 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 thisShapingResultobject.- Returns:
- The index after the last character in source text.
-
getGlyphCount
public int getGlyphCount()Returns the number of glyphs in thisShapingResultobject.- Returns:
- The number of glyphs in this
ShapingResultobject.
-
getGlyphIds
Returns a list of glyph IDs in thisShapingResultobject.Note: The returned list might exhibit undefined behavior if the
ShapingResultobject is disposed.- Returns:
- A list of glyph IDs.
-
getGlyphOffsets
Returns a list of glyph offsets in thisShapingResultobject.Note: The returned list might exhibit undefined behavior if the
ShapingResultobject is disposed.- Returns:
- A list of glyph offsets.
-
getGlyphAdvances
Returns a list of glyph advances in thisShapingResultobject.Note: The returned list might exhibit undefined behavior if the
ShapingResultobject 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
ShapingResultobject 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:DisposableReleases 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:
disposein interfaceDisposable
-
toString
-