Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Label

Object comprising a text reference, a font face, and additional typographic information for type setting, rendering, and interaction. Multiple labels might reference the same text, but could be placed at different locations or rendered applying different font faces, styles etc.

Hierarchy

Index

Constructors

constructor

  • Constructs an unconfigured, empty label. Depending on the label type, transformations are applied once when typesetting (static) or every frame during rendering (dynamic).

    Parameters

    • text: Text

      The text that is displayed by this label.

    • type: Type

      Either static or dynamic. If static is used, all transformations are baked and modifications to any of the label's transformations are expected to occur less often.

    • Optional fontFace: FontFace

      The font face that should be used for that label, or undefined if set later.

    Returns Label

Properties

Protected _alignment

_alignment: Alignment = ...
see

alignment

Protected Readonly _altered

_altered: ChangeLookup & { any: boolean; color: boolean; dynamic: boolean; resources: boolean; static: boolean; text: boolean; typesetting: boolean } = ...
see

altered

Protected _backgroundColor

_backgroundColor: Color
see

{@link background}

Protected _color

_color: Color = ...
see

color

Protected _dynamicTransform

_dynamicTransform: mat4

Protected _elide

_elide: Elide = ...
see

elide

Protected _ellipsis

_ellipsis: string = ...
see

ellipsis

Protected _extent

_extent: [number, number]
see

extent

Protected _fontFace

_fontFace: undefined | FontFace
see

fontFace

Protected _fontSize

_fontSize: number
see

fontSize

Protected _fontSizeUnit

_fontSizeUnit: Unit = ...

Protected _lineAnchor

_lineAnchor: LineAnchor = ...

Protected _lineWidth

_lineWidth: number = ...
see

lineWidth

Protected _staticTransform

_staticTransform: mat4

Protected _text

_text: Text
see

text

Protected _type

_type: Type
see

type

Protected _wrap

_wrap: boolean = false
see

wrap

Static Private Readonly DEFAULT_COLOR

DEFAULT_COLOR: GLclampf4 = ...

Static Private Readonly DEFAULT_ELLIPSIS

DEFAULT_ELLIPSIS: "..." = '...'

Accessors

alignment

altered

  • get altered(): boolean

backgroundColor

  • get backgroundColor(): Color
  • set backgroundColor(color: Color): void

color

  • get color(): Color
  • set color(color: Color): void

dynamicTransform

  • get dynamicTransform(): mat4
  • set dynamicTransform(t: mat4): void
  • Stores the resulting dynamic transform. This is intended to be used when in dynamic mode. (e.g., for calculations to the final transform).

    Returns mat4

  • Stores the resulting dynamic transform. This is intended to be used when in dynamic mode. (e.g., for calculations to the final transform).

    Parameters

    Returns void

elide

  • get elide(): Elide
  • set elide(elide: Elide): void
  • If enabled, shrinks the label to line width. Depending on the elide mode, the ellipses is put left, middle, or right. The ellipsis string can be adjusted (@see ellipsis). If the labels text does not exceed the line width no elide will be applied.

    Returns Elide

  • If enabled, shrinks the label to line width. Depending on the elide mode, the ellipses is put left, middle, or right. The ellipsis string can be adjusted (@see ellipsis). If the labels text does not exceed the line width no elide will be applied.

    Parameters

    Returns void

ellipsis

  • get ellipsis(): string
  • set ellipsis(ellipsis: string): void
  • Allows to override/customize the ellipsis string used for text elide (@see elide).

    Returns string

  • Allows to override/customize the ellipsis string used for text elide (@see elide).

    Parameters

    • ellipsis: string

    Returns void

extent

  • get extent(): [number, number]
  • set extent(e: [number, number]): void
  • Returns the width and height of the typset label in fontSizeUnit. Both are zero if not typeset yet. The static transform is already applied.

    Returns [number, number]

  • The typesetter sets this extent after typesetting and applying the static transform. Don't set this manually without typesetting.

    Parameters

    • e: [number, number]

    Returns void

fontFace

  • get fontFace(): undefined | FontFace
  • set fontFace(fontFace: undefined | FontFace): void
  • Font face used for typesetting, transformation, and rendering. To avoid unnecessary state changes when rendering, prefer to add labels of the same font face consecutively (since this specifies draw sequence and state change occurs whenever font face changes between two subsequent labels).

    Returns undefined | FontFace

  • Font face used for typesetting, transformation, and rendering. To avoid unnecessary state changes when rendering, prefer to add labels of the same font face consecutively (since this specifies draw sequence and state change occurs whenever font face changes between two subsequent labels).

    Parameters

    Returns void

fontSize

  • get fontSize(): number
  • set fontSize(size: number): void

fontSizeUnit

  • get fontSizeUnit(): Unit
  • set fontSizeUnit(unit: Unit): void

length

  • get length(): number

lineAnchor

lineFeed

  • get lineFeed(): string

lineWidth

  • get lineWidth(): number
  • set lineWidth(lineWidth: number): void
  • Width of a single line in typesetting space (the unit used while Typesetting, i.e., the unit as the font face's glyph texture atlas). Since the font face needs to be defined in order to typeset, we assume here that the label has a defined fontFace.

    Returns number

  • Line width used to either maximum length for elide or maximum length for line breaks due to word wrap. The line width is expected in font size.

    Parameters

    • lineWidth: number

    Returns void

staticTransform

  • get staticTransform(): mat4
  • set staticTransform(transform: mat4): void
  • Transformation used to move, scale, rotate, skew, etc. the label into an arbitrary coordinate space (e.g., screen space, world space, ...). This can be set either explicitly or implicitly using various transformation utility functions. @todo review/refine this.

    Returns mat4

  • Transformation used to move, scale, rotate, skew, etc. the label into an arbitrary coordinate space (e.g., screen space, world space, ...). This can be set either explicitly or implicitly using various transformation utility functions. @todo review/refine this.

    Parameters

    Returns void

text

  • get text(): Text
  • set text(text: Text): void

type

  • Read-only access to this labels type specified at construction time. Static labels are baking as much transformations as possible into the glyph vertices (used for GPU). This means, when the position or size changes, the label must be typeset again and vertices are fully re-computed. For dynamic labels, only most relevant transformations are applied and dynamic transformations such as rotation, translation, scale etc, are applied during rendering without requiring re-typesetting or re-computation of vertices. The type, however, does not relate to the text. Whenever the text changes, re-typesetting etc. have to be invoked.

    Returns Type

valid

  • get valid(): boolean
  • Returns whether or not this label is ready to be rendered (aka has a font face with valid texture as well as a text with a length > 0).

    Returns boolean

wrap

  • get wrap(): boolean
  • set wrap(flag: boolean): void
  • If enabled, breaks lines automatically at line width (while typesetting). Note that elide mode takes precedence.

    Returns boolean

  • If enabled, breaks lines automatically at line width (while typesetting). Note that elide mode takes precedence.

    Parameters

    • flag: boolean

    Returns void

Methods

advance

  • advance(index: number): number
  • Returns the advancement of the glyph at given index.

    Parameters

    • index: number

      The zero-based index of the desired character. If there is no character at the specified index, NaN is returned.

    Returns number

    • advancement of the glyph at given index or NaN

charAt

  • charAt(index: number): string
  • Returns the character at the specified index.

    Parameters

    • index: number

      The zero-based index of the desired character.

    Returns string

    character at the specified index

charCodeAt

  • charCodeAt(index: number): number
  • Returns the Unicode value (codepoint) of the character at the specified location.

    Parameters

    • index: number

      The zero-based index of the desired character. If there is no character at the specified index, NaN is returned.

    Returns number

    • codepoint of the char at given index or NaN

kerningAfter

  • kerningAfter(index: number): number
  • Gets the kerning value after (i.e., right in left-to-right writing systems) the given glyph index.

    Parameters

    • index: number

      index of the glyph in this label

    Returns number

    • kerning value after glyph at given index

kerningBefore

  • kerningBefore(index: number): number
  • Gets the kerning value before (i.e., left in left-to-right writing systems) the given glyph index.

    Parameters

    • index: number

      index of the glyph in this label

    Returns number

    • kerning value before glyph at given index

lineFeedAt

  • lineFeedAt(index: number): boolean
  • Returns, whether or not the character at a given index is equal to the default or the text's line feed character.

    Parameters

    • index: number

      The zero-based index of the desired character. If there is no character at the specified index, NaN is returned.

    Returns boolean

    • true if char at given index equals the text's line feed character

reset

  • reset(): void

toString

  • toString(): string
  • Convenience getter to the label's text as string.

    Returns string

    the label's text as string

Abstract typeset

  • Interface intended to compute/update the label's static and dynamic transformations as well as invoking the typesetter in order to create the glyph vertices. Returns undefined, if previous vertices can be reused since no typesetting was required. Returns an empty GlyphVertices storage if label is invalid or cannot be rendered ...

    Returns undefined | GlyphVertices

Protected vertices

Static devicePixelRatio

  • devicePixelRatio(): number
  • Returns the window device pixel ratio. If this is not available/undefined 1.0 is returned.

    Returns number