Package icyllis.modernui.graphics.text

# Class LayoutPiece

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

@Immutable public final class LayoutPiece extends Object
The layout of a styled text run, including text shaping results, glyph metrics and their positions.

Since:
  2.6
See Also:
  - `LayoutCache`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `float`
  `getAdvance()`
  Returns the total advance of this piece.
  `@org.jetbrains.annotations.Unmodifiable float[]`
  `getAdvances()`
  The array of all chars advance, the length and order are relative to the text buffer, if computed.
  `int`
  `getAscent()`
  Gets the font metrics of the maximum extent of this piece.
  `int`
  `getBoundsHeight()`
  Returns the height value of the pixel bounds of all glyph images, if computed.
  `int`
  `getBoundsWidth()`
  Returns the width value of the pixel bounds of all glyph images, if computed.
  `int`
  `getBoundsX()`
  Returns the floor left value of the pixel bounds of all glyph images, relative to (0, 0), if computed.
  `int`
  `getBoundsY()`
  Returns the floor top value of the pixel bounds of all glyph images, relative to (0, 0), if computed.
  `int`
  `getCharCount()`
  Returns the number of characters (i.e.
  `int`
  `getComputeFlags()`
  Returns which flags were computed.
  `int`
  `getDescent()`
  Gets the font metrics of the maximum extent of this piece.
  `void`
  `getExtent(FontMetricsInt extent)`
  Expands the font metrics of the maximum extent of this piece.
  `Font`
  `getFont(int i)`
  Returns which font should be used for the i-th glyph.
  `int`
  `getGlyphCount()`
  Returns the number of glyphs.
  `@org.jetbrains.annotations.Unmodifiable int[]`
  `getGlyphs()`
  The array is about all laid-out glyphs for in order visually from left to right.
  `int`
  `getMemoryUsage()`
  `@org.jetbrains.annotations.Unmodifiable float[]`
  `getPositions()`
  This array holds the repeat of x offset, y offset of glyph positions.
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Method Details

  - ### getGlyphCount

    public int getGlyphCount()
    Returns the number of glyphs.

  - ### getGlyphs

    public @org.jetbrains.annotations.Unmodifiable int[] getGlyphs()
    The array is about all laid-out glyphs for in order visually from left to right.
    Returns:
      glyphs

  - ### getPositions

    public @org.jetbrains.annotations.Unmodifiable float[] getPositions()
    This array holds the repeat of x offset, y offset of glyph positions. The length is twice as long as the glyph array.
    Returns:
      glyph positions

  - ### getFont

    public Font getFont(int i)
    Returns which font should be used for the i-th glyph.
    Parameters:
      `i` - the index
    Returns:
      the font

  - ### getCharCount

    public int getCharCount()
    Returns the number of characters (i.e. constructor `limit - start` in code units).

  - ### getAdvances

    public @org.jetbrains.annotations.Unmodifiable float[] getAdvances()
    The array of all chars advance, the length and order are relative to the text buffer, if computed. Only grapheme cluster bounds have advances, others are zeros. For example: [13.57, 0, 14.26, 0, 0]. The length is constructor `end - start`.
    Returns:
      advances, or null
    See Also:
      - `LayoutCache.COMPUTE_CLUSTER_ADVANCES`

  - ### getExtent

    public void getExtent(@NonNull FontMetricsInt extent)
    Expands the font metrics of the maximum extent of this piece.
    Parameters:
      `extent` - to expand from

  - ### getAscent

    public int getAscent()
    Gets the font metrics of the maximum extent of this piece.
    Returns:
      ascent to baseline, always negative

  - ### getDescent

    public int getDescent()
    Gets the font metrics of the maximum extent of this piece.
    Returns:
      descent to baseline, always positive

  - ### getAdvance

    public float getAdvance()
    Returns the total advance of this piece.
    Returns:
      advance

  - ### getBoundsX

    public int getBoundsX()
    Returns the floor left value of the pixel bounds of all glyph images, relative to (0, 0), if computed.
    Returns:
      the bounds X, or 0
    See Also:
      - `LayoutCache.COMPUTE_GLYPHS_PIXEL_BOUNDS`

  - ### getBoundsY

    public int getBoundsY()
    Returns the floor top value of the pixel bounds of all glyph images, relative to (0, 0), if computed.
    Returns:
      the bounds Y, or 0
    See Also:
      - `LayoutCache.COMPUTE_GLYPHS_PIXEL_BOUNDS`

  - ### getBoundsWidth

    public int getBoundsWidth()
    Returns the width value of the pixel bounds of all glyph images, if computed.
    Returns:
      the bounds width, or 0
    See Also:
      - `LayoutCache.COMPUTE_GLYPHS_PIXEL_BOUNDS`

  - ### getBoundsHeight

    public int getBoundsHeight()
    Returns the height value of the pixel bounds of all glyph images, if computed.
    Returns:
      the bounds height, or 0
    See Also:
      - `LayoutCache.COMPUTE_GLYPHS_PIXEL_BOUNDS`

  - ### getComputeFlags

    public int getComputeFlags()
    Returns which flags were computed.
    See Also:
      - `LayoutCache.COMPUTE_CLUSTER_ADVANCES`
      - `LayoutCache.COMPUTE_GLYPHS_PIXEL_BOUNDS`

  - ### getMemoryUsage

    public int getMemoryUsage()

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`