gameforge - v0.1.12
    Preparing search index...

    Class HTMLTextStyle

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

    PIXI

    Style to copy.

    7.2.0

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _breakWords: boolean
    _dropShadow: boolean
    _dropShadowAlpha: number
    _dropShadowAngle: number
    _dropShadowBlur: number
    _dropShadowColor: string | number
    _dropShadowDistance: number
    _fillGradientStops: number[]
    _fillGradientType: TEXT_GRADIENT
    _fontFamily: string | string[]
    _fontSize: string | number
    _fontStyle: TextStyleFontStyle
    _fontVariant: TextStyleFontVariant
    _fontWeight: TextStyleFontWeight
    _leading: number
    _letterSpacing: number
    _lineHeight: number
    _miterLimit: number
    _padding: number
    _stroke: string | number
    _strokeThickness: number
    _textBaseline: TextStyleTextBaseline
    _trim: boolean
    _whiteSpace: TextStyleWhiteSpace
    _wordWrap: boolean
    _wordWrapWidth: number
    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

    • set align(align: TextStyleAlign): 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: boolean): 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: boolean): 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: number): 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: number): 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: number): 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: string | number): 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: number): 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: 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.

      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: number): void

      If fill is an array of colours to create a gradient, this can change the type/direction of the 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: string | string[]): 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: 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')

      Parameters

      • fontSize: string | number

      Returns void

    • get fontStyle(): TextStyleFontStyle

      The font style.

      Returns TextStyleFontStyle

    • set fontStyle(fontStyle: TextStyleFontStyle): void

      The font style.

      Parameters

      Returns void

    • get fontVariant(): TextStyleFontVariant

      The font variant.

      Returns TextStyleFontVariant

    • set fontVariant(fontVariant: TextStyleFontVariant): void

      The font variant.

      Parameters

      Returns void

    • get fontWeight(): TextStyleFontWeight

      The font weight.

      Returns TextStyleFontWeight

    • set fontWeight(fontWeight: TextStyleFontWeight): void

      The font weight.

      Parameters

      Returns void

    • get leading(): number

      The space between lines.

      Returns number

    • set leading(_value: number): void

      The space between lines.

      Parameters

      • _value: number

      Returns void

    • get letterSpacing(): number

      The amount of spacing between letters, default is 0.

      Returns number

    • set letterSpacing(letterSpacing: number): 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: number): 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

    • set lineJoin(_value: TextStyleLineJoin): void

      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

    • 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: number): 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: number): 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: string | number): 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

      0
      
    • set strokeThickness(strokeThickness: number): 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: string): void

      Parameters

      • value: string

      Returns void

    • get textBaseline(): TextStyleTextBaseline

      The baseline of the text that is rendered.

      Returns TextStyleTextBaseline

    • set textBaseline(_value: TextStyleTextBaseline): void

      The baseline of the text that is rendered.

      Parameters

      Returns void

    • get trim(): boolean

      Trim transparent borders.

      Returns boolean

    • set trim(_value: boolean): 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

    • set whiteSpace(whiteSpace: TextStyleWhiteSpace): 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: boolean): 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: number): 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

      • ...value: string[]

        CSS style(s) to add.

      Returns void

      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 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

      • ...value: string[]

        CSS style to remove.

      Returns void

      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

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