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

WoffCompressionContext

Context object for font compression and decompression. All operations are done off-thread using a worker pool. If running in an environment where your program is meant to exit by itself (e.g. on the command line), you must call WoffCompressionContext#destroy to close the worker threads and allow the program to exit.

  • Defined in compression.ts:37
Index

Constructors

constructor

Methods

getParallelism compressFromTTF decompressToTTF destroy compressionType

Constructors

constructor

  • new WoffCompressionContext(parallelism?: number): WoffCompressionContext

    Create a new compression/decompression context.

    Parameters

    • Optionalparallelism: number

      The number of worker threads to create. If not given, this will default to the number of cores on the system or navigator.hardwareConcurrency.

    Returns WoffCompressionContext

    • Defined in compression.ts:47

Methods

getParallelism

  • getParallelism(): Promise<number>

    Returns Promise<number>

    The resolved number of worker threads, e.g. for ETA or progress estimation.

    • Defined in compression.ts:75

compressFromTTF

  • compressFromTTF(
        ttf: Uint8Array,
        options: CompressOptions,
    ): Promise<Uint8Array<ArrayBuffer>>

    Compress an OpenType font file to WOFF or WOFF2.

    Parameters

    • ttf: Uint8Array

      The font file to compress. This must be a single font, not a collection.

    • options: CompressOptions

      Options object.

    Returns Promise<Uint8Array<ArrayBuffer>>

    Compressed font data.

    • Defined in compression.ts:91

decompressToTTF

  • decompressToTTF(
        compressed: Uint8Array,
        options?: DecompressOptions,
    ): Promise<Uint8Array<ArrayBuffer>>

    Decompress a WOFF or WOFF2-compressed font file. Throws an error if the input font is not compressed.

    Parameters

    • compressed: Uint8Array

      The compressed font file data.

    • Optionaloptions: DecompressOptions

      Options object.

    Returns Promise<Uint8Array<ArrayBuffer>>

    Decompressed font file data.

    • Defined in compression.ts:114

destroy

  • destroy(): void

    Destroy this context. All previous calls to this context's compression and decompression methods 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 compression.ts:169

StaticcompressionType

  • compressionType(fontData: Uint8Array): null | "woff" | "woff2"

    Return the compression type for a given font file.

    Parameters

    • fontData: Uint8Array

      The font file to check.

    Returns null | "woff" | "woff2"

    'woff' if the file is compressed with WOFF1, 'woff2' if it's compressed with WOFF2, or null if it's not compressed.

    • Defined in compression.ts:140