text-shaper 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +413 -38
  2. package/dist/aat/state-machine.d.ts +18 -6
  3. package/dist/buffer/glyph-buffer.d.ts +35 -1
  4. package/dist/buffer/unicode-buffer.d.ts +2 -0
  5. package/dist/fluent/bitmap-builder.d.ts +146 -0
  6. package/dist/fluent/index.d.ts +102 -0
  7. package/dist/fluent/path-builder.d.ts +230 -0
  8. package/dist/fluent/pipe.d.ts +200 -0
  9. package/dist/fluent/types.d.ts +93 -0
  10. package/dist/font/brotli/decode.d.ts +42 -0
  11. package/dist/font/face.d.ts +2 -0
  12. package/dist/font/font.d.ts +14 -0
  13. package/dist/font/tables/cff.d.ts +3 -1
  14. package/dist/font/tables/cff2.d.ts +63 -0
  15. package/dist/font/tables/colr.d.ts +4 -1
  16. package/dist/font/tables/fvar.d.ts +3 -1
  17. package/dist/font/tables/glyf.d.ts +13 -0
  18. package/dist/font/tables/gpos.d.ts +24 -1
  19. package/dist/font/tables/gsub.d.ts +20 -0
  20. package/dist/font/tables/gvar.d.ts +10 -1
  21. package/dist/font/tables/head.d.ts +5 -0
  22. package/dist/font/tables/hhea.d.ts +5 -0
  23. package/dist/font/tables/loca.d.ts +3 -0
  24. package/dist/font/tables/maxp.d.ts +5 -0
  25. package/dist/font/tables/name.d.ts +5 -0
  26. package/dist/font/tables/os2.d.ts +5 -0
  27. package/dist/font/tables/post.d.ts +5 -0
  28. package/dist/index.d.ts +5 -3
  29. package/dist/index.js +12 -10
  30. package/dist/index.js.map +105 -99
  31. package/dist/layout/justify.d.ts +15 -2
  32. package/dist/layout/structures/class-def.d.ts +61 -8
  33. package/dist/layout/structures/coverage.d.ts +57 -10
  34. package/dist/layout/structures/device.d.ts +26 -5
  35. package/dist/layout/structures/layout-common.d.ts +18 -3
  36. package/dist/layout/structures/set-digest.d.ts +59 -0
  37. package/dist/raster/asymmetric-stroke.d.ts +9 -5
  38. package/dist/raster/bitmap-utils.d.ts +67 -0
  39. package/dist/raster/blur.d.ts +11 -0
  40. package/dist/raster/cascade-blur.d.ts +9 -10
  41. package/dist/raster/cell.d.ts +24 -0
  42. package/dist/raster/fixed-point.d.ts +1 -1
  43. package/dist/raster/gradient.d.ts +15 -0
  44. package/dist/raster/gray-raster.d.ts +7 -1
  45. package/dist/raster/lcd-filter.d.ts +15 -0
  46. package/dist/raster/msdf.d.ts +27 -5
  47. package/dist/raster/outline-decompose.d.ts +16 -17
  48. package/dist/raster/rasterize.d.ts +19 -2
  49. package/dist/raster/sdf.d.ts +3 -0
  50. package/dist/raster/stroker.d.ts +3 -0
  51. package/dist/raster/types.d.ts +9 -0
  52. package/dist/render/path.d.ts +56 -1
  53. package/dist/shaper/complex/arabic.d.ts +1 -0
  54. package/dist/shaper/shape-plan.d.ts +11 -8
  55. package/dist/shaper/shaper.d.ts +189 -4
  56. package/dist/unicode/bidi/brackets.d.ts +15 -0
  57. package/dist/unicode/bidi/char-types.d.ts +4 -0
  58. package/dist/unicode/bidi/embedding-levels.d.ts +3 -0
  59. package/dist/unicode/bidi/mirroring.d.ts +10 -0
  60. package/dist/unicode/bidi/reordering.d.ts +15 -0
  61. package/dist/unicode/normalize.d.ts +23 -0
  62. package/dist/unicode/script.d.ts +17 -0
  63. package/dist/unicode/segmentation.d.ts +18 -0
  64. package/package.json +11 -2
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Shared types for the fluent API
3
+ */
4
+ import type { FillRule, PixelMode } from "../raster/types.ts";
5
+ import type { Matrix2D, Matrix3x3 } from "../render/outline-transform.ts";
6
+ /**
7
+ * Accumulated transform state for lazy evaluation
8
+ */
9
+ export interface TransformState {
10
+ /** 2D affine transform matrix */
11
+ matrix2D: Matrix2D;
12
+ /** 3D perspective matrix (takes precedence over matrix2D if set) */
13
+ matrix3D: Matrix3x3 | null;
14
+ }
15
+ /**
16
+ * Options for rasterization
17
+ */
18
+ export interface RasterOptions {
19
+ /** Bitmap width in pixels */
20
+ width?: number;
21
+ /** Bitmap height in pixels */
22
+ height?: number;
23
+ /** Scale factor applied during rasterization */
24
+ scale?: number;
25
+ /** X offset for rasterization */
26
+ offsetX?: number;
27
+ /** Y offset for rasterization */
28
+ offsetY?: number;
29
+ /** Padding around the glyph */
30
+ padding?: number;
31
+ /** Pixel mode (Gray, Mono, LCD, etc.) */
32
+ pixelMode?: PixelMode;
33
+ /** Fill rule for path filling */
34
+ fillRule?: FillRule;
35
+ /** Flip Y axis (default true for screen coordinates) */
36
+ flipY?: boolean;
37
+ }
38
+ /**
39
+ * Options for auto-sized rasterization
40
+ */
41
+ export interface AutoRasterOptions {
42
+ /** Padding around the glyph (default: 1) */
43
+ padding?: number;
44
+ /** Scale factor (default: 1) */
45
+ scale?: number;
46
+ /** Pixel mode (default: Gray) */
47
+ pixelMode?: PixelMode;
48
+ /** Fill rule (default: NonZero) */
49
+ fillRule?: FillRule;
50
+ /** Flip Y axis (default: true) */
51
+ flipY?: boolean;
52
+ }
53
+ /**
54
+ * Options for SVG output
55
+ */
56
+ export interface SVGOptions {
57
+ /** Flip Y axis (default: true) */
58
+ flipY?: boolean;
59
+ /** Scale factor */
60
+ scale?: number;
61
+ }
62
+ /**
63
+ * Options for SVG element output
64
+ */
65
+ export interface SVGElementOptions {
66
+ /** Font size for scaling */
67
+ fontSize?: number;
68
+ /** Fill color */
69
+ fill?: string;
70
+ /** Stroke color */
71
+ stroke?: string;
72
+ /** Stroke width */
73
+ strokeWidth?: number;
74
+ }
75
+ /**
76
+ * Options for canvas rendering
77
+ */
78
+ export interface CanvasOptions {
79
+ /** Flip Y axis (default: true) */
80
+ flipY?: boolean;
81
+ /** Scale factor */
82
+ scale?: number;
83
+ /** X offset */
84
+ offsetX?: number;
85
+ /** Y offset */
86
+ offsetY?: number;
87
+ /** Fill color (set to "none" to skip fill) */
88
+ fill?: string;
89
+ /** Stroke color */
90
+ stroke?: string;
91
+ /** Stroke width */
92
+ strokeWidth?: number;
93
+ }
@@ -3,7 +3,49 @@
3
3
  * Based on the brotli.js reference implementation (MIT License)
4
4
  * https://github.com/devongovett/brotli.js
5
5
  */
6
+ interface HuffmanCode {
7
+ bits: number;
8
+ value: number;
9
+ }
10
+ declare class BitReader {
11
+ private data;
12
+ private buf;
13
+ private pos;
14
+ private val;
15
+ private bitPos;
16
+ private bitEndPos;
17
+ private eos;
18
+ constructor(data: Uint8Array);
19
+ private fillBuffer;
20
+ readMoreInput(): void;
21
+ fillBitWindow(): void;
22
+ readBits(n: number): number;
23
+ get currentBitPos(): number;
24
+ set currentBitPos(v: number);
25
+ get currentVal(): number;
26
+ }
27
+ declare function buildHuffmanTable(rootTable: HuffmanCode[], tableOffset: number, rootBits: number, codeLengths: Uint8Array, codeLengthsSize: number): number;
28
+ declare function getNextKey(key: number, len: number): number;
29
+ declare function replicateValue(table: HuffmanCode[], offset: number, step: number, end: number, code: HuffmanCode): void;
30
+ declare function nextTableBitSize(count: Int32Array, len: number, rootBits: number): number;
31
+ declare function readHuffmanCodeLengths(codeLengthCodeLengths: Uint8Array, numSymbols: number, codeLengths: Uint8Array, br: BitReader): void;
32
+ declare function readBlockLength(table: HuffmanCode[], tableOffset: number, br: BitReader): number;
6
33
  /**
7
34
  * Decompress Brotli-compressed data
8
35
  */
9
36
  export declare function decompress(data: Uint8Array): Uint8Array;
37
+ export declare const __testing: {
38
+ getNextKey: typeof getNextKey;
39
+ replicateValue: typeof replicateValue;
40
+ nextTableBitSize: typeof nextTableBitSize;
41
+ buildHuffmanTable: typeof buildHuffmanTable;
42
+ readBlockLength: typeof readBlockLength;
43
+ readHuffmanCodeLengths: typeof readHuffmanCodeLengths;
44
+ BitReader: typeof BitReader;
45
+ HuffmanCode: {
46
+ bits: number;
47
+ value: number;
48
+ };
49
+ CODE_LENGTH_CODES: number;
50
+ };
51
+ export {};
@@ -11,6 +11,8 @@ export declare class Face {
11
11
  private _coords;
12
12
  /** User-space axis values */
13
13
  private _variations;
14
+ /** Cached advance width deltas for variable fonts (glyphId -> delta) */
15
+ private _advanceDeltas;
14
16
  constructor(font: Font, variations?: Record<string, number> | Variation[]);
15
17
  /**
16
18
  * Set variation axis values
@@ -198,6 +198,20 @@ export declare class Font {
198
198
  xMax: number;
199
199
  yMax: number;
200
200
  } | null;
201
+ /**
202
+ * Get contours and bounds for a glyph in a single operation.
203
+ * More efficient than calling getGlyphContours + getGlyphBounds separately
204
+ * as it only parses the glyph once.
205
+ */
206
+ getGlyphContoursAndBounds(glyphId: GlyphId): {
207
+ contours: Contour[];
208
+ bounds: {
209
+ xMin: number;
210
+ yMin: number;
211
+ xMax: number;
212
+ yMax: number;
213
+ } | null;
214
+ } | null;
201
215
  /** Get contours for a glyph with variation applied */
202
216
  getGlyphContoursWithVariation(glyphId: GlyphId, axisCoords: number[]): Contour[] | null;
203
217
  }
@@ -88,7 +88,9 @@ export interface FDSelect {
88
88
  select: (glyphId: number) => number;
89
89
  }
90
90
  /**
91
- * Parse CFF table
91
+ * Parse CFF table - Compact Font Format for PostScript outlines
92
+ * @param reader - Reader positioned at start of CFF table
93
+ * @returns Parsed CFF table with CharStrings, DICTs, and subroutines
92
94
  */
93
95
  export declare function parseCff(reader: Reader): CffTable;
94
96
  /**
@@ -79,7 +79,70 @@ export interface ItemVariationData {
79
79
  * Parse CFF2 table
80
80
  */
81
81
  export declare function parseCff2(reader: Reader): Cff2Table;
82
+ /**
83
+ * Parse CFF2 INDEX structure (uses 32-bit count)
84
+ */
85
+ declare function parseIndex(reader: Reader): Uint8Array[];
86
+ /**
87
+ * Read offset of given size
88
+ */
89
+ declare function readOffset(reader: Reader, offSize: number): number;
90
+ /**
91
+ * Parse a CFF2 DICT structure
92
+ */
93
+ declare function parseDict(reader: Reader): Map<number, number[]>;
94
+ /**
95
+ * Parse real number
96
+ */
97
+ declare function parseReal(reader: Reader): number;
98
+ /**
99
+ * Parse CFF2 Top DICT
100
+ */
101
+ declare function parseCff2TopDict(reader: Reader): Cff2TopDict;
102
+ /**
103
+ * Parse CFF2 FD DICT
104
+ */
105
+ declare function parseCff2FDDict(reader: Reader): Cff2FDDict;
106
+ /**
107
+ * Parse CFF2 Private DICT
108
+ */
109
+ declare function parseCff2PrivateDict(reader: Reader): Cff2PrivateDict;
110
+ /**
111
+ * Convert delta-encoded values to absolute
112
+ */
113
+ declare function deltaToAbsolute(deltas: number[]): number[];
114
+ /**
115
+ * Parse FDSelect structure
116
+ */
117
+ declare function parseFDSelect(reader: Reader, numGlyphs: number): Cff2FDSelect;
118
+ /**
119
+ * Parse ItemVariationStore
120
+ */
121
+ declare function parseItemVariationStore(reader: Reader): ItemVariationStore;
122
+ /**
123
+ * Parse VariationRegionList
124
+ */
125
+ declare function parseVariationRegionList(reader: Reader): VariationRegionList;
126
+ /**
127
+ * Parse ItemVariationData
128
+ */
129
+ declare function parseItemVariationData(reader: Reader): ItemVariationData;
82
130
  /**
83
131
  * Calculate variation delta for given coordinates
84
132
  */
85
133
  export declare function calculateVariationDelta(vstore: ItemVariationStore, outerIndex: number, innerIndex: number, normalizedCoords: number[]): number;
134
+ export declare const __testing: {
135
+ parseIndex: typeof parseIndex;
136
+ readOffset: typeof readOffset;
137
+ parseDict: typeof parseDict;
138
+ parseReal: typeof parseReal;
139
+ parseCff2TopDict: typeof parseCff2TopDict;
140
+ parseCff2FDDict: typeof parseCff2FDDict;
141
+ parseCff2PrivateDict: typeof parseCff2PrivateDict;
142
+ deltaToAbsolute: typeof deltaToAbsolute;
143
+ parseFDSelect: typeof parseFDSelect;
144
+ parseItemVariationStore: typeof parseItemVariationStore;
145
+ parseVariationRegionList: typeof parseVariationRegionList;
146
+ parseItemVariationData: typeof parseItemVariationData;
147
+ };
148
+ export {};
@@ -245,7 +245,10 @@ export interface VarColorStop extends ColorStop {
245
245
  varIndexBase?: number;
246
246
  }
247
247
  /**
248
- * Parse COLR table
248
+ * Parse COLR table - color glyph definitions with layered or gradient fills
249
+ * Supports both v0 (simple layers) and v1 (advanced paint operations)
250
+ * @param reader - Reader positioned at start of COLR table
251
+ * @returns Parsed COLR table with color layer and paint definitions
249
252
  */
250
253
  export declare function parseColr(reader: Reader): ColrTable;
251
254
  /**
@@ -56,7 +56,9 @@ export declare const AxisTags: {
56
56
  readonly opsz: 1869640570;
57
57
  };
58
58
  /**
59
- * Parse fvar table
59
+ * Parse fvar table - font variations defining axes and named instances
60
+ * @param reader - Reader positioned at start of fvar table
61
+ * @returns Parsed fvar table with variation axes and instances
60
62
  */
61
63
  export declare function parseFvar(reader: Reader): FvarTable;
62
64
  /**
@@ -97,6 +97,19 @@ export declare function flattenCompositeGlyph(glyf: GlyfTable, loca: LocaTable,
97
97
  * Get all contours for a glyph, flattening composites
98
98
  */
99
99
  export declare function getGlyphContours(glyf: GlyfTable, loca: LocaTable, glyphId: GlyphId): Contour[];
100
+ /**
101
+ * Get contours and bounds for a glyph in one parse operation.
102
+ * More efficient than calling getGlyphContours + getGlyphBounds separately.
103
+ */
104
+ export declare function getGlyphContoursAndBounds(glyf: GlyfTable, loca: LocaTable, glyphId: GlyphId): {
105
+ contours: Contour[];
106
+ bounds: {
107
+ xMin: number;
108
+ yMin: number;
109
+ xMax: number;
110
+ yMax: number;
111
+ } | null;
112
+ };
100
113
  /**
101
114
  * Get bounding box for a glyph
102
115
  */
@@ -2,7 +2,8 @@ import { type ClassDef } from "../../layout/structures/class-def.ts";
2
2
  import { type Coverage } from "../../layout/structures/coverage.ts";
3
3
  import { type DeviceOrVariationIndex } from "../../layout/structures/device.ts";
4
4
  import { type FeatureList, type ScriptList } from "../../layout/structures/layout-common.ts";
5
- import type { GlyphId, int16, uint16 } from "../../types.ts";
5
+ import { SetDigest } from "../../layout/structures/set-digest.ts";
6
+ import type { GlyphId, GlyphPosition, int16, uint16 } from "../../types.ts";
6
7
  import type { Reader } from "../binary/reader.ts";
7
8
  import { type ChainingContextPosLookup, type ContextPosLookup } from "./gpos-contextual.ts";
8
9
  import { type CursivePosSubtable, type MarkBasePosSubtable, type MarkLigaturePosSubtable, type MarkMarkPosSubtable } from "./gpos-mark.ts";
@@ -45,6 +46,8 @@ export interface GposLookup {
45
46
  type: GposLookupType;
46
47
  flag: uint16;
47
48
  markFilteringSet?: uint16;
49
+ /** Bloom filter for fast O(1) glyph rejection */
50
+ digest: SetDigest;
48
51
  }
49
52
  /** Single adjustment lookup (Type 1) */
50
53
  export interface SinglePosLookup extends GposLookup {
@@ -131,7 +134,27 @@ export interface GposTable {
131
134
  }
132
135
  export type { Anchor, MarkArray } from "./gpos-mark.ts";
133
136
  export declare function parseGpos(reader: Reader): GposTable;
137
+ declare function parseGposLookup(reader: Reader): AnyGposLookup | null;
138
+ declare function parseValueRecord(reader: Reader, valueFormat: uint16, subtableReader?: Reader): ValueRecord;
139
+ declare function parseSinglePos(reader: Reader, subtableOffsets: number[]): SinglePosSubtable[];
140
+ declare function parsePairPos(reader: Reader, subtableOffsets: number[]): PairPosSubtable[];
141
+ declare function parseExtensionLookup(reader: Reader, subtableOffsets: number[], baseProps: {
142
+ flag: uint16;
143
+ markFilteringSet?: uint16;
144
+ }): AnyGposLookup | null;
134
145
  export declare function getKerning(lookup: PairPosLookup, firstGlyph: GlyphId, secondGlyph: GlyphId): {
135
146
  xAdvance1: number;
136
147
  xAdvance2: number;
137
148
  } | null;
149
+ /**
150
+ * Apply kerning directly to positions, avoiding object allocation.
151
+ * Returns true if kerning was applied, false otherwise.
152
+ */
153
+ export declare function applyKerningDirect(lookup: PairPosLookup, firstGlyph: GlyphId, secondGlyph: GlyphId, pos1: GlyphPosition, pos2: GlyphPosition): boolean;
154
+ export declare const __testing: {
155
+ parseGposLookup: typeof parseGposLookup;
156
+ parseExtensionLookup: typeof parseExtensionLookup;
157
+ parseSinglePos: typeof parseSinglePos;
158
+ parsePairPos: typeof parsePairPos;
159
+ parseValueRecord: typeof parseValueRecord;
160
+ };
@@ -1,5 +1,6 @@
1
1
  import { type Coverage } from "../../layout/structures/coverage.ts";
2
2
  import { type FeatureList, type ScriptList } from "../../layout/structures/layout-common.ts";
3
+ import { SetDigest } from "../../layout/structures/set-digest.ts";
3
4
  import type { GlyphId, uint16 } from "../../types.ts";
4
5
  import type { Reader } from "../binary/reader.ts";
5
6
  import { type ChainingContextSubstSubtable, type ContextSubstSubtable } from "./gsub-contextual.ts";
@@ -19,6 +20,8 @@ export interface GsubLookup {
19
20
  type: GsubLookupType;
20
21
  flag: uint16;
21
22
  markFilteringSet?: uint16;
23
+ /** Bloom filter for fast O(1) glyph rejection */
24
+ digest: SetDigest;
22
25
  }
23
26
  /** Single substitution lookup (Type 1) */
24
27
  export interface SingleSubstLookup extends GsubLookup {
@@ -100,8 +103,25 @@ export interface GsubTable {
100
103
  }
101
104
  export type { SequenceLookupRecord } from "./gsub-contextual.ts";
102
105
  export declare function parseGsub(reader: Reader): GsubTable;
106
+ declare function parseGsubLookup(reader: Reader, _lookupListReader: Reader, _lookupOffset: number): AnyGsubLookup | null;
107
+ declare function parseExtensionLookup(reader: Reader, subtableOffsets: number[], baseProps: {
108
+ flag: uint16;
109
+ markFilteringSet?: uint16;
110
+ }): AnyGsubLookup | null;
103
111
  export declare function applySingleSubst(lookup: SingleSubstLookup, glyphId: GlyphId): GlyphId | null;
104
112
  export declare function applyLigatureSubst(lookup: LigatureSubstLookup, glyphIds: GlyphId[], startIndex: number): {
105
113
  ligatureGlyph: GlyphId;
106
114
  consumed: number;
107
115
  } | null;
116
+ /**
117
+ * Apply ligature substitution using a Uint16Array directly (avoids Array.from allocation).
118
+ * glyphIds is a pre-allocated typed array, matchLen is the valid length to consider.
119
+ */
120
+ export declare function applyLigatureSubstDirect(lookup: LigatureSubstLookup, glyphIds: Uint16Array, matchLen: number, startIndex: number): {
121
+ ligatureGlyph: GlyphId;
122
+ consumed: number;
123
+ } | null;
124
+ export declare const __testing: {
125
+ parseGsubLookup: typeof parseGsubLookup;
126
+ parseExtensionLookup: typeof parseExtensionLookup;
127
+ };
@@ -39,7 +39,10 @@ export interface PointDelta {
39
39
  y: int16;
40
40
  }
41
41
  /**
42
- * Parse gvar table
42
+ * Parse gvar table - glyph variations for TrueType outlines in variable fonts
43
+ * @param reader - Reader positioned at start of gvar table
44
+ * @param _numGlyphs - Number of glyphs (currently unused)
45
+ * @returns Parsed gvar table with per-glyph variation data
43
46
  */
44
47
  export declare function parseGvar(reader: Reader, _numGlyphs: number): GvarTable;
45
48
  /**
@@ -48,6 +51,12 @@ export declare function parseGvar(reader: Reader, _numGlyphs: number): GvarTable
48
51
  export declare function parsePackedDeltas(reader: Reader, count: number): number[];
49
52
  /**
50
53
  * Calculate the scalar for a tuple given axis coordinates
54
+ * Determines how much a variation tuple contributes based on current axis values
55
+ * @param peakTuple - Peak coordinates for each axis where variation is at maximum
56
+ * @param axisCoords - Current normalized axis coordinates
57
+ * @param intermediateStart - Start of intermediate region (null if not used)
58
+ * @param intermediateEnd - End of intermediate region (null if not used)
59
+ * @returns Scalar value between 0 and 1 indicating variation contribution
51
60
  */
52
61
  export declare function calculateTupleScalar(peakTuple: number[], axisCoords: number[], intermediateStart: number[] | null, intermediateEnd: number[] | null): number;
53
62
  /**
@@ -44,4 +44,9 @@ export declare const MacStyle: {
44
44
  readonly Condensed: 32;
45
45
  readonly Extended: 64;
46
46
  };
47
+ /**
48
+ * Parse head table - font header with global metrics
49
+ * @param reader - Reader positioned at start of head table
50
+ * @returns Parsed head table
51
+ */
47
52
  export declare function parseHead(reader: Reader): HeadTable;
@@ -21,4 +21,9 @@ export interface HheaTable {
21
21
  metricDataFormat: int16;
22
22
  numberOfHMetrics: uint16;
23
23
  }
24
+ /**
25
+ * Parse hhea table - horizontal header with metrics for horizontal layout
26
+ * @param reader - Reader positioned at start of hhea table
27
+ * @returns Parsed hhea table
28
+ */
24
29
  export declare function parseHhea(reader: Reader): HheaTable;
@@ -20,6 +20,9 @@ export declare function parseLoca(reader: Reader, numGlyphs: number, indexToLocF
20
20
  /**
21
21
  * Get byte offset and length for a glyph in the glyf table
22
22
  * Returns null if glyph has no outline (empty glyph)
23
+ * @param loca - Parsed loca table
24
+ * @param glyphId - Glyph ID to look up
25
+ * @returns Object with offset and length, or null if glyph has no outline
23
26
  */
24
27
  export declare function getGlyphLocation(loca: LocaTable, glyphId: GlyphId): {
25
28
  offset: uint32;
@@ -24,4 +24,9 @@ export interface MaxpTable10 {
24
24
  maxComponentDepth: uint16;
25
25
  }
26
26
  export type MaxpTable = MaxpTable05 | MaxpTable10;
27
+ /**
28
+ * Parse maxp table - maximum profile with glyph count and limits
29
+ * @param reader - Reader positioned at start of maxp table
30
+ * @returns Parsed maxp table (version 0.5 for CFF or 1.0 for TrueType)
31
+ */
27
32
  export declare function parseMaxp(reader: Reader): MaxpTable;
@@ -60,6 +60,11 @@ export interface NameTable {
60
60
  format: uint16;
61
61
  records: NameRecord[];
62
62
  }
63
+ /**
64
+ * Parse name table - font naming information in multiple languages
65
+ * @param reader - Reader positioned at start of name table
66
+ * @returns Parsed name table with decoded name records
67
+ */
63
68
  export declare function parseName(reader: Reader): NameTable;
64
69
  /** Get a specific name by ID, preferring Windows Unicode */
65
70
  export declare function getNameById(table: NameTable, nameId: number, languageId?: number): string | null;
@@ -91,6 +91,11 @@ export declare const FsType: {
91
91
  readonly NoSubsetting: 256;
92
92
  readonly BitmapOnly: 512;
93
93
  };
94
+ /**
95
+ * Parse OS/2 table - Windows-specific metrics, weight, width, and classification
96
+ * @param reader - Reader positioned at start of OS/2 table
97
+ * @returns Parsed OS/2 table
98
+ */
94
99
  export declare function parseOs2(reader: Reader): Os2Table;
95
100
  /** Check if font is italic */
96
101
  export declare function isItalic(os2: Os2Table): boolean;
@@ -18,6 +18,11 @@ export interface PostTable {
18
18
  glyphNameIndex?: uint16[];
19
19
  names?: string[];
20
20
  }
21
+ /**
22
+ * Parse post table - PostScript information including glyph names
23
+ * @param reader - Reader positioned at start of post table
24
+ * @returns Parsed post table
25
+ */
21
26
  export declare function parsePost(reader: Reader): PostTable;
22
27
  /** Get glyph name by glyph ID */
23
28
  export declare function getGlyphName(post: PostTable, glyphId: number): string | null;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export { processContextual, processInsertion, processLigature, processRearrangement, } from "./aat/state-machine.ts";
2
2
  export { GlyphBuffer } from "./buffer/glyph-buffer.ts";
3
3
  export { UnicodeBuffer } from "./buffer/unicode-buffer.ts";
4
+ export { adaptiveBlur as $adaptiveBlur, BitmapBuilder, bitmap, blur as $blur, boxBlur as $boxBlur, cascadeBlur as $cascadeBlur, char, clone as $clone, combine, combinePaths as $combinePaths, condensePath as $condensePath, convert as $convert, copy as $copy, embolden as $embolden, emboldenPath as $emboldenPath, fastBlur as $fastBlur, fromGlyph as $fromGlyph, glyph, glyphVar, italic as $italic, matrix as $matrix, obliquePath as $obliquePath, PathBuilder, pad as $pad, path, perspective as $perspective, pipe, rasterize as $rasterize, rasterizeAuto as $rasterizeAuto, rasterizeWithGradient as $rasterizeWithGradient, renderMsdf as $renderMsdf, renderSdf as $renderSdf, resize as $resize, resizeBilinear as $resizeBilinear, rotate as $rotate, rotateDeg as $rotateDeg, scale as $scale, shear as $shear, shift as $shift, strokeAsymmetric as $strokeAsymmetric, strokeAsymmetricCombined as $strokeAsymmetricCombined, strokePath as $strokePath, toGray as $toGray, toRGBA as $toRGBA, toSVG as $toSVG, translate as $translate, } from "./fluent/index.ts";
5
+ export type { AutoRasterOptions, CanvasOptions, RasterOptions, SVGElementOptions, SVGOptions, TransformState, } from "./fluent/types.ts";
4
6
  export { Reader } from "./font/binary/reader.ts";
5
7
  export { createFace, Face } from "./font/face.ts";
6
8
  export { Font, type FontLoadOptions } from "./font/font.ts";
@@ -66,7 +68,7 @@ export { applyFeatureVariations, evaluateConditionSet, findMatchingFeatureVariat
66
68
  export { type AsymmetricStrokeOptions, strokeAsymmetric, strokeAsymmetricCombined, strokeUniform, } from "./raster/asymmetric-stroke.ts";
67
69
  export { atlasToAlpha, atlasToRGBA, buildAsciiAtlas, buildAtlas, buildStringAtlas, getGlyphUV, } from "./raster/atlas.ts";
68
70
  export { getExactBounds } from "./raster/bbox.ts";
69
- export { addBitmaps, blendBitmap, compositeBitmaps, convertBitmap, copyBitmap, emboldenBitmap, expandToFit, fixOutline, maxBitmaps, mulBitmaps, padBitmap, resizeBitmap, shiftBitmap, subBitmaps, } from "./raster/bitmap-utils.ts";
71
+ export { addBitmaps, blendBitmap, compositeBitmaps, convertBitmap, copyBitmap, emboldenBitmap, expandToFit, fixOutline, maxBitmaps, mulBitmaps, padBitmap, resizeBitmap, resizeBitmapBilinear, shiftBitmap, subBitmaps, } from "./raster/bitmap-utils.ts";
70
72
  export { blurBitmap, boxBlur, createGaussianKernel, gaussianBlur, } from "./raster/blur.ts";
71
73
  export { adaptiveBlur, cascadeBlur, fastGaussianBlur, } from "./raster/cascade-blur.ts";
72
74
  export { type ColorStop as GradientColorStop, createGradientBitmap, type Gradient, interpolateGradient, type LinearGradient, type RadialGradient, rasterizePathWithGradient, } from "./raster/gradient.ts";
@@ -79,11 +81,11 @@ export type { Bitmap, GlyphAtlas, GlyphMetrics, MsdfAtlasOptions, RasterizedGlyp
79
81
  export { clearBitmap, createBitmap, FillRule, PixelMode, } from "./raster/types.ts";
80
82
  export { type BoundingBox, type ControlBox, clonePath, combinePaths, computeControlBox, computeTightBounds, identity2D, identity3x3, italicizeOutline, type Matrix2D, type Matrix3x3, multiply2D, multiply3x3, perspectiveMatrix, rotate2D, rotateOutline, rotateOutline90, scale2D, scaleOutline, scaleOutlinePow2, shear2D, transformOutline2D, transformOutline3D, transformPoint2D, transformPoint3x3, translate2D, translateOutline, updateMinTransformedX, } from "./render/outline-transform.ts";
81
83
  export type { GlyphPath, PathCommand, ShapedGlyph } from "./render/path.ts";
82
- export { contourToPath, createPath2D, getGlyphPath, getGlyphPathWithVariation, getTextWidth, glyphBufferToShapedGlyphs, glyphToSVG, pathToCanvas, pathToSVG, renderShapedText, renderShapedTextWithVariation, shapedTextToSVG, shapedTextToSVGWithVariation, } from "./render/path.ts";
84
+ export { applyMatrixToContext, contourToPath, createPath2D, getGlyphPath, getGlyphPathWithVariation, getTextWidth, glyphBufferToShapedGlyphs, glyphToSVG, matrixToSVGTransform, pathToCanvas, pathToCanvasWithMatrix, pathToCanvasWithMatrix3D, pathToSVG, pathToSVGWithMatrix, pathToSVGWithMatrix3D, renderShapedText, renderShapedTextWithVariation, shapedTextToSVG, shapedTextToSVGWithVariation, } from "./render/path.ts";
83
85
  export { applyFallbackKerning, applyFallbackMarkPositioning, } from "./shaper/fallback.ts";
84
86
  export { allSmallCaps, capitalSpacing, capsToSmallCaps, caseSensitiveForms, characterVariant, characterVariants, combineFeatures, contextualAlternates, discretionaryLigatures, feature, features, fractions, fullWidthForms, halfWidthForms, historicalLigatures, jis78Forms, jis83Forms, jis90Forms, jis2004Forms, kerning, liningFigures, oldstyleFigures, ordinals, petiteCaps, proportionalFigures, proportionalWidthForms, quarterWidthForms, ruby, scientificInferiors, simplifiedForms, slashedZero, smallCaps, standardLigatures, stylisticAlternates, stylisticSet, stylisticSets, subscript, superscript, swash, tabularFigures, thirdWidthForms, traditionalForms, verticalAlternatesRotation, verticalForms, verticalKanaAlternates, verticalLayoutFeatures, } from "./shaper/features.ts";
85
87
  export { createShapePlan, getOrCreateShapePlan, type ShapeFeature, type ShapePlan, } from "./shaper/shape-plan.ts";
86
- export { type FontLike, type ShapeOptions, shape } from "./shaper/shaper.ts";
88
+ export { type FontLike, type ShapeOptions, shape, shapeInto, } from "./shaper/shaper.ts";
87
89
  export * from "./types.ts";
88
90
  export { applyMirroring, type BidiParagraph, type BidiResult, BidiType, detectDirection, getCharType, getEmbeddings, getMirror, getVisualOrder, isLTR, isRTL, processBidi, reorderGlyphs, } from "./unicode/bidi.ts";
89
91
  export type { LineBreakAnalysis } from "./unicode/line-break.ts";