fontjs
Version:
FontJS (Font.js) is a packages for TrueType font parsing and manipulation
223 lines (222 loc) • 5.77 kB
TypeScript
import { SeqStream } from "bytestreamjs";
import { FontTable } from "../Table";
export declare enum HEADFontDirectionHint {
/**
* Fully mixed directional glyphs
*/
fullyMixed = 0,
/**
* Only strongly left to right
*/
leftToRight = 1,
/**
* Like 1 but also contains neutrals
*/
leftToRightNeutrals = 2,
/**
* Only strongly right to left
*/
rightToLeft = -1,
/**
* Like -1 but also contains neutrals
*/
rightToLeftNeutrals = -2
}
export declare enum HEADMacStyleFlags {
bold = 1,
italic = 2,
underline = 4,
outline = 8,
shadow = 16,
condensed = 32,
extended = 64
}
export declare enum HEADFlags {
/**
* Baseline for font at y=0.
*/
bit0 = 1,
/**
* Left sidebearing point at x=0 (relevant only for TrueType rasterizers) — see the note below regarding variable fonts.
*/
bit1 = 2,
/**
* Instructions may depend on point size.
*/
bit2 = 4,
/**
* Force ppem to integer values for all internal scaler math; may use fractional ppem sizes if this bit is clear. It is strongly recommended that this be set in hinted fonts.
*/
bit3 = 8,
/**
* Instructions may alter advance width (the advance widths might not scale linearly).
*/
bit4 = 16,
/**
* This bit is not used in OpenType, and should not be set in order to ensure compatible behavior on all platforms. If set, it may result in different behavior for vertical layout in some platforms. (See Apple’s specification for details regarding behavior in Apple platforms.)
*/
bit5 = 32,
/**
* These bits are not used in Opentype and should always be cleared. (See Apple’s specification for details regarding legacy used in Apple platforms.)
*/
/**
* Font data is “lossless” as a result of having been subjected to optimizing transformation and/or compression (such as e.g. compression mechanisms defined by ISO/IEC 14496-18, MicroType Express, WOFF 2.0 or similar) where the original font functionality and features are retained but the binary compatibility between input and output font files is not guaranteed. As a result of the applied transform, the DSIG table may also be invalidated.
*/
bit11 = 2048,
/**
* Font converted (produce compatible metrics).
*/
bit12 = 4096,
/**
* Font optimized for ClearType™. Note, fonts that rely on embedded bitmaps (EBDT) for rendering should not be considered optimized for ClearType, and therefore should keep this bit cleared.
*/
bit13 = 8192,
/**
* Last Resort font. If set, indicates that the glyphs encoded in the 'cmap' subtables are simply generic symbolic representations of code point ranges and don’t truly represent support for those code points. If unset, indicates that the glyphs encoded in the 'cmap' subtables represent proper support for those code points.
*/
bit14 = 16384
}
export interface HEADParameters {
/**
* Version number of the font header table
*/
version?: number;
/**
* Set by font manufacturer
*/
fontRevision?: number;
/**
* Computed check sum adjustment
*/
checkSumAdjustment?: number;
/**
* Set to 0x5F0F3CF5
*/
magicNumber?: number;
/**
* Flags
*/
flags?: HEADFlags;
/**
* Set to a value from 16 to 16384
*/
unitsPerEm?: number;
/**
* Created time
*/
created?: Date;
/**
* Modified time
*/
modified?: Date;
/**
* For all glyph bounding boxes
*/
xMin?: number;
/**
* For all glyph bounding boxes
*/
yMin?: number;
/**
* For all glyph bounding boxes
*/
xMax?: number;
/**
* For all glyph bounding boxes
*/
yMax?: number;
/**
* mac style
*/
macStyle?: HEADMacStyleFlags;
/**
* Smallest readable size in pixels
*/
lowestRecPPEM?: number;
/**
* Font description hint
*/
fontDirectionHint?: HEADFontDirectionHint;
/**
* 0 for short offsets (Offset16), 1 for long (Offset32)
*/
indexToLocFormat?: number;
/**
* 0 for current format
*/
glyphDataFormat?: number;
}
export declare class HEAD extends FontTable {
/**
* Version number of the font header table
*/
version: number;
/**
* Set by font manufacturer
*/
fontRevision: number;
/**
* Computed check sum adjustment
*/
checkSumAdjustment: number;
/**
* Set to 0x5F0F3CF5
*/
magicNumber: number;
/**
* Flags
*/
flags: HEADFlags;
/**
* Set to a value from 16 to 16384
*/
unitsPerEm: number;
/**
* Created time
*/
created:
/**
* Modified time
*/ Date;
modified:
/**
* For all glyph bounding boxes
*/ Date;
xMin: number;
/**
* For all glyph bounding boxes
*/
yMin: number;
/**
* For all glyph bounding boxes
*/
xMax: number;
/**
* For all glyph bounding boxes
*/
yMax: number;
/**
* mac style
*/
macStyle: HEADMacStyleFlags;
/**
* Smallest readable size in pixels
*/
lowestRecPPEM: number;
/**
* Font description hint
*/
fontDirectionHint: HEADFontDirectionHint;
/**
* 0 for short offsets (Offset16), 1 for long (Offset32)
*/
indexToLocFormat: number;
/**
* 0 for current format
*/
glyphDataFormat: number;
constructor(parameters?: HEADParameters);
static get tag(): number;
toStream(stream: SeqStream): boolean;
static fromStream(stream: SeqStream): HEAD;
}