Skip to content

@pdfa-lab/fontkit / TrueTypeFont

Class: TrueTypeFont<TDirectory> ​

Defined in: src/true-type-font.ts:114

This is the base class for all SFNT-based font formats in fontkit. It supports TrueType, and PostScript glyphs, and several colour glyph formats.

Extends ​

Extended by ​

Type Parameters ​

Type ParameterDefault type
TDirectory extends SFNTDirectorySFNTDirectory

Implements ​

Indexable ​

[key: string]: unknown

Constructors ​

Constructor ​

new TrueTypeFont<TDirectory>(streamOrBuffer, variationCoords?): TrueTypeFont<TDirectory>

Defined in: src/true-type-font.ts:214

Instantiates a font object from binary font data. You can either pass in a Uint8Array or DecodeStream from the restructure library (@see https://github.com/foliojs/restructure).

Parameters ​

ParameterTypeDefault valueDescription
streamOrBufferUint8Array<ArrayBufferLike> | DecodeStreamundefinedbinary font data
variationCoordsnumber[] | nullnullNormalised design coordinates (typically ranging from -1.0 to 1.0) used to select a specific instance within a variable font's design space.

Returns ​

TrueTypeFont<TDirectory>

Inherited from ​

Font.constructor

Properties ​

PropertyModifierTypeDefault valueDescriptionInherited fromDefined in
avarpublicavar | nullundefinedAxis Variations Table. Modifies normalised coordinates across axes in variable fonts.Font.avar Font.avarsrc/font.ts:324
BASEpublicBASE | nullundefinedBaseline Data Table. Sets alignment values dynamically shifting script baselines.Font.BASE Font.BASEsrc/font.ts:235
bslnpublicbsln | nullundefinedBaseline Table. Provides baseline shift measurements for multi-script alignment.Font.bsln Font.bslnsrc/font.ts:330
CBLCpublicEBLC | nullundefinedColour Bitmap Data Table. Variant containing colour bitmap raw data blocks.Font.CBLC Font.CBLCsrc/font.ts:211
CFF publicCFF1Font | nullundefinedAlternate PostScript Compact Font Format alias mapping.Font.CFF Font.CFF src/font.ts:188
CFF2publicCFF2Font | nullundefinedPostScript Compact Font Format (CFF) Outline Table version 2.Font.CFF2 Font.CFF2src/font.ts:193
cmappubliccmap | nullundefinedCharacter to Glyph Index Mapping Table. Maps characters to internal glyph indices.Font.cmap Font.cmapsrc/font.ts:106
COLRpublicCOLR | nullundefinedColour Table. Outlines layering configurations for multi-coloured vector icon layouts.Font.COLR Font.COLRsrc/font.ts:223
CPALpublicCPAL | nullundefinedColour Palette Table. Maps index arrays declaring hex colours utilised by COLR elements.Font.CPAL Font.CPALsrc/font.ts:229
cvt publiccvt | nullundefinedControl Value Table. Stores indexed control values used by TrueType instructions to maintain consistency when hinting glyphs.Font.cvt Font.cvt src/font.ts:172
defaultLanguagepublicstring | nullundefinedThe default language as an ISO 639-1 code ('en', 'fr', ...).Font.defaultLanguage Font.defaultLanguagesrc/true-type-font.ts:152
DSIGpublicDSIG | nullundefinedDigital Signature Table. Encapsulates cryptographic signatures validating binary authenticity.Font.DSIG Font.DSIGsrc/font.ts:271
EBLCpublicEBLC | nullundefinedEmbedded Bitmap Data Table. Stores bitmap images for specific point sizes.Font.EBLC Font.EBLCsrc/font.ts:205
featpublicfeat | nullundefinedFeature Name Table. Maps AAT feature selectors to localised string references.Font.feat Font.featsrc/font.ts:336
fpgmpublicfpgm | nullundefinedFont Program Table. Contains low-level hints executing instruction sets across grid points.Font.fpgm Font.fpgmsrc/font.ts:154
fvarpublicfvar | nullundefinedFont Variations Table. Declares design axes and instance configurations in variable fonts.Font.fvar Font.fvarsrc/font.ts:342
gasppublicgasp | nullundefinedGrid-fitting and Scan-conversion Procedure Table. Optimises text raster rendering constraints.Font.gasp Font.gaspsrc/font.ts:277
GDEFpublicGDEF | nullundefinedGlyph Definition Table. Categorises glyph types (e.g., base, ligature, mark) for layout alignment.Font.GDEF Font.GDEFsrc/font.ts:241
glyfpublicglyph | nullundefinedGlyph Data Table. Describes TrueType glyph outlines, including contour coordinates, composite glyph components, and hinting instructions.Font.glyf Font.glyfsrc/font.ts:178
glyphsprotectedRecord<number, Glyph>{}--src/true-type-font.ts:145
GPOSpublicGPOS | nullundefinedGlyph Positioning Table. Provides precise metric adjustments handling kerning and attachment marks.Font.GPOS Font.GPOSsrc/font.ts:247
GSUBpublicGSUB | nullundefinedGlyph Substitution Table. Supplies glyph substitutions for contextual alternates, ligatures, and script-specific rendering.Font.GSUB Font.GSUBsrc/font.ts:253
gvarpublicgvar | nullundefinedGlyph Variations Table. Controls structural outline distortion transformations for variable glyphs.Font.gvar Font.gvarsrc/font.ts:348
hdmxpublichdmx | nullundefinedHorizontal Device Metrics Table. Preserves explicit pixel width mappings optimising spacing.Font.hdmx Font.hdmxsrc/font.ts:283
headpublichead | nullundefinedFont Header Table. Tracks global typographic metrics, scale grid bounds, and metadata.Font.head Font.headsrc/font.ts:112
hheapublichhea | nullundefinedHorizontal Header Table. Stores global metric parameters for horizontal glyph layouts.Font.hhea Font.hheasrc/font.ts:118
hmtxpublichmtx | nullundefinedHorizontal Metrics Table. Contains advance widths and left side bearings for all glyphs.Font.hmtx Font.hmtxsrc/font.ts:124
HVARpublicHVAR | nullundefinedHorizontal Variation Metrics Table. Adjusts advance metrics across design spaces in variable fonts.Font.HVAR Font.HVARsrc/font.ts:265
JSTFpublicJSTF | nullundefinedJustification Table. Provides options for justification adjustments in complex scripts.Font.JSTF Font.JSTFsrc/font.ts:259
justpublicjust | nullundefinedJustification Table (just). Provides layout rules for line justification, glyph width deltas, and post-compensation actions in AAT typography.Font.just Font.justsrc/font.ts:354
kernpublickern | nullundefinedKerning Table. Contains traditional pairwise spacing adjustments.Font.kern Font.kernsrc/font.ts:288
locapublicloca | nullundefinedIndex to Location Table. Maps local offsets for binary data streams resolving glyph outlines.Font.loca Font.locasrc/font.ts:160
LTSHpublicLTSH | nullundefinedLinear Threshold Table. Sets pixel-per-em limits where scaling instructions degrade.Font.LTSH Font.LTSHsrc/font.ts:294
maxppublicmaxp | nullundefinedMaximum Profile Table. Explicitly defines memory boundaries and total glyph count constraints.Font.maxp Font.maxpsrc/font.ts:130
morxpublicmorx | nullundefinedExtended Glyph Metamorphosis Table. Powers state-machine transformations substituting AAT items.Font.morx Font.morxsrc/font.ts:360
namepublicname | nullundefinedNaming Table. Contains multilingual string records for copyrights, families, and system IDs.Font.name Font.namesrc/font.ts:136
objTypereadonlystringTrueTypeFont.objTypeDiscriminating property. Has the same value as the static TrueTypeFont.objType property.-src/true-type-font.ts:133
opbdpublicopbd | nullundefinedOptical Bounds Table. Sets bounding limits to align glyphs based on visual centre points.Font.opbd Font.opbdsrc/font.ts:366
OS/2publicOS2 | nullundefinedOS/2 and Windows Metrics Table. Contains subsystem configurations, weights, and unicode ranges.Font.OS/2 Font.OS/2src/font.ts:142
outlinespublic"" | "none" | "PostScript" | "TrueType"''Determines the type of glyph outlines based on the presence of the required tables. Fonts without the core OpenType tables are identified by an empty string (@see OpenTypeNoOutlinesFont). If all core OpenType tables are present, the outline type is either 'TrueType' if the loca table is present, or PostScript if either CFF or CFF2 are present, 'none' otherwise. See - OpenTypeTrueTypeFont - OpenTypePostScriptFont-src/true-type-font.ts:178
outlineVersionpublicnumber0Discriminator for the different flavours of OpenTypePostScriptFont. If the CFF2 table is present, outline version is 2, if the CFF table is present, it is 1. For fonts that do not have PostScript, outlines, the value is 0.-src/true-type-font.ts:188
PCLTpublicPCLT | nullundefinedPCL 5 Table. Contains metrics and command parameters for HP LaserJet compatibility.Font.PCLT Font.PCLTsrc/font.ts:300
postpublicpost | nullundefinedPostScript Table. Encapsulates printer operational bounds and memory-tracking metrics.Font.post Font.postsrc/font.ts:148
preppublicprep | nullundefinedControl Value Program Table. Provides global instructions establishing variable outline alignment.Font.prep Font.prepsrc/font.ts:166
sbixpublicsbix | nullundefinedStandard Bitmap Graphics Table. Embeds raster configurations (PNG/JPEG) directly within glyph IDs.Font.sbix Font.sbixsrc/font.ts:217
typereadonlystringTrueTypeFont.objTypeDeprecated Use TrueTypeFont#objType instead!-src/true-type-font.ts:138
VDMXpublicVDMX | nullundefinedVertical Device Metrics Table. Preserves explicit vertical pixel height mappings.Font.VDMX Font.VDMXsrc/font.ts:306
vheapublicvhea | nullundefinedVertical Header Table. Stores global metric parameters for vertical text directions.Font.vhea Font.vheasrc/font.ts:312
vmtxpublicvmtx | nullundefinedVertical Metrics Table. Contains advance heights and top side bearings for vertical layouts.Font.vmtx Font.vmtxsrc/font.ts:318
VORGpublicVORG | nullundefinedVertical Origin Table. Specifies vertical coordinate origins for dynamic metrics scaling.Font.VORG Font.VORGsrc/font.ts:199
objTypereadonlystring'TTF'Identifier for TrueType fonts. Always 'TTF'.-src/true-type-font.ts:127

Accessors ​

ascent ​

Get Signature ​

get ascent(): number | undefined

Defined in: src/true-type-font.ts:407

The font’s ascender.

Returns ​

number | undefined

Implementation of ​

Font.ascent

Inherited from ​

Font.ascent


availableFeatures ​

Get Signature ​

get availableFeatures(): keyof Features[]

Defined in: src/true-type-font.ts:645

An array of all OpenType feature tags supported by the font.

Returns ​

keyof Features[]

Implementation of ​

Font.availableFeatures

Inherited from ​

Font.availableFeatures


bbox ​

Get Signature ​

get bbox(): Readonly<BoundingBox> | undefined

Defined in: src/true-type-font.ts:514

Deprecated ​

Use boundingBox instead!

Returns ​

Readonly<BoundingBox> | undefined

Implementation of ​

Font.bbox

Inherited from ​

Font.bbox


boundingBox ​

Get Signature ​

get boundingBox(): Readonly<BoundingBox> | undefined

Defined in: src/true-type-font.ts:497

The font’s bounding box, i.e. the box that encloses all glyphs in the font.

Returns ​

Readonly<BoundingBox> | undefined

Implementation of ​

Font.boundingBox

Inherited from ​

Font.boundingBox


capHeight ​

Get Signature ​

get capHeight(): number | undefined

Defined in: src/true-type-font.ts:455

The height of capital letters above the baseline. See here for more details.

Returns ​

number | undefined

Implementation of ​

Font.capHeight

Inherited from ​

Font.capHeight


cff ​

Get Signature ​

get cff(): CFF1Font | null

Defined in: src/true-type-font.ts:271

PostScript Compact Font Format (CFF) Outline Table version 1.

Returns ​

CFF1Font | null

PostScript Compact Font Format (CFF) Outline Table version 1.

Implementation of ​

Font.cff

Inherited from ​

Font.cff


characterSet ​

Get Signature ​

get characterSet(): number[]

Defined in: src/true-type-font.ts:530

An array of all of the unicode code points supported by the font.

Returns ​

number[]

An array of all of the unicode code points supported by the font.

Implementation of ​

Font.characterSet

Inherited from ​

Font.characterSet


Get Signature ​

get copyright(): string | null

Defined in: src/true-type-font.ts:399

The font's copyright information, or null if not present.

Returns ​

string | null

The font's copyright information, or null if not present.

Implementation of ​

Font.copyright

Inherited from ​

Font.copyright


descent ​

Get Signature ​

get descent(): number | undefined

Defined in: src/true-type-font.ts:415

The font’s descender.

Returns ​

number | undefined

Implementation of ​

Font.descent

Inherited from ​

Font.descent


familyName ​

Get Signature ​

get familyName(): string | null

Defined in: src/true-type-font.ts:391

The font's family name, e.g. "Helvetica", or null if not present.

Returns ​

string | null

The font's family name, e.g. "Helvetica", or null if not present.

Implementation of ​

Font.familyName

Inherited from ​

Font.familyName


fullName ​

Get Signature ​

get fullName(): string | null

Defined in: src/true-type-font.ts:387

The font's full name, e.g. "Helvetica Bold", or null if not present.

Returns ​

string | null

The font's full name, e.g. "Helvetica Bold", or null if not present.

Implementation of ​

Font.fullName

Inherited from ​

Font.fullName


italicAngle ​

Get Signature ​

get italicAngle(): number | undefined

Defined in: src/true-type-font.ts:447

If this is an italic font, the angle the cursor should be drawn at to match the font design.

Returns ​

number | undefined

Implementation of ​

Font.italicAngle

Inherited from ​

Font.italicAngle


layoutEngine ​

Get Signature ​

get layoutEngine(): LayoutEngine

Defined in: src/true-type-font.ts:613

The shaping engine matching text scripts to font tables.

Returns ​

LayoutEngine

The shaping engine matching text scripts to font tables.

Implementation of ​

Font.layoutEngine

Inherited from ​

Font.layoutEngine


lineGap ​

Get Signature ​

get lineGap(): number | undefined

Defined in: src/true-type-font.ts:423

The line gap, i.e. amount of space that should be included between lines.

Returns ​

number | undefined

Implementation of ​

Font.lineGap

Inherited from ​

Font.lineGap


namedVariations ​

Get Signature ​

get namedVariations(): NamedVariations

Defined in: src/true-type-font.ts:774

Returns ​

NamedVariations


numGlyphs ​

Get Signature ​

get numGlyphs(): number | undefined

Defined in: src/true-type-font.ts:481

The total count of glyph indexes present in the font mapping.

Returns ​

number | undefined

Implementation of ​

Font.numGlyphs

Inherited from ​

Font.numGlyphs


postscriptName ​

Get Signature ​

get postscriptName(): string | Uint8Array<ArrayBufferLike> | null

Defined in: src/true-type-font.ts:352

The unique PostScript name for this font or null if not present.

Some broken fonts have PostScript names that cannot be decoded into a string. They are exposed as Uint8Array.

Returns ​

string | Uint8Array<ArrayBufferLike> | null

The unique PostScript name for this font or null if not present.

Some broken fonts have PostScript names that cannot be decoded into a string. They are exposed as Uint8Array.

Implementation of ​

Font.postscriptName

Inherited from ​

Font.postscriptName


subfamilyName ​

Get Signature ​

get subfamilyName(): string | null

Defined in: src/true-type-font.ts:395

The font's sub-family, e.g. "Bold", or null if not present.

Returns ​

string | null

The font's sub-family, e.g. "Bold", or null if not present.

Implementation of ​

Font.subfamilyName

Inherited from ​

Font.subfamilyName


underlinePosition ​

Get Signature ​

get underlinePosition(): number | undefined

Defined in: src/true-type-font.ts:431

The offset from the normal underline position that should be used.

Returns ​

number | undefined

Implementation of ​

Font.underlinePosition

Inherited from ​

Font.underlinePosition


underlineThickness ​

Get Signature ​

get underlineThickness(): number | undefined

Defined in: src/true-type-font.ts:439

The weight of the underline that should be used.

Returns ​

number | undefined

Implementation of ​

Font.underlineThickness

Inherited from ​

Font.underlineThickness


unitsPerEm ​

Get Signature ​

get unitsPerEm(): number

Defined in: src/true-type-font.ts:489

The size of the font's internal coordinate grid in units per em. Defaults to 1000, if all other attempts to calculate the value fail.

Returns ​

number

Implementation of ​

Font.unitsPerEm

Inherited from ​

Font.unitsPerEm


variationAxes ​

Get Signature ​

get variationAxes(): VariationAxes

Defined in: src/true-type-font.ts:747

Returns ​

VariationAxes


variationProcessor ​

Get Signature ​

get variationProcessor(): GlyphVariationProcessor | null

Defined in: src/true-type-font.ts:852

The processor responsible for calculating delta adjustments to glyph outlines along design variation axes. This is initialised when variation coordinates are applied, and is null for static fonts.

Returns ​

GlyphVariationProcessor | null

The processor responsible for calculating delta adjustments to glyph outlines along design variation axes. This is initialised when variation coordinates are applied, and is null for static fonts.

Implementation of ​

Font.variationProcessor

Inherited from ​

Font.variationProcessor


version ​

Get Signature ​

get version(): string | null

Defined in: src/true-type-font.ts:403

The font's version number or null if not present.

Returns ​

string | null

The font's version number or null if not present.

Implementation of ​

Font.version

Inherited from ​

Font.version


xHeight ​

Get Signature ​

get xHeight(): number

Defined in: src/true-type-font.ts:468

The height of lowercase letters in the font. See here for more details.

Returns ​

number

Implementation of ​

Font.xHeight

Inherited from ​

Font.xHeight

Methods ​

asAATFont() ​

asAATFont(): AATFont | null

Defined in: src/true-type-font.ts:914

Attempts to view this font as an AATFont.

Returns ​

AATFont | null

the font with narrowed to an @{link AATFont} or `null if a required table is missing

Inherited from ​

Font.asAATFont


asOpenTypeFont() ​

asOpenTypeFont(): OpenTypeFont | null

Defined in: src/true-type-font.ts:890

Attempts to view this font instance as a strict OpenType font layout. Returns null, if a structurally required table is missing.

See OpenTypeFont for usage instructions!

Returns ​

OpenTypeFont | null

the font with narrowed to an @{link OpenTypeFont} or `null if a required table is missing

Inherited from ​

Font.asOpenTypeFont


asTrueTypeSubsetFont() ​

asTrueTypeSubsetFont(): TrueTypeSubsetFont | null

Defined in: src/true-type-font.ts:926

Attempts to view this font as an TrueTypeSubsetFont font.

Returns ​

TrueTypeSubsetFont | null

the font with narrowed to a @{link TrueTypeSubsetFont} or `null if a required table is missing

Inherited from ​

Font.asTrueTypeSubsetFont


codePointsForGlyph() ​

codePointsForGlyph(gid): number[]

Defined in: src/true-type-font.ts:641

Returns an array of alternative unicode mapping arrays tied to a specific glyph ID.

Parameters ​

ParameterType
gidnumber

Returns ​

number[]

Inherited from ​

Font.codePointsForGlyph


createSubset() ​

createSubset(): Subset

Defined in: src/true-type-font.ts:716

Creates an empty layout subset utilising this font structure as its baseline data map.

Returns ​

Subset

Inherited from ​

Font.createSubset


decodeDirectory() ​

protected decodeDirectory(): TDirectory

Defined in: src/true-type-font.ts:324

Returns ​

TDirectory


decodeTable() ​

protected decodeTable<K>(table): ReturnType<object[K]["decode"]> | null

Defined in: src/true-type-font.ts:330

Type Parameters ​

Type Parameter
K extends "name" | "head" | "kern" | "opbd" | "loca" | "hmtx" | "cmap" | "hhea" | "maxp" | "OS/2" | "post" | "fpgm" | "prep" | "cvt " | "glyf" | "CFF " | "CFF2" | "VORG" | "EBLC" | "CBLC" | "sbix" | "COLR" | "CPAL" | "BASE" | "GDEF" | "GPOS" | "GSUB" | "JSTF" | "HVAR" | "DSIG" | "gasp" | "hdmx" | "LTSH" | "PCLT" | "VDMX" | "vhea" | "vmtx" | "avar" | "bsln" | "feat" | "fvar" | "gvar" | "just" | "morx"

Parameters ​

ParameterType
tableSFNTDirectoryEntry

Returns ​

ReturnType<object[K]["decode"]> | null


getAvailableFeatures() ​

getAvailableFeatures(script, language?): keyof Features[]

Defined in: src/true-type-font.ts:649

An array of all OpenType feature tags supported by the font for a given script and language.

Parameters ​

ParameterType
script"Caucasian_Albanian" | "Arabic" | "Imperial_Aramaic" | "Armenian" | "Avestan" | "Balinese" | "Bamum" | "Bassa_Vah" | "Batak" | "Bengali" | "Bopomofo" | "Brahmi" | "Braille" | "Buginese" | "Buhid" | "Chakma" | "Canadian_Aboriginal" | "Carian" | "Cham" | "Cherokee" | "Coptic" | "Cypriot" | "Cyrillic" | "Devanagari" | "Deseret" | "Duployan" | "Egyptian_Hieroglyphs" | "Elbasan" | "Ethiopic" | "Georgian" | "Glagolitic" | "Gothic" | "Grantha" | "Greek" | "Gujarati" | "Gurmukhi" | "Hangul" | "Han" | "Hanunoo" | "Hebrew" | "Hiragana" | "Pahawh_Hmong" | "Katakana_Or_Hiragana" | "Old_Italic" | "Javanese" | "Kayah_Li" | "Katakana" | "Kharoshthi" | "Khmer" | "Khojki" | "Kannada" | "Kaithi" | "Tai_Tham" | "Lao" | "Latin" | "Lepcha" | "Limbu" | "Linear_A" | "Linear_B" | "Lisu" | "Lycian" | "Lydian" | "Mahajani" | "Mandaic" | "Manichaean" | "Mende_Kikakui" | "Meroitic_Cursive" | "Meroitic_Hieroglyphs" | "Malayalam" | "Modi" | "Mongolian" | "Mro" | "Meetei_Mayek" | "Myanmar" | "Old_North_Arabian" | "Nabataean" | "Nko" | "Ogham" | "Ol_Chiki" | "Old_Turkic" | "Oriya" | "Osmanya" | "Palmyrene" | "Pau_Cin_Hau" | "Old_Permic" | "Phags_Pa" | "Inscriptional_Pahlavi" | "Psalter_Pahlavi" | "Phoenician" | "Miao" | "Inscriptional_Parthian" | "Rejang" | "Runic" | "Samaritan" | "Old_South_Arabian" | "Saurashtra" | "Shavian" | "Sharada" | "Siddham" | "Khudawadi" | "Sinhala" | "Sora_Sompeng" | "Sundanese" | "Syloti_Nagri" | "Syriac" | "Tagbanwa" | "Takri" | "Tai_Le" | "New_Tai_Lue" | "Tamil" | "Tai_Viet" | "Telugu" | "Tifinagh" | "Tagalog" | "Thaana" | "Thai" | "Tibetan" | "Tirhuta" | "Ugaritic" | "Vai" | "Warang_Citi" | "Old_Persian" | "Cuneiform" | "Yi" | "Inherited" | "Common" | "Unknown"
language?string

Returns ​

keyof Features[]

Inherited from ​

Font.getAvailableFeatures


getFont() ​

getFont(name): TrueTypeFont

Defined in: src/true-type-font.ts:860

Parameters ​

ParameterType
namestring

Returns ​

TrueTypeFont


getGlyfTableStream() ​

getGlyfTableStream(): DecodeStream | null

Defined in: src/true-type-font.ts:320

Extracts a raw readable segment slice targeting vector outline definitions.

Returns ​

DecodeStream | null

Inherited from ​

Font.getGlyfTableStream


getGlyph() ​

getGlyph(glyph, characters?): Glyph | null

Defined in: src/true-type-font.ts:680

Returns a glyph object for the given glyph id. You can pass the array of code points this glyph represents for your use later, and it will be stored in the glyph object.

Parameters ​

ParameterTypeDefault valueDescription
glyphnumberundefinedthe glyph id
charactersreadonly number[][]an array of code points this glyph represents

Returns ​

Glyph | null

the corresponding glyph

Inherited from ​

Font.getGlyph


getName() ​

protected getName(key, lang?): string | null

Defined in: src/true-type-font.ts:360

Parameters ​

ParameterType
keykeyof ProcessedRecords
langstring

Returns ​

string | null


getTable() ​

protected getTable<K>(table): SFNTTableMap[K] | null

Defined in: src/true-type-font.ts:275

Type Parameters ​

Type Parameter
K extends "name" | "head" | "kern" | "opbd" | "loca" | "hmtx" | "cmap" | "hhea" | "maxp" | "OS/2" | "post" | "fpgm" | "prep" | "cvt " | "glyf" | "CFF " | "CFF2" | "VORG" | "EBLC" | "CBLC" | "sbix" | "COLR" | "CPAL" | "BASE" | "GDEF" | "GPOS" | "GSUB" | "JSTF" | "HVAR" | "DSIG" | "gasp" | "hdmx" | "LTSH" | "PCLT" | "VDMX" | "vhea" | "vmtx" | "avar" | "bsln" | "feat" | "fvar" | "gvar" | "just" | "morx"

Parameters ​

ParameterType
tableSFNTDirectoryEntry

Returns ​

SFNTTableMap[K] | null


getTableStream() ​

protected getTableStream(tag): DecodeStream | null

Defined in: src/true-type-font.ts:310

Parameters ​

ParameterType
tagstring

Returns ​

DecodeStream | null


getVariation() ​

getVariation(settings): TrueTypeFont

Defined in: src/true-type-font.ts:782

Parameters ​

ParameterType
settingsstring | VariationCoordinates

Returns ​

TrueTypeFont


glyphForCodePoint() ​

glyphForCodePoint(codePoint): Glyph | null

Defined in: src/true-type-font.ts:543

Maps a single unicode code point to a Glyph object. Does not perform any advanced substitutions.

Parameters ​

ParameterTypeDescription
codePointnumberthe unicode code point

Returns ​

Glyph | null

the corresponding glyph

Inherited from ​

Font.glyphForCodePoint


glyphsForString() ​

glyphsForString(str): Glyph[]

Defined in: src/true-type-font.ts:551

Returns an array of Glyph objects for the given string. This is only a static one-to-one mapping from characters to glyphs.

Parameters ​

ParameterTypeDescription
strstringthe string to encode

Returns ​

Glyph[]

the corresponding glyphs

Inherited from ​

Font.glyphsForString


hasGlyphForCodePoint() ​

hasGlyphForCodePoint(codePoint): boolean

Defined in: src/true-type-font.ts:539

Returns whether there is a glyph in the font for the given unicode code point.

Parameters ​

ParameterTypeDescription
codePointnumberthe unicode code point

Returns ​

boolean

true if a glyph is available for the code point, false otherwise

Inherited from ​

Font.hasGlyphForCodePoint


hasTable() ​

hasTable<K>(tag, decode?): boolean

Defined in: src/true-type-font.ts:864

Tests whether a certain table is present in the font file.

Type Parameters ​

Type ParameterDefault type
K extends stringstring

Parameters ​

ParameterTypeDescription
tag"name" | "head" | "kern" | "opbd" | "loca" | "hmtx" | "cmap" | "hhea" | "maxp" | "OS/2" | "post" | "fpgm" | "prep" | "cvt " | "glyf" | "CFF " | "CFF2" | "VORG" | "EBLC" | "CBLC" | "sbix" | "COLR" | "CPAL" | "BASE" | "GDEF" | "GPOS" | "GSUB" | "JSTF" | "HVAR" | "DSIG" | "gasp" | "hdmx" | "LTSH" | "PCLT" | "VDMX" | "vhea" | "vmtx" | "avar" | "bsln" | "feat" | "fvar" | "gvar" | "just" | "morx" | Kthe table name like cmap, OS/2, or hmtx
decode?boolean-

Returns ​

boolean

Inherited from ​

Font.hasTable


layout() ​

layout(str, userFeatures?, script?, language?, direction?): GlyphRun

Defined in: src/true-type-font.ts:621

Returns a GlyphRun object, which includes an array of Glyphs and GlyphPositions for the given string.

Parameters ​

ParameterTypeDescription
strstringthe string to encode
userFeatures?Features | keyof Features[]an array of OpenType feature tags to be applied in addition to the default set.
script?OpenTypeTagthe script of the string
language?stringthe language of the string
direction?BidiDirectionthe writing direction for the string

Returns ​

GlyphRun

the rendered string as a GlyphRun

Inherited from ​

Font.layout


safeGetGlyph() ​

safeGetGlyph(glyph, characters?): Glyph

Defined in: src/true-type-font.ts:699

Like getGlyph but falls back to the fallback glyph .notdef if the glyph cannot be resolved, because of missing tables.

Parameters ​

ParameterTypeDefault valueDescription
glyphnumberundefinedthe glyph id
charactersreadonly number[][]an optional sequence of codepoints

Returns ​

Glyph

Inherited from ​

Font.safeGetGlyph


setDefaultLanguage() ​

setDefaultLanguage(lang?): void

Defined in: src/true-type-font.ts:356

Set the default language.

Parameters ​

ParameterTypeDefault value
langstring | nullnull

Returns ​

void

See ​

defaultLanguage

Inherited from ​

Font.setDefaultLanguage


stringsForGlyph() ​

stringsForGlyph(gid): string[]

Defined in: src/true-type-font.ts:637

Returns an array of strings that map to the given glyph id.

Parameters ​

ParameterTypeDescription
gidnumberthe glyph id

Returns ​

string[]

Inherited from ​

Font.stringsForGlyph