Class TextFormatter

Hierarchy

  • TextFormatter

Properties

DEBUG: boolean = false

To enable logging for this class. Set Vex.Flow.TextFormatter.DEBUG to true.

Accessors

  • get fontSizeInPixels(): number
  • this.size is specified in points. Convert to pixels.

    Returns number

  • get localHeightCache(): Record<string, undefined | yExtent>
  • Returns Record<string, undefined | yExtent>

  • get maxHeight(): number
  • Returns number

Methods

  • The glyphs table is indexed by the character (e.g., 'C', '@'). See: robotoslab_glyphs.ts & petalumascript_glyphs.ts.

    Parameters

    • character: string

    Returns FontGlyph

  • Returns number

  • Retrieve the character's advanceWidth as a fraction of an em unit. For the space character ' ' as defined in the: petalumascript_glyphs.ts: 250 advanceWidth in the 1000 unitsPerEm font returns 0.25. robotoslab_glyphs.ts: 509 advanceWidth in the 2048 unitsPerEm font returns 0.2485.

    Parameters

    • c: string

    Returns number

  • Retrieve the total width of text in em units.

    Parameters

    • text: string

    Returns number

  • The width of the text (in em) is scaled by the font size (in px).

    Parameters

    • text: string

    Returns number

  • Retrieve the character's y bounds (ymin, ymax) and height.

    Parameters

    • c: string

    Returns yExtent

  • Parameters

    • str: string

    Returns yExtent

  • Create a hash with the current font data, so we can cache computed widths.

    Returns void

  • Call TextFormatter.registerInfo(info) to register font information before using this method.

    This method creates a formatter for the font that most closely matches the requested font. We compare font family, bold, and italic attributes. This method will return a fallback formatter if there are no matches.

    Parameters

    Returns TextFormatter

  • Parameters

    • fontFamily: string

      used as a key to the font registry.

    Returns undefined | TextFormatterInfo

    the same info object that was passed in via TextFormatter.registerInfo(info)

  • Apps may register their own fonts and metrics, and those metrics will be available to the app for formatting.

    Metrics can be generated from a font file using fontgen_text.js in the tools/fonts directory.

    Parameters

    Returns void