Used internally to restrict text style usage and convert easily to CSS.

Memberof

PIXI

Param: style

Style to copy.

Since

7.2.0

Hierarchy (view full)

Constructors

  • Parameters

    • Optional style: Partial<ITextStyle>

      TextStyle properties to be set on the text. See PIXI.TextStyle.defaultStyle for the default values.

    Returns HTMLTextStyle

Properties

styleID: number
availableFonts: Record<string, IHTMLFont>

The collection of installed fonts

defaultOptions: IHTMLTextStyle

List of default options, these are largely the same as TextStyle, with the exception of whiteSpace, which is set to 'normal' by default.

defaultStyle: ITextStyle

Default style options used for all TextStyle instances.

Accessors

  • get align(): TextStyleAlign
  • Alignment for multiline text, does not affect single line text.

    Returns TextStyleAlign

    Member

  • set align(align): void
  • Alignment for multiline text, does not affect single line text

    Parameters

    Returns void

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

    Returns boolean

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

    Parameters

    • breakWords: boolean

    Returns void

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

    Returns boolean

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

    Parameters

    • dropShadow: boolean

    Returns void

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

    Returns number

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

    Parameters

    • dropShadowAlpha: number

    Returns void

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

    Returns number

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

    Parameters

    • dropShadowAngle: number

    Returns void

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

    Returns number

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

    Parameters

    • dropShadowBlur: number

    Returns void

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

    Returns string | number

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

    Parameters

    • dropShadowColor: string | number

    Returns void

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

    Returns number

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

    Parameters

    • dropShadowDistance: number

    Returns void

  • get fillGradientStops(): 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.

    Returns number[]

  • set fillGradientStops(_value): 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.

    Parameters

    • _value: number[]

    Returns void

  • get fillGradientType(): number
  • If fill is an array of colours to create a gradient, this can change the type/direction of the gradient.

    Returns number

  • set fillGradientType(_value): void
  • If fill is an array of colours to create a gradient, this can change the type/direction of the gradient. See PIXI.TEXT_GRADIENT

    Parameters

    • _value: number

    Returns void

  • get fontFamily(): string | string[]
  • The font family, can be a single font name, or a list of names where the first is the preferred font.

    Returns string | string[]

  • set fontFamily(fontFamily): void
  • The font family, can be a single font name, or a list of names where the first is the preferred font.

    Parameters

    • fontFamily: string | string[]

    Returns void

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

    Returns string | number

  • set fontSize(fontSize): void
  • 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

  • get fontStyle(): TextStyleFontStyle
  • The font style.

    Returns TextStyleFontStyle

    Member

  • set fontStyle(fontStyle): void
  • The font style.

    Parameters

    Returns void

  • get fontVariant(): TextStyleFontVariant
  • The font variant.

    Returns TextStyleFontVariant

    Member

  • set fontVariant(fontVariant): void
  • The font variant.

    Parameters

    Returns void

  • get fontWeight(): TextStyleFontWeight
  • The font weight.

    Returns TextStyleFontWeight

    Member

  • set fontWeight(fontWeight): void
  • The font weight.

    Parameters

    Returns void

  • get leading(): number
  • The space between lines.

    Returns number

  • set leading(_value): void
  • The height of the line, a number that represents the vertical space that a letter uses.

    Parameters

    • _value: number

    Returns void

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

    Returns number

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

    Parameters

    • letterSpacing: number

    Returns void

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

    Returns number

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

    Parameters

    • lineHeight: number

    Returns void

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

    Returns TextStyleLineJoin

    Member

  • set lineJoin(_value): void
  • The lineJoin property sets the type of corner created, it can resolve spiked text issues. Possible values "miter" (creates a sharp corner), "round" (creates a round corner) or "bevel" (creates a squared corner).

    Parameters

    Returns void

  • get miterLimit(): number
  • The miter limit to use when using the 'miter' lineJoin mode.

    This can reduce or increase the spikiness of rendered text.

    Returns number

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

    Parameters

    • _value: number

    Returns void

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

    Returns number

  • set padding(padding): void
  • 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

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

    Returns string | number

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

    Parameters

    • stroke: string | number

    Returns void

  • get strokeThickness(): number
  • A number that represents the thickness of the stroke.

    Returns number

    Default

    0
    
  • set strokeThickness(strokeThickness): void
  • A number that represents the thickness of the stroke. A value of 0 will disable stroke.

    Parameters

    • strokeThickness: number

    Returns void

  • get stylesheet(): string
  • Internal stylesheet contents, useful for creating rules for rendering

    Returns string

  • set stylesheet(value): void
  • Parameters

    • value: string

    Returns void

  • get textBaseline(): TextStyleTextBaseline
  • The baseline of the text that is rendered.

    Returns TextStyleTextBaseline

    Member

  • set textBaseline(_value): void
  • The baseline of the text that is rendered.

    Parameters

    Returns void

  • get trim(): boolean
  • Trim transparent borders.

    Returns boolean

  • set trim(_value): void
  • Trim transparent borders

    Parameters

    • _value: boolean

    Returns void

  • get whiteSpace(): 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

    Returns TextStyleWhiteSpace

    Member

  • set whiteSpace(whiteSpace): void
  • Determines whether newlines & spaces are collapsed or preserved "normal" (collapse, collapse), "pre" (preserve, preserve) | "pre-line" (preserve, collapse). It needs wordWrap to be set to true.

    Parameters

    Returns void

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

    Returns boolean

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

    Parameters

    • wordWrap: boolean

    Returns void

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

    Returns number

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

    Parameters

    • wordWrapWidth: number

    Returns void

Methods

  • Add a style override, this can be any CSS property it will override any built-in style. This is the property and the value as a string (e.g., color: red). This will override any other internal style.

    Parameters

    • Rest ...value: string[]

      CSS style(s) to add.

    Returns void

    Example

    style.addOverride('background-color: red');
    
  • Clear the current font

    Returns void

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

    Returns Pixi.TextStyle

    New cloned TextStyle object

  • Because of how HTMLText renders, fonts need to be imported

    Parameters

    Returns Promise<void>

  • Remove any overrides that match the value.

    Parameters

    • Rest ...value: string[]

      CSS style to remove.

    Returns void

    Example

    style.removeOverride('background-color: red');
    
  • Resets all properties to the defaults specified in TextStyle.prototype._default

    Returns void

  • Internally converts all of the style properties into CSS equivalents.

    Parameters

    • scale: number

    Returns string

    The CSS style string, for setting style property of root HTMLElement.

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

    Returns string

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

  • Get the font CSS styles from the loaded font, If available.

    Returns string

  • Convert a TextStyle to HTMLTextStyle

    Parameters

    Returns HTMLTextStyle

    Example

    import {TextStyle } from 'pixi.js';
    import {HTMLTextStyle} from '@pixi/text-html';
    const style = new TextStyle();
    const htmlStyle = HTMLTextStyle.from(style);

Generated using TypeDoc