Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Glyph

Glyph related data for glyph based text rendering. Most of the glyph data (except the advance) refers to the font face's glyph-texture. This class does not provide dpi awareness. This has to be handled outside of this class, e.g., during layouting and rendering. The following definitions are applied: http://chanae.walon.org/pub/ttf/ttf_glyphs.htm

Hierarchy

  • Glyph

Index

Constructors

constructor

  • new Glyph(index?: GLsizei, advance?: GLfloat): Glyph
  • Parameters

    • Default value index: GLsizei = 0
    • Default value advance: GLfloat = 0

    Returns Glyph

Properties

Protected _advance

_advance: GLfloat
see

advance

Protected _bearing

_bearing: GLfloat2 = [0.0, 0.0]
see

bearing

Protected _extent

_extent: GLfloat2 = [0.0, 0.0]
see

extent

Protected _index

_index: GLsizei
see

index

Protected _kernings

_kernings: Map<number, number> = new Map<GLsizei, GLfloat>()
see

kernings

Protected _subTextureExtent

_subTextureExtent: GLclampf2 = [0.0, 0.0]

Protected _subTextureOrigin

_subTextureOrigin: GLclampf2 = [0.0, 0.0]

Accessors

advance

  • get advance(): GLfloat
  • set advance(advance: GLfloat): void
  • Set the glyph's horizontal overall advance in pt. The horizontal advance comprises the font face's left and right padding, the glyphs (inner) width as well as the horizontal bearing (and often a glyph specific gap). E.g., advance = subTextureExtent_width + xOffset (+ gap), or alternatively: advance = xOffset + padding_left + glyph_width + padding_right (+ gap)

    The glyphs horizontal advance (along the baseline) in pt.

    Returns GLfloat

  • Set the glyph's horizontal overall advance in pt. The horizontal advance comprises the font face's left and right padding, the glyphs (inner) width as well as the horizontal bearing (and often a glyph specific gap). E.g., advance = subTextureExtent_width + xOffset (+ gap), or alternatively: advance = xOffset + padding_left + glyph_width + padding_right (+ gap)

    Parameters

    • advance: GLfloat

      The glyphs horizontal advance (along the baseline) in pt.

    Returns void

bearing

  • The x and y offsets w.r.t. to the pen-position on the baseline. The horizontal bearing does not comprise the glyph-texture's padding provided by the owning font face (@see FontFace). The vertical bearing also does not comprises the glyph texture's padding and is the measured w.r.t. baseline.

    Horizontal and vertical bearing based on the glyph's origin/pen-position placed on the baseline in pt.

    Returns GLfloat2

  • The x and y offsets w.r.t. to the pen-position on the baseline. The horizontal bearing does not comprise the glyph-texture's padding provided by the owning font face (@see FontFace). The vertical bearing also does not comprises the glyph texture's padding and is the measured w.r.t. baseline.

    Parameters

    • bearing: GLfloat2

      Horizontal and vertical bearing based on the glyph's origin/pen-position placed on the baseline in pt.

    Returns void

extent

  • Width and height of the glyph in pt.

    The glyph's extent by means of width and height in pt.

    Returns GLfloat2

  • Width and height of the glyph in pt.

    Parameters

    • extent: GLfloat2

      The glyph's extent by means of width and height in pt.

    Returns void

index

  • get index(): GLsizei
  • set index(index: GLsizei): void
  • Set the index of one single distinguishable character.

    Returns GLsizei

  • Set the index of one single distinguishable character.

    Parameters

    • index: GLsizei

    Returns void

subTextureExtent

  • Width and height of the glyph's sub-texture. In combination with the sub-texture offset (subTextureOffset) the sub-texture rectangle is implicitly fully specified in normalized texture coordinates. Note: the extent comprises the font face's padding.

    Returns GLclampf2

  • Width and height of the glyph's sub-texture. In combination with the sub-texture offset (subTextureOffset) the sub-texture rectangle is implicitly fully specified in normalized texture coordinates. Note: the extent comprises the font face's padding.

    Parameters

    • extent: GLclampf2

      Normalized width and height of the glyph's sub-texture.

    Returns void

subTextureOrigin

  • Upper left position of the glyph's sub-texture. The upper left position refers to the glyph-texture that is specified by a font face (@see FontFace). It is the u and v coordinates pointing to the glyphs sub-texture within the texture atlas. The coordinates are normalized in [0;1].

    Returns GLclampf2

  • Upper left position of the glyph's sub-texture. The upper left position refers to the glyph-texture that is specified by a font face (@see FontFace). It is the u and v coordinates pointing to the glyphs sub-texture within the texture atlas. The coordinates are normalized in [0;1].

    Parameters

    • origin: GLclampf2

      Normalized coordinates pointing to the upper left texel of the glyph's sub-texture.

    Returns void

Methods

bearingFromFontBaseAndOffset

  • bearingFromFontBaseAndOffset(fontBase: GLfloat, xOffset: GLfloat, yOffset: GLfloat): void
  • Convenience setter for the x and y bearings. The horizontal bearing does not comprise the glyph-texture's padding provided by the owning font face (see FontFace). The vertical bearing also does not comprise the glyph- texture's padding and is the measured w.r.t. baseline. Padding is expected to be handled by the typesetter. The vertical bearing is computed as follows: bearingY = fontBase - yOffset The horizontal bearing equals the xOffset: bearingX = xOffset:

    Parameters

    • fontBase: GLfloat

      The font face's (FontFace) base-to-top distance in pt.

    • xOffset: GLfloat

      The glyphs horizontal offset without left padding.

    • yOffset: GLfloat

      The glyphs vertical offset w.r.t. the font's topmost ascenders, without the font's top padding in pt.

    Returns void

depictable

  • depictable(): boolean
  • Check if a glyph is depictable/renderable. If the glyph's sub texture vertical or horizontal extent is zero the glyph does not need to be depicted/rendered. E.g., spaces, line feeds, other control sequences as well as unknown glyphs do not need to be processed for rendering.

    Returns boolean

    • True if the glyph needs to be depicted/rendered.

kerning

  • kerning(subsequentIndex: GLsizei): GLfloat
  • The glyph's kernel w.r.t. a subsequent glyph in pt. The kerning provides a(usually negative) offset along the baseline that can be used to move the pen-position respectively, i.e., the subsequent pen-position is computed as follows: pen-position + advance + kerning

    Parameters

    • subsequentIndex: GLsizei

      The subsequent glyph's index.

    Returns GLfloat

    • The kerning w.r.t. to the subsequent glyph in pt. If no kerning data is available for the subsequent glyph, the return value is zero indicating no kerning.

setKerning

  • setKerning(subsequentIndex: GLsizei, kerning: GLfloat): void
  • Set the glyph's kernel w.r.t. a subsequent glyph in pt. @see kerning

    Parameters

    • subsequentIndex: GLsizei

      The subsequent glyph's index.

    • kerning: GLfloat

      The kerning value w.r.t. to the subsequent glyph in pt. Note that the kerning should be a negative value but is not enforced to be in terms of assertion or clamping. If kerning data for the subsequent glyph is already available it will be updated to the provided value.

    Returns void