• DR-IT Software
  • Products
  • Documentation
  • Product page
  • Examples
  • API reference
  • Support
Show / Hide Table of Contents

Class TtfLocaTable

Parsed OpenType "loca" table (index to location). Maps glyph indices to their byte offsets within the "glyf" table.

Inheritance
object
TtfTableBase
TtfLocaTable
Inherited Members
TtfTableBase.Tag
TtfTableBase.RawBytes
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DRIT.Drawing.Font.Ttf.Tables
Assembly: DRIT.Drawing.dll
Syntax
public sealed class TtfLocaTable : TtfTableBase
Remarks

The table stores numGlyphs + 1 offsets so the length of any glyph's data can be derived as loca[i+1] − loca[i]. A zero-length entry means the glyph has no outline (e.g. the space character).

Format is controlled by head.indexToLocFormat:

  • 0 (short): 16-bit values, each multiplied by 2 to get the byte offset.
  • 1 (long): 32-bit values used as-is.

Ref: OpenType spec §5.2.5.

Fields

TableTag

The table tag for the loca table.

Declaration
public const string TableTag = "loca"
Field Value
Type Description
string
Remarks

The table stores numGlyphs + 1 offsets so the length of any glyph's data can be derived as loca[i+1] − loca[i]. A zero-length entry means the glyph has no outline (e.g. the space character).

Format is controlled by head.indexToLocFormat:

  • 0 (short): 16-bit values, each multiplied by 2 to get the byte offset.
  • 1 (long): 32-bit values used as-is.

Ref: OpenType spec §5.2.5.

Properties

GlyphCount

Total number of glyph entries (excluding the sentinel).

Declaration
public int GlyphCount { get; }
Property Value
Type Description
int
Remarks

The table stores numGlyphs + 1 offsets so the length of any glyph's data can be derived as loca[i+1] − loca[i]. A zero-length entry means the glyph has no outline (e.g. the space character).

Format is controlled by head.indexToLocFormat:

  • 0 (short): 16-bit values, each multiplied by 2 to get the byte offset.
  • 1 (long): 32-bit values used as-is.

Ref: OpenType spec §5.2.5.

IndexToLocFormat

The indexToLocFormat value from the "head" table: 0 = short format, 1 = long format.

Declaration
public short IndexToLocFormat { get; }
Property Value
Type Description
short
Remarks

The table stores numGlyphs + 1 offsets so the length of any glyph's data can be derived as loca[i+1] − loca[i]. A zero-length entry means the glyph has no outline (e.g. the space character).

Format is controlled by head.indexToLocFormat:

  • 0 (short): 16-bit values, each multiplied by 2 to get the byte offset.
  • 1 (long): 32-bit values used as-is.

Ref: OpenType spec §5.2.5.

Methods

GetGlyphLength(int)

Returns the byte length of the glyph data for glyphIndex. A return value of 0 indicates a glyph with no outline (e.g. space).

Declaration
public uint GetGlyphLength(int glyphIndex)
Parameters
Type Name Description
int glyphIndex
Returns
Type Description
uint
Remarks

The table stores numGlyphs + 1 offsets so the length of any glyph's data can be derived as loca[i+1] − loca[i]. A zero-length entry means the glyph has no outline (e.g. the space character).

Format is controlled by head.indexToLocFormat:

  • 0 (short): 16-bit values, each multiplied by 2 to get the byte offset.
  • 1 (long): 32-bit values used as-is.

Ref: OpenType spec §5.2.5.

GetGlyphOffset(int)

Returns the absolute byte offset of glyph glyphIndex within the "glyf" table data. Returns 0 for out-of-range indices.

Declaration
public uint GetGlyphOffset(int glyphIndex)
Parameters
Type Name Description
int glyphIndex
Returns
Type Description
uint
Remarks

The table stores numGlyphs + 1 offsets so the length of any glyph's data can be derived as loca[i+1] − loca[i]. A zero-length entry means the glyph has no outline (e.g. the space character).

Format is controlled by head.indexToLocFormat:

  • 0 (short): 16-bit values, each multiplied by 2 to get the byte offset.
  • 1 (long): 32-bit values used as-is.

Ref: OpenType spec §5.2.5.

Parse(byte[], short, ushort)

Parses the "loca" table from its raw bytes.

Declaration
public static TtfLocaTable Parse(byte[] rawBytes, short indexToLocFormat, ushort numGlyphs)
Parameters
Type Name Description
byte[] rawBytes

Raw table data.

short indexToLocFormat

Value from IndexToLocFormat: 0 = short (×2), 1 = long.

ushort numGlyphs

Total glyph count from NumGlyphs. The table will contain numGlyphs + 1 offset entries.

Returns
Type Description
TtfLocaTable
Remarks

The table stores numGlyphs + 1 offsets so the length of any glyph's data can be derived as loca[i+1] − loca[i]. A zero-length entry means the glyph has no outline (e.g. the space character).

Format is controlled by head.indexToLocFormat:

  • 0 (short): 16-bit values, each multiplied by 2 to get the byte offset.
  • 1 (long): 32-bit values used as-is.

Ref: OpenType spec §5.2.5.

Back to top

DR-IT Software documentation

DR-IT Software · Products · Documentation index · Product page · Downloads · Support · Licensing

Generated by DocFX