Class Font

Representation of a font with optional family, size, style and weight attributes. Used as a value for font properties. The Properties.get method returns a Font instance when called with a font property name.

Hierarchy

  • Font

Index

Constructors

Properties

Methods

Constructors

constructor

  • new Font(_family: string[] | null, _size: Length | null, _style: FontStyle | null, _weight: number | null): Font
  • Creates a read-only instance of a Font. Each one of the attributes is optional.

    Parameters

    • _family: string[] | null

      The font family as an array of strings.

    • _size: Length | null

      The size of the font.

    • _style: FontStyle | null

      The style of the font.

    • _weight: number | null

      The weight of the font.

    Returns Font

Properties

family

family: string[] | null

The font family collection or null if no family is defined.

size

size: Length | null

The size of the font or null if no size is defined.

style

style: FontStyle | null

The font style, for example normal or italic. Can be null if the font does not have a specific style defined.

weight

weight: number | null

The font weight value, for example 400 for normal, or 700 for bold. Can be null if the font does not have an explicit weight defined.

Methods

toString

  • toString(): string
  • Returns string

    A (CSS compliant) representation of the Font.

Static fromObject

  • fromObject(_obj: object): Font
  • Creates a Font instance given an object with optional attributes.

    Parameters

    • _obj: object

      An object with optional font attributes.

    Returns Font

    A Font object.