Glypht
  • Documentation
  • Discussions
  • GitHub
Navigation
  • Documentation
    • @glypht/bundler-utils
      • NodeType
      • CSSSpan
      • CSSOutput
      • FeatureMetadata
      • FamilyInfo
      • SubsetAxisSetting
      • ExportedFont
      • CharacterSetSettings
      • FamilySubsetSettings
      • FamilySettings
      • ExportFontsSettings
      • featureMetadata
      • sortFontsIntoFamilies
      • exportedFontsToCSS
      • exportFonts
      • parseUnicodeRanges
      • parseRanges
      • formatUnicodeRanges
    • @glypht/cli
      • GlyphtConfig
      • build
    • @glypht/core
      • AxisValueFormat
      • AxisValueFlags
      • WoffCompressionContext
      • GlyphtContext
      • CompressOptions
      • DecompressOptions
      • LoadFontsOptions
      • AxisInfo
      • SubsetAxisInfo
      • StyleValue
      • FeatureInfo
      • NamedInstance
      • StyleKey
      • StyleValues
      • SfntVersion
      • DesignAxisRecord
      • AxisValueSingle
      • AxisValueRange
      • AxisValueLinked
      • AxisValueMultiple
      • AxisValue
      • StyleAttributes
      • SubsettedFont
      • SubsetInfo
      • SubsetAxisSetting
      • SubsetSettings
      • FontRef
      • SubsetName
      • SUBSET_NAMES
    • Comparison with other tools
    • Web app

FontRef

A font loaded by Glypht.

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>;
}
  • Defined in font-types.ts:342
Index

Properties

id uid faceCount faceIndex familyName subfamilyName styleValues styleAttributes fileSize axes features namedInstances subsetCoverage unicodeRanges

Methods

destroy subset getFontFileData getFontFileHash

Properties

id

id: number

Identifier for a specific font face. Unique per GlyphtContext.

  • Defined in font-types.ts:344

uid

uid: string

The OpenType unique font ID (name ID 3), or a hash of the font if it is absent.

  • Defined in font-types.ts:346

faceCount

faceCount: number

Number of faces in the file that this font face comes from (will be more than 1 if you load a .ttc or .otc).

  • Defined in font-types.ts:348

faceIndex

faceIndex: number

Index of this face in the file that this font face comes from.

  • Defined in font-types.ts:350

familyName

familyName: string

This font's family name, not including any weight, width, or style modifiers (e.g. "Inter Display").

  • Defined in font-types.ts:352

subfamilyName

subfamilyName: string

This font's subfamily name (e.g. "Light Italic").

  • Defined in font-types.ts:354

styleValues

styleValues: StyleValues

This font's style values (weight, width, italic, slant). These may be static or variable.

  • Defined in font-types.ts:356

styleAttributes

styleAttributes: StyleAttributes | null

Values from the font's STAT table, if present.

  • Defined in font-types.ts:360

fileSize

fileSize: number

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.

  • Defined in font-types.ts:365

axes

axes: AxisInfo[]

Variable font axes. Does not include variable axes listed in FontRef#styleValues.

  • Defined in font-types.ts:367

features

features: FeatureInfo[]

List of all font features.

  • Defined in font-types.ts:369

namedInstances

namedInstances: NamedInstance[]

List of all named font instances.

  • Defined in font-types.ts:371

subsetCoverage

subsetCoverage: SubsetInfo[]

Unicode subsets for which this font has some coverage. It does not need to cover the entire subset, just a small portion.

  • Defined in font-types.ts:376

unicodeRanges

unicodeRanges: (number | readonly [number, number])[]

All the Unicode code points contained in the font.

  • Defined in font-types.ts:380

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 Promise that resolves once the font is definitely unloaded. You probably don't need to await it.

    Returns Promise<void>

    • Defined in font-types.ts:390

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>

    • Defined in font-types.ts:395

getFontFileData

  • getFontFileData(): Promise<Uint8Array<ArrayBuffer>>

    Returns the original font file data behind this font. Unlike subset with null settings, this will not extract single font faces from collections.

    Returns Promise<Uint8Array<ArrayBuffer>>

    • Defined in font-types.ts:400

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>

    • Defined in font-types.ts:406