FontRef
type FontRef = {
id: number;
uid: string;
faceCount: number;
faceIndex: number;
familyName: string;
subfamilyName: string;
styleValues: StyleValues;
styleAttributes: StyleAttributes | null;
fileSize: number;
axes: AxisInfo[];
features: FeatureInfo[];
namedInstances: NamedInstance[];
subsetCoverage: SubsetInfo[];
unicodeRanges: (number | readonly [number, number])[];
destroy(): Promise<void>;
subset(settings: SubsetSettings | null): Promise<SubsettedFont>;
getFontFileData(): Promise<Uint8Array<ArrayBuffer>>;
getFontFileHash(): Promise<string>;
}
Properties
id
Identifier for a specific font face. Unique per GlyphtContext.
uid
The OpenType unique font ID (name ID 3), or a hash of the font if it is absent.
faceCount
Number of faces in the file that this font face comes from (will be more than 1 if you load a .ttc or .otc).
faceIndex
Index of this face in the file that this font face comes from.
familyName
This font's family name, not including any weight, width, or style modifiers (e.g. "Inter Display").
subfamilyName
This font's subfamily name (e.g. "Light Italic").
styleValues
This font's style values (weight, width, italic, slant). These may be static or variable.
styleAttributes
Values from the font's STAT table, if present.
fileSize
The size of the file this font comes from. If this font comes from a collection file, this will be the size of the entire collection.
axes
Variable font axes. Does not include variable axes listed in FontRef#styleValues.
features
List of all font features.
namedInstances
List of all named font instances.
subsetCoverage
Unicode subsets for which this font has some coverage. It does not need to cover the entire subset, just a small portion.
unicodeRanges
All the Unicode code points contained in the font.
Methods
destroy
destroy(): Promise<void>
Unload this font, freeing any memory used for it.
While this object does have a finalizer that may eventually run, it is recommended to explicitly unload fonts when you're done with them.
This method returns a
Promisethat resolves once the font is definitely unloaded. You probably don't need to await it.Returns
Promise<void>
subset
subset(settings: SubsetSettings | null): Promise<SubsettedFont>
Subset this font according to the provided settings. If null, the font's data will be returned as-is (but if the font is part of a collection, only that particular font's data will be included).
Parameters
settings: SubsetSettings | null
Returns
Promise<SubsettedFont>
getFontFileData
getFontFileData(): Promise<Uint8Array<ArrayBuffer>>
Returns the original font file data behind this font. Unlike subset with
nullsettings, this will not extract single font faces from collections.Returns
Promise<Uint8Array<ArrayBuffer>>
getFontFileHash
getFontFileHash(): Promise<string>
Returns a hash (as a hex string) of the original font file data behind this font (if this font is part of a collection, the hash will be the same for all the fonts in that collection). This can be helpful for e.g. persisting fonts in a webapp.
Returns
Promise<string>
A font loaded by Glypht.