Options
All
  • Public
  • Public/Protected
  • All
Menu

A TextStyle Object contains information to decorate a Text objects.

An instance can be shared between multiple Text objects; then changing the style will update all text objects using it.

A tool can be used to generate a text style here.

memberof

PIXI

Hierarchy

  • TextStyle

Implements

Index

Constructors

constructor

  • Parameters

    Returns TextStyle

Properties

Protected _align

Protected _breakWords

_breakWords: boolean

Protected _dropShadow

_dropShadow: boolean

Protected _dropShadowAlpha

_dropShadowAlpha: number

Protected _dropShadowAngle

_dropShadowAngle: number

Protected _dropShadowBlur

_dropShadowBlur: number

Protected _dropShadowColor

_dropShadowColor: string | number

Protected _dropShadowDistance

_dropShadowDistance: number

Protected _fill

Protected _fillGradientStops

_fillGradientStops: number[]

Protected _fillGradientType

_fillGradientType: TEXT_GRADIENT

Protected _fontFamily

_fontFamily: string | string[]

Protected _fontSize

_fontSize: string | number

Protected _fontStyle

_fontStyle: TextStyleFontStyle

Protected _fontVariant

_fontVariant: TextStyleFontVariant

Protected _fontWeight

_fontWeight: TextStyleFontWeight

Protected _leading

_leading: number

Protected _letterSpacing

_letterSpacing: number

Protected _lineHeight

_lineHeight: number

Protected _lineJoin

Protected _miterLimit

_miterLimit: number

Protected _padding

_padding: number

Protected _stroke

_stroke: string | number

Protected _strokeThickness

_strokeThickness: number

Protected _textBaseline

_textBaseline: TextStyleTextBaseline

Protected _trim

_trim: boolean

Protected _whiteSpace

_whiteSpace: TextStyleWhiteSpace

Protected _wordWrap

_wordWrap: boolean

Protected _wordWrapWidth

_wordWrapWidth: number

styleID

styleID: number

Accessors

align

  • Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text

    member

    {string}

    Returns TextStyleAlign

  • Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text

    Parameters

    Returns void

breakWords

  • get breakWords(): boolean
  • set breakWords(breakWords: boolean): void
  • Indicates if lines can be wrapped within words, it needs wordWrap to be set to true

    member

    {boolean}

    Returns boolean

  • Indicates if lines can be wrapped within words, it needs wordWrap to be set to true

    Parameters

    • breakWords: boolean

    Returns void

dropShadow

  • get dropShadow(): boolean
  • set dropShadow(dropShadow: boolean): void
  • Set a drop shadow for the text

    member

    {boolean}

    Returns boolean

  • Set a drop shadow for the text

    Parameters

    • dropShadow: boolean

    Returns void

dropShadowAlpha

  • get dropShadowAlpha(): number
  • set dropShadowAlpha(dropShadowAlpha: number): void
  • Set alpha for the drop shadow

    member

    {number}

    Returns number

  • Set alpha for the drop shadow

    Parameters

    • dropShadowAlpha: number

    Returns void

dropShadowAngle

  • get dropShadowAngle(): number
  • set dropShadowAngle(dropShadowAngle: number): void
  • Set a angle of the drop shadow

    member

    {number}

    Returns number

  • Set a angle of the drop shadow

    Parameters

    • dropShadowAngle: number

    Returns void

dropShadowBlur

  • get dropShadowBlur(): number
  • set dropShadowBlur(dropShadowBlur: number): void
  • Set a shadow blur radius

    member

    {number}

    Returns number

  • Set a shadow blur radius

    Parameters

    • dropShadowBlur: number

    Returns void

dropShadowColor

  • get dropShadowColor(): string | number
  • set dropShadowColor(dropShadowColor: string | number): void
  • A fill style to be used on the dropshadow e.g 'red', '#00FF00'

    member

    {string|number}

    Returns string | number

  • A fill style to be used on the dropshadow e.g 'red', '#00FF00'

    Parameters

    • dropShadowColor: string | number

    Returns void

dropShadowDistance

  • get dropShadowDistance(): number
  • set dropShadowDistance(dropShadowDistance: number): void
  • Set a distance of the drop shadow

    member

    {number}

    Returns number

  • Set a distance of the drop shadow

    Parameters

    • dropShadowDistance: number

    Returns void

fill

  • A canvas fillstyle that will be used on the text e.g 'red', '#00FF00'. Can be an array to create a gradient eg ['#000000','#FFFFFF'] MDN

    member

    {string|string[]|number|number[]|CanvasGradient|CanvasPattern}

    Returns TextStyleFill

  • A canvas fillstyle that will be used on the text e.g 'red', '#00FF00'. Can be an array to create a gradient eg ['#000000','#FFFFFF'] MDN

    Parameters

    Returns void

fillGradientStops

  • get fillGradientStops(): number[]
  • set fillGradientStops(fillGradientStops: number[]): void
  • If fill is an array of colours to create a gradient, this array can set the stop points (numbers between 0 and 1) for the color, overriding the default behaviour of evenly spacing them.

    member

    {number[]}

    Returns number[]

  • If fill is an array of colours to create a gradient, this array can set the stop points (numbers between 0 and 1) for the color, overriding the default behaviour of evenly spacing them.

    Parameters

    • fillGradientStops: number[]

    Returns void

fillGradientType

fontFamily

  • get fontFamily(): string | string[]
  • set fontFamily(fontFamily: string | string[]): void
  • The font family

    member

    {string|string[]}

    Returns string | string[]

  • The font family

    Parameters

    • fontFamily: string | string[]

    Returns void

fontSize

  • get fontSize(): string | number
  • set fontSize(fontSize: string | number): void
  • The font size (as a number it converts to px, but as a string, equivalents are '26px','20pt','160%' or '1.6em')

    member

    {number|string}

    Returns string | number

  • The font size (as a number it converts to px, but as a string, equivalents are '26px','20pt','160%' or '1.6em')

    Parameters

    • fontSize: string | number

    Returns void

fontStyle

  • The font style ('normal', 'italic' or 'oblique')

    member

    {string}

    Returns TextStyleFontStyle

  • The font style ('normal', 'italic' or 'oblique')

    Parameters

    Returns void

fontVariant

fontWeight

  • The font weight ('normal', 'bold', 'bolder', 'lighter' and '100', '200', '300', '400', '500', '600', '700', 800' or '900')

    member

    {string}

    Returns TextStyleFontWeight

  • The font weight ('normal', 'bold', 'bolder', 'lighter' and '100', '200', '300', '400', '500', '600', '700', 800' or '900')

    Parameters

    Returns void

leading

  • get leading(): number
  • set leading(leading: number): void
  • The space between lines

    member

    {number}

    Returns number

  • The space between lines

    Parameters

    • leading: number

    Returns void

letterSpacing

  • get letterSpacing(): number
  • set letterSpacing(letterSpacing: number): void
  • The amount of spacing between letters, default is 0

    member

    {number}

    Returns number

  • The amount of spacing between letters, default is 0

    Parameters

    • letterSpacing: number

    Returns void

lineHeight

  • get lineHeight(): number
  • set lineHeight(lineHeight: number): void
  • The line height, a number that represents the vertical space that a letter uses

    member

    {number}

    Returns number

  • The line height, a number that represents the vertical space that a letter uses

    Parameters

    • lineHeight: number

    Returns void

lineJoin

  • The lineJoin property sets the type of corner created, it can resolve spiked text issues. Default is 'miter' (creates a sharp corner).

    member

    {string}

    Returns TextStyleLineJoin

  • The lineJoin property sets the type of corner created, it can resolve spiked text issues. Default is 'miter' (creates a sharp corner).

    Parameters

    Returns void

miterLimit

  • get miterLimit(): number
  • set miterLimit(miterLimit: number): void
  • The miter limit to use when using the 'miter' lineJoin mode This can reduce or increase the spikiness of rendered text.

    member

    {number}

    Returns number

  • The miter limit to use when using the 'miter' lineJoin mode This can reduce or increase the spikiness of rendered text.

    Parameters

    • miterLimit: number

    Returns void

padding

  • get padding(): number
  • set padding(padding: number): void
  • Occasionally some fonts are cropped. Adding some padding will prevent this from happening by adding padding to all sides of the text.

    member

    {number}

    Returns number

  • Occasionally some fonts are cropped. Adding some padding will prevent this from happening by adding padding to all sides of the text.

    Parameters

    • padding: number

    Returns void

stroke

  • get stroke(): string | number
  • set stroke(stroke: string | number): void
  • A canvas fillstyle that will be used on the text stroke e.g 'blue', '#FCFF00'

    member

    {string|number}

    Returns string | number

  • A canvas fillstyle that will be used on the text stroke e.g 'blue', '#FCFF00'

    Parameters

    • stroke: string | number

    Returns void

strokeThickness

  • get strokeThickness(): number
  • set strokeThickness(strokeThickness: number): void
  • A number that represents the thickness of the stroke. Default is 0 (no stroke)

    member

    {number}

    Returns number

  • A number that represents the thickness of the stroke. Default is 0 (no stroke)

    Parameters

    • strokeThickness: number

    Returns void

textBaseline

trim

  • get trim(): boolean
  • set trim(trim: boolean): void
  • Trim transparent borders

    member

    {boolean}

    Returns boolean

  • Trim transparent borders

    Parameters

    • trim: boolean

    Returns void

whiteSpace

  • How newlines and spaces should be handled. Default is 'pre' (preserve, preserve).

    value New lines Spaces
    'normal' Collapse Collapse
    'pre' Preserve Preserve
    'pre-line' Preserve Collapse
    member

    {string}

    Returns TextStyleWhiteSpace

  • How newlines and spaces should be handled. Default is 'pre' (preserve, preserve).

    value New lines Spaces
    'normal' Collapse Collapse
    'pre' Preserve Preserve
    'pre-line' Preserve Collapse

    Parameters

    Returns void

wordWrap

  • get wordWrap(): boolean
  • set wordWrap(wordWrap: boolean): void
  • Indicates if word wrap should be used

    member

    {boolean}

    Returns boolean

  • Indicates if word wrap should be used

    Parameters

    • wordWrap: boolean

    Returns void

wordWrapWidth

  • get wordWrapWidth(): number
  • set wordWrapWidth(wordWrapWidth: number): void
  • The width at which text will wrap, it needs wordWrap to be set to true

    member

    {number}

    Returns number

  • The width at which text will wrap, it needs wordWrap to be set to true

    Parameters

    • wordWrapWidth: number

    Returns void

Methods

clone

  • Creates a new TextStyle object with the same values as this one. Note that the only the properties of the object are cloned.

    Returns TextStyle

    New cloned TextStyle object

reset

  • reset(): void
  • Resets all properties to the defaults specified in TextStyle.prototype._default

    Returns void

toFontString

  • toFontString(): string
  • Generates a font style string to use for TextMetrics.measureFont().

    Returns string

    Font style string, for passing to TextMetrics.measureFont()

Generated using TypeDoc