Text Texture Settings

interface Settings {
    advancedRenderer?: boolean;
    cutEx?: number;
    cutEy?: number;
    cutSx?: number;
    cutSy?: number;
    fontBaselineRatio?: number;
    fontFace?: null | string | string[];
    fontSize?: number;
    fontStyle?: string;
    h?: number;
    highlight?: boolean;
    highlightColor?: number;
    highlightHeight?: number;
    highlightOffset?: number;
    highlightPaddingLeft?: number;
    highlightPaddingRight?: number;
    letterSpacing?: number;
    lineHeight?: null | number;
    maxLines?: number;
    maxLinesSuffix?: string;
    offsetY?: null | number;
    paddingLeft?: number;
    paddingRight?: number;
    precision?: number;
    resizeMode?: null | ResizeMode;
    shadow?: boolean;
    shadowBlur?: number;
    shadowColor?: number;
    shadowOffsetX?: number;
    shadowOffsetY?: number;
    text?: string;
    textAlign?: TextAlign;
    textBaseline?: TextBaseline;
    textColor?: number;
    textIndent?: number;
    textOverflow?: null | TextOverflow;
    type?: typeof Lightning.textures.TextTexture;
    verticalAlign?: TextVerticalAlign;
    w?: number;
    wordBreak?: boolean;
    wordWrap?: boolean;
    wordWrapWidth?: number;
    x?: number;
    y?: number;
}

Hierarchy (View Summary)

Properties

advancedRenderer?: boolean

Enables the Advanced Text Renderer

The Advanced Text Renderer adds support for:

  • <b> tag for bold text
    • Example: <b>This is bold</b>
  • <i> tag for italics text
    • Example: <i>This is italics</i>
  • <color=$ARGB> tag for colored text
    • Example: <color=0xff00ff00>This is green</color>
  • Enables the use of wordBreak

See: https://github.com/rdkcentral/Lightning/pull/318 for more details

false
cutEx?: number

X coordinate of text cutting end position (in pixels)

0

cutEy?: number

Y coordinate of text cutting end position (in pixels)

0

cutSx?: number

X coordinate of text cutting start position (in pixels)

0

cutSy?: number

Y coordinate of text cutting start position (in pixels)

0

fontBaselineRatio?: number

Font baseline ratio (Advanced Text Renderer only)

This can be used to improve vertical text alignment when using the Advanced Text Renderer.

You MUST enable advancedRenderer in order to use this.

See PR #378 for more information about this feature.

To calculate the ratio for a particular font face, you can do this calculation from font metadata:

    (head.unitsPerEmhhea.Ascenderhhea.Descender) / (2 × head.unitsPerEm)

This give you the ratio for the baseline, which is then used to figure out where the baseline is relative to the bottom of the text bounding box.

The input values can be retrieved using the opentype.js Font Inspector.

0

fontFace?: null | string | string[]

Font family

If an array is provided, font families that appear later in the array are used as fallbacks. If the (default) null value is specified, the font family value specified in the defaultFontFace Stage Option is used. If the resolved font family (or families) is unavailable to the browser, a fallback is chosen by the browser. The special CSS defined font family values of "serif" and "sans-serif" may be used as well.

null (uses Stage.Options.defaultFontFace)

fontSize?: number

Font size (in pixels)

40

fontStyle?: string

Font style

"normal"

h?: number

Texture clipping height

If 0 then shows full width.

This should not be set at the same time as resizeMode.

See Clipping for more information.

highlight?: boolean

Highlight mode

If set, enables a solid color highlight behind the rendered text controlled by these properties:

false

highlightColor?: number

Highlight color

highlight must be enabled for this property to have any affect.

0xFF000000 (black)

highlightHeight?: number

Highlight height (in pixels)

highlight must be enabled for this property to have any affect.

0 (fontSize multiplied by 1.5)

highlightOffset?: number

Highlight Y offset (in pixels)

Shifts the rendered highlight blocks down the Y-axis.

highlight must be enabled for this property to have any affect.

0

highlightPaddingLeft?: number

Highlight left padding (in pixels)

  • If > 0:
    • Adds additional highlight to the left of each highlighted line.
  • If < 0:
    • Removes highlight from the left side of each highlighted line.

highlight must be enabled for this property to have any affect.

0

highlightPaddingRight?: number

Highlight right padding (in pixels)

  • If > 0:
    • Adds additional highlight to the right of each highlighted line.
  • If < 0:
    • Removes highlight from the right side of each highlighted line.

highlight must be enabled for this property to have any affect.

0

letterSpacing?: number

Spacing between letters

Adds or removes spacing between letters. Negative values are allowed.

Warning: Setting this to anything but 0 can slow down the rendering of text.

0 (disabled)

lineHeight?: null | number

Line height (in pixels)

null

maxLines?: number

Maximum number of lines to display before truncation

If this is set to a value greater than 0, multiline text will be truncated at this number of lines. The maxLinesSuffix will be inserted at the end of the last rendered line of text.

0 (line truncation disabled)

maxLinesSuffix?: string

String rendered at the end of a truncated line of text

This suffix is used in the following situations:

".."

offsetY?: null | number

Text Y offset (in pixels)

Translates the position of rendered text along the Y-axis.

This value must be equal to at least the fontSize (which is the default) for the first line of text to be completely visible in the texture. If set to 0, the first line of text will be completely clipped.

null (fontSize)

paddingLeft?: number

Padding left (in pixels)

Using this will result in a larger texture size allocation.

paddingRight?: number

Padding right (in pixels)

Using this will result in a larger texture size allocation.

precision?: number

Render precision of text

Stage.Options.precision stage option

resizeMode?: null | ResizeMode

Texture resize mode (Automatic resize + clipping)

When set, enables automatic clipping to a specific rectangular area.

Note: resizeMode actually modifies the following texture clipping properties, so it should not be set at the same time as them:

See Clipping - ResizeMode for more information.

null (disabled)

shadow?: boolean

Text shadow mode

If set, enables a text shadow behind the rendered text controlled by these properties:

See CanvasRenderingContext2D - Shadows (MDN) for more information on the properties that determine shadows.

false

shadowBlur?: number

Text shadow blur iterations

shadow must be enabled for this property to have any affect.

See CanvasRenderingContext2D.shadowBlur (MDN) for more information on this property.

5

shadowColor?: number

Text shadow color

shadow must be enabled for this property to have any affect.

See CanvasRenderingContext2D.shadowColor (MDN) for more information on this property.

0xFF000000 (black)

shadowOffsetX?: number

Text shadow X offset (in pixels)

shadow must be enabled for this property to have any affect.

See CanvasRenderingContext2D.shadowOffsetX (MDN) for more information on this property.

0

shadowOffsetY?: number

Text shadow Y offset

shadow must be enabled for this property to have any affect.

See CanvasRenderingContext2D.shadowOffsetY (MDN) for more information on this property.

0

text?: string

Text to display

""

textAlign?: TextAlign

Horizontal text alignment

"left"

textBaseline?: TextBaseline

Text baseline

See CanvasRenderingContext2D.textBaseline (MDN) for the available options.

"alphabetic"

textColor?: number

Text color

0xFFFFFFFF (white)

textIndent?: number

Indent of the first line of text (in pixels)

0

textOverflow?: null | TextOverflow

Text overflow mode

When enabled, truncates long blocks of text with a suffix (like "..") to the size specified in wordWrapWidth. wordWrap must be disabled for this to work.

Values

  • "ellipsis": Truncated text will end in maxLinesSuffix.
  • "clip": Truncated text will not end in a suffix.
  • any string: Truncated text will end in this user-defined suffix.

null (disabled)

verticalAlign?: TextVerticalAlign

Vertical text aligment

If lineHeight is larger than fontSize, this value specifies how text should be aligned vertically inside each line.

"top"

w?: number

Texture clipping width

If 0 then shows full width.

This should not be set at the same time as resizeMode.

See Clipping for more information.

wordBreak?: boolean

Word Breaking mode (Advanced Text Renderer only)

When enabled, words that overflow the set width of the texture will be broken to another line.

You MUST enable advancedRenderer in order to use this.

false

wordWrap?: boolean

Word wrap mode

When enabled (default), long lines that exceed wordWrapWidth will be be broken into new lines.

true

wordWrapWidth?: number

Word wrap width (in pixels)

  • When wordWrap is enabled:
    • Long lines that exceed this width will be broken into new lines.
  • When wordWrap is disabled AND when textOverflow is enabled:
    • Text that exceeds this width will be truncated.

0

x?: number

Texture clipping x-offset

This should not be set at the same time as resizeMode.

See Clipping for more information.

y?: number

Texture clipping x-offset

This should not be set at the same time as resizeMode.

See Clipping for more information.