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:
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:
class TrueTypeFont {
// ...
public avar: avarTable.avar | null;
// ...
}Exceptions:
OS/2: The namespace isOS2Table, and the type isOS2Table.OS2.cvt[SPACE]: The namespace iscvtTable, and the interface iscvtTable.cvt.CFF[SPACE]/cff: There is a namespaceCFFTable, but the font propertyCFF, and its aliascffhave the typeCFF1Font.CFF2: There is no namespaceCFF2Table, and the font property has the typeCFF2Font.
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:
export namespace OS2Table {
// ...
export type OS2 = OS2V0 | OS2V1 | OS2V2 | OS2V3 | OS2V4 | OS2V5;
}