Package playn.core

Class TextLayout

java.lang.Object
playn.core.TextLayout

public abstract class TextLayout extends Object
Contains metrics and metadata for a laid out body of text. The text may subsequently be rendered to a canvas.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Returns the precise bounds of the text rendered by this layout.
    The TextFormat used to lay out this text.
    The size of the bounding box that contains all of the rendered text.
    final String
    The text that was laid out.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract float
    The number of pixels from the top of a line of text to the baseline.
    abstract float
    The number of pixels from the baseline to the bottom of a line of text.
    abstract float
    The number of pixels between the bottom of one line of text and the top of the next.
    static String
    A helper function for normalizing EOL prior to processing.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • text

      public final String text
      The text that was laid out.
    • format

      public final TextFormat format
      The TextFormat used to lay out this text.
    • bounds

      public final IRectangle bounds
      Returns the precise bounds of the text rendered by this layout. The x and y position may be non-zero if the text is rendered somewhat offset from the "natural" origin of the text line. Unfortunately x may even be negative in some cases which makes rendering the text into a bespoke image troublesome. TextBlock provides methods to help with this.
    • size

      public final IDimension size
      The size of the bounding box that contains all of the rendered text. Note: the height is the height of a line of text. It is not a tight bounding box, but rather the ascent plus the descent and is thus consistent regardless of what text is rendered. Use bounds if you want the precise height of just the rendered text.
  • Method Details

    • ascent

      public abstract float ascent()
      The number of pixels from the top of a line of text to the baseline.
    • descent

      public abstract float descent()
      The number of pixels from the baseline to the bottom of a line of text.
    • leading

      public abstract float leading()
      The number of pixels between the bottom of one line of text and the top of the next.
    • normalizeEOL

      public static String normalizeEOL(String text)
      A helper function for normalizing EOL prior to processing.