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

GlyphtContext

Context object for all font processing. This is what you use to load fonts.

All subsetting is done off-thread using a worker. If running in an environment where your program is meant to exit by itself (e.g. on the command line), you must call GlyphtContext#destroy after subsetting your fonts to close the worker thread and allow the program to exit.

  • Defined in context.ts:20
Index

Constructors

constructor

Methods

loadFonts destroy

Constructors

constructor

  • new GlyphtContext(): GlyphtContext

    Returns GlyphtContext

    • Defined in context.ts:25

Methods

loadFonts

  • loadFonts(
        fontFiles: Uint8Array<ArrayBufferLike>[],
        options?: LoadFontsOptions,
    ): Promise<FontRef[]>

    Load a set of fonts. This will return a list of FontRefs that can be subset.

    There is no equivalent method for loading a single font, because a single font file could be a collection of multiple fonts and hence have to return an array anyway.

    Parameters

    • fontFiles: Uint8Array<ArrayBufferLike>[]

      Font files to load.

    • Optionaloptions: LoadFontsOptions

      Options object.

    Returns Promise<FontRef[]>

    A list of loaded fonts.

    • Defined in context.ts:52

destroy

  • destroy(): void

    Destroy this context, meaning any previously-loaded FontRefs can no longer be subset. All promises previously returned from FontRef#subset will resolve, but any further calls will error out.

    If running in Node, Bun, Deno, or another such runtime, this will allow the program to exit once all font processing work is finished.

    Returns void

    • Defined in context.ts:121