Skip to content

Naming Conventions ​

Table Accessors ​

The TrueTypeFont class is the base class of all font formats. For each supported table in @pdfa-lab/fontkit, a property of the same name (tag) exists. Example:

TypeScript
const numSubtables = font.cmap?.numSubtables;

If this is the first access to the property cmap, the table is lazily loaded.

Because @pdfa-lab/fontkit may support more tables in the future, all property names with four characters are considered reserved. This is the reason why the type property is deprecated in favour of the objType property, and the bbox property is deprecated in favour of the boundingBox property.

In order to save you from typing font['CFF '], an alias font.cff exists.

Namespaces ​

For each table a namespace with the table tag followed by Table exists. For example, the avar table has the namespace avarTable. Inside the namespace, the actual table object uses the table tag as its name. For example, the avar table object is avarTable.avar.

Consequently, the definition of the avar table in the TrueTypeFont class looks like this:

TypeScript
class TrueTypeFont {
	// ...
	public avar: avarTable.avar | null;
	// ...
}

Exceptions:

  • OS/2: The namespace is OS2Table, and the type is OS2Table.OS2.
  • cvt[SPACE]: The namespace is cvtTable, and the interface is cvtTable.cvt.
  • CFF[SPACE]/cff: There is a namespace CFFTable, but the font property CFF , and its alias cff have the type CFF1Font.
  • CFF2: There is no namespace CFF2Table, and the font property has the type CFF2Font.

interface vs type ​

Hint! This section is for TypeScript only!

As a convention, @pdfa-lab prefers interface over type. Therefore, all table objects are by default defined as an interface.

However, tables that have different versions are defined as a union type. For example the OS/2 table is a union:

TypeScript
export namespace OS2Table {
	// ...
	export type OS2 = OS2V0 | OS2V1 | OS2V2 | OS2V3 | OS2V4 | OS2V5;
}