Class MeasuredText

java.lang.Object
icyllis.modernui.graphics.text.MeasuredText

public class MeasuredText extends Object
Text shaping result object for multi-style text, so there are multiple style runs of positioned glyphs.
See Also:
  • Method Details

    • getTextBuf

      @NonNull public char[] getTextBuf()
      Returns the text buffer. Elements may change if recycled at higher level, keep it synchronized with MeasuredText.
      Returns:
      the backend buffer of the text
    • getRuns

      @NonNull public MeasuredText.Run[] getRuns()
      Returns runs of text. Successive style runs may remain the same font paint under optimization consideration.
      Returns:
      all text runs, may empty if text buf is empty
    • getExtent

      public void getExtent(int start, int end, @NonNull FontMetricsInt extent)
      Expands the font metrics with those of the chars in the given range of the text buffer.
      Parameters:
      start - the start index
      end - the end index
      extent - receives the metrics
    • getAdvance

      public float getAdvance(int pos)
      Returns the advance of the char at the given index of the text buffer.

      This follows grapheme cluster break. For example: there are 6 chars (uint_16), the first two are the first grapheme, the last four are the second one. Then mAdvances[0] is for the first grapheme, mAdvances[2] for the second one, other elements are zero. It's in the same order of getTextBuf()

      Parameters:
      pos - the char index
      Returns:
      advance
    • getAdvance

      public float getAdvance(int start, int end)
      Returns the advance of the chars in the given range of the text buffer.
      Parameters:
      start - the start index
      end - the end index
      Returns:
      advance
      See Also:
    • searchRun

      @Nullable public MeasuredText.Run searchRun(int pos)
      Binary search with ranges.
      Parameters:
      pos - char index
      Returns:
      the run
    • getMemoryUsage

      public int getMemoryUsage()
      Note: The text buffer is not within the calculation range.
      Returns:
      memory usage in bytes
    • toString

      public String toString()
      Overrides:
      toString in class Object