BitmapFont represents a typeface available for use with the BitmapText class. Use the install method for adding a font to be used.

Memberof

PIXI

Constructors

Properties

The map of characters by character code.

distanceFieldRange: number

The range of the distance field in pixels.

distanceFieldType: string

The kind of distance field for this font or "none".

font: string

The name of the font face.

lineHeight: number

The line-height of the font face in pixels.

pageTextures: Dict<Texture<Resource>>

The map of base page textures (i.e., sheets of glyphs).

size: number

The size of the font face in pixels.

ALPHA: (string | string[])[]

This character set includes all the letters in the alphabet (both lower- and upper- case).

Example

BitmapFont.from('ExampleFont', style, { chars: BitmapFont.ALPHA })
ALPHANUMERIC: (string | string[])[]

This character set is the union of BitmapFont.ALPHA and BitmapFont.NUMERIC.

ASCII: string[][]

This character set consists of all the ASCII table.

NUMERIC: string[][]

This character set includes all decimal digits (from 0 to 9).

Example

BitmapFont.from('ExampleFont', style, { chars: BitmapFont.NUMERIC })
available: Dict<BitmapFont>

Collection of available/installed fonts.

defaultOptions: IBitmapFontOptions

Collection of default options when using BitmapFont.from.

Methods

  • Remove references to created glyph textures.

    Returns void

  • Generates a bitmap-font for the given style and character set. This does not support kernings yet. With style properties, only the following non-layout properties are used:

    • PIXI.TextStyle#dropShadow|dropShadow
    • PIXI.TextStyle#dropShadowDistance|dropShadowDistance
    • PIXI.TextStyle#dropShadowColor|dropShadowColor
    • PIXI.TextStyle#dropShadowBlur|dropShadowBlur
    • PIXI.TextStyle#dropShadowAngle|dropShadowAngle
    • PIXI.TextStyle#fill|fill
    • PIXI.TextStyle#fillGradientStops|fillGradientStops
    • PIXI.TextStyle#fillGradientType|fillGradientType
    • PIXI.TextStyle#fontFamily|fontFamily
    • PIXI.TextStyle#fontSize|fontSize
    • PIXI.TextStyle#fontVariant|fontVariant
    • PIXI.TextStyle#fontWeight|fontWeight
    • PIXI.TextStyle#lineJoin|lineJoin
    • PIXI.TextStyle#miterLimit|miterLimit
    • PIXI.TextStyle#stroke|stroke
    • PIXI.TextStyle#strokeThickness|strokeThickness
    • PIXI.TextStyle#textBaseline|textBaseline

    Parameters

    • name: string

      The name of the custom font to use with BitmapText.

    • Optional textStyle: Pixi.TextStyle | Partial<ITextStyle>

      Style options to render with BitmapFont.

    • Optional options: IBitmapFontOptions

      Setup options for font or name of the font.

    Returns BitmapFont

    Font generated by style options.

    Example

    import { BitmapFont, BitmapText } from 'pixi.js';

    BitmapFont.from('TitleFont', {
    fontFamily: 'Arial',
    fontSize: 12,
    strokeThickness: 2,
    fill: 'purple',
    });

    const title = new BitmapText('This is the title', { fontName: 'TitleFont' });
  • Register a new bitmap font.

    Parameters

    • data: string | XMLDocument | BitmapFontData

      The characters map that could be provided as xml or raw string.

    • textures: Texture<Resource> | Texture<Resource>[] | Dict<Texture<Resource>>

      List of textures for each page.

    • Optional ownsTextures: boolean

      Set to true to destroy page textures when the font is uninstalled. By default fonts created with BitmapFont.from or from the BitmapFontLoader are true.

    Returns BitmapFont

    Result font object with font, size, lineHeight and char fields.

  • Remove bitmap font by name.

    Parameters

    • name: string

      Name of the font to uninstall.

    Returns void

Generated using TypeDoc