Interface IShapedText


public interface IShapedText
Represents a shaped text. A shaped text is a piece of text that has been processed to determine the glyphs and their positions in the text. This is typically done by a text shaping library.

A shaped text consist of a list of clusters. Each cluster represents an indivisible unit, which may be a single character or e.g. a ligature of letter with a combining diacritics mark. For each cluster, you can access the codepoints from which it was constructed. Finally, you can also access the shaped glyphs, consisting of their advance, ascender offset and advance offset.

Since:
8.4.0
  • Method Summary

    Modifier and Type
    Method
    Description
    int[]
    clusterCodePoints(int clusterIndex)
    The codepoints from which the cluster was constructed.
    int
    The total number of clusters in the text.
    int
    clusterEnd(int clusterIndex)
    The index in the original input text where the cluster ends.
    int
    clusterFontIndex(int clusterIndex)
    Index of the font in the font collection if available, -1 if not available.
    double
    clusterGlyphAdvance(int clusterIndex, int glyphIndex)
    The advance of the glyph in the cluster, in units of font size (unitsPerEm / fontSize)
    double
    clusterGlyphAdvanceOffset(int clusterIndex, int glyphIndex)
    The advance offset of the glyph in the cluster, in units of font size (unitsPerEm / fontSize)
    double
    clusterGlyphAscenderOffset(int clusterIndex, int glyphIndex)
    The ascender offset of the glyph in the cluster, in units of font size (unitsPerEm / fontSize).
    int
    clusterGlyphCount(int clusterIndex)
    The number of shaped glyphs in the cluster.
    int
    clusterGlyphIndex(int clusterIndex, int glyphIndex)
    Index of the glyph in the font if available, 0 if not available.
    default double
    clusterGlyphWidth(int clusterIndex, int glyphIndex)
    The total width of the glyph, i.e. the sum of all glyph advances, in units of font size (unitsPerEm / fontSize).
    int
    clusterStart(int clusterIndex)
    The index in the original input text where the cluster ends.
    default double
    clusterWidth(int clusterIndex)
    The total width of the cluster, i.e. the sum of all glyph advances, in units of font size (unitsPerEm / fontSize).
    double
    The height of the shaped text line, in units of font size (unitsPerEm / fontSize).
    default double
    The total width of the shaped text line, i.e. the sum of all glyph advances, , in units of font size (unitsPerEm / fontSize).
  • Method Details

    • clusterCodePoints

      int[] clusterCodePoints(int clusterIndex)
      The codepoints from which the cluster was constructed. This is equivalent to
      inputText.substring(clusterStart(clusterIndex), clusterEnd(clusterIndex)).codePoints().
      
      Parameters:
      clusterIndex - Index of the cluster
      Returns:
      The codepoints of the cluster.
    • clusterCount

      int clusterCount()
      The total number of clusters in the text.
      Returns:
      The number of clusters in the text.
    • clusterEnd

      int clusterEnd(int clusterIndex)
      The index in the original input text where the cluster ends.
      Parameters:
      clusterIndex - Index of the cluster
      Returns:
      The index in the shaped text where the cluster ends.
    • clusterFontIndex

      int clusterFontIndex(int clusterIndex)
      Index of the font in the font collection if available, -1 if not available.
      Parameters:
      clusterIndex - Index of the cluster
      Returns:
      The index of the font in the font collection.
    • clusterGlyphAdvance

      double clusterGlyphAdvance(int clusterIndex, int glyphIndex)
      The advance of the glyph in the cluster, in units of font size (unitsPerEm / fontSize)
      Parameters:
      clusterIndex - Index of the cluster
      glyphIndex - Index of the glyph
      Returns:
      The advance of the glyph in the cluster.
    • clusterGlyphAdvanceOffset

      double clusterGlyphAdvanceOffset(int clusterIndex, int glyphIndex)
      The advance offset of the glyph in the cluster, in units of font size (unitsPerEm / fontSize)
      Parameters:
      clusterIndex - Index of the cluster
      glyphIndex - Index of the glyph
      Returns:
      The advance offset of the glyph in the cluster.
    • clusterGlyphAscenderOffset

      double clusterGlyphAscenderOffset(int clusterIndex, int glyphIndex)
      The ascender offset of the glyph in the cluster, in units of font size (unitsPerEm / fontSize).
      Parameters:
      clusterIndex - Index of the cluster
      glyphIndex - Index of the glyph
      Returns:
      The ascender offset of the glyph in the cluster.
    • clusterGlyphCount

      int clusterGlyphCount(int clusterIndex)
      The number of shaped glyphs in the cluster.
      Parameters:
      clusterIndex - Index of the cluster
      Returns:
      The number of glyphs in the cluster.
    • clusterGlyphIndex

      int clusterGlyphIndex(int clusterIndex, int glyphIndex)
      Index of the glyph in the font if available, 0 if not available.
      Parameters:
      clusterIndex - Index of the cluster
      glyphIndex - Index of the glyph
      Returns:
      The index of the glyph in the font.
    • clusterGlyphWidth

      default double clusterGlyphWidth(int clusterIndex, int glyphIndex)
      The total width of the glyph, i.e. the sum of all glyph advances, in units of font size (unitsPerEm / fontSize).
      Parameters:
      clusterIndex - Index of the cluster
      glyphIndex - Index of the glyph
      Returns:
      The width of the glyph.
    • clusterStart

      int clusterStart(int clusterIndex)
      The index in the original input text where the cluster ends.
      Parameters:
      clusterIndex - Index of the cluster
      Returns:
      The index in the shaped text where the cluster starts.
    • clusterWidth

      default double clusterWidth(int clusterIndex)
      The total width of the cluster, i.e. the sum of all glyph advances, in units of font size (unitsPerEm / fontSize).
      Parameters:
      clusterIndex - Index of the cluster
      Returns:
      The width of the cluster.
    • height

      double height()
      The height of the shaped text line, in units of font size (unitsPerEm / fontSize). Usually derived from the font settings.
      Returns:
      The height of the shaped text.
    • width

      default double width()
      The total width of the shaped text line, i.e. the sum of all glyph advances, , in units of font size (unitsPerEm / fontSize).
      Returns:
      The width of the shaped text.