Class ShapingResult

java.lang.Object
com.mta.tehreer.sfnt.ShapingResult
All Implemented Interfaces:
Disposable

public class ShapingResult extends Object implements 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 Type
    Method
    Description
    void
    Releases the native memory of this object.
    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 this ShapingResult object.
    int
    Returns the index to the first character in source text for this ShapingResult object.
    Returns a list of indexes, mapping each shaped character in source string to corresponding glyph.
    Returns a list of glyph advances in this ShapingResult object.
    int
    Returns the number of glyphs in this ShapingResult object.
    Returns a list of glyph IDs in this ShapingResult object.
    Returns a list of glyph offsets in this ShapingResult object.
    boolean
    Returns true if the text flows backward for this ShapingResult object.
    static boolean
    Checks whether a shaping result object is finalizable or not.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • finalizable

      @NonNull public static ShapingResult finalizable(@NonNull 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. After calling this method, dispose() should not be called on either original object or returned object. Calling dispose() on returned object will throw an UnsupportedOperationException.

      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

      public static boolean isFinalizable(@NonNull ShapingResult shapingResult)
      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()
      Returns true if the text flows backward for this ShapingResult 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 this ShapingResult 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 this ShapingResult object.
      Returns:
      The index after the last character in source text.
    • getGlyphCount

      public int getGlyphCount()
      Returns the number of glyphs in this ShapingResult object.
      Returns:
      The number of glyphs in this ShapingResult object.
    • getGlyphIds

      @NonNull public IntList getGlyphIds()
      Returns a list of glyph IDs in this ShapingResult object.

      Note: The returned list might exhibit undefined behavior if the ShapingResult object is disposed.

      Returns:
      A list of glyph IDs.
    • getGlyphOffsets

      @NonNull public PointList getGlyphOffsets()
      Returns a list of glyph offsets in this ShapingResult object.

      Note: The returned list might exhibit undefined behavior if the ShapingResult object is disposed.

      Returns:
      A list of glyph offsets.
    • getGlyphAdvances

      @NonNull public FloatList getGlyphAdvances()
      Returns a list of glyph advances in this ShapingResult object.

      Note: The returned list might exhibit undefined behavior if the ShapingResult object is disposed.

      Returns:
      A list of glyph advances.
    • getClusterMap

      @NonNull public IntList 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 interface Disposable
    • toString

      @NonNull public String toString()
      Overrides:
      toString in class Object