text-shaper 0.0.1

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 (97) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +161 -0
  3. package/dist/aat/state-machine.d.ts +34 -0
  4. package/dist/buffer/glyph-buffer.d.ts +55 -0
  5. package/dist/buffer/unicode-buffer.d.ts +51 -0
  6. package/dist/font/binary/reader.d.ts +72 -0
  7. package/dist/font/face.d.ts +65 -0
  8. package/dist/font/font.d.ts +189 -0
  9. package/dist/font/tables/avar.d.ts +36 -0
  10. package/dist/font/tables/base.d.ts +79 -0
  11. package/dist/font/tables/cbdt.d.ts +120 -0
  12. package/dist/font/tables/cff-charstring.d.ts +16 -0
  13. package/dist/font/tables/cff.d.ts +93 -0
  14. package/dist/font/tables/cff2.d.ts +85 -0
  15. package/dist/font/tables/cmap.d.ts +81 -0
  16. package/dist/font/tables/colr.d.ts +278 -0
  17. package/dist/font/tables/cpal.d.ts +46 -0
  18. package/dist/font/tables/feat.d.ts +359 -0
  19. package/dist/font/tables/fvar.d.ts +77 -0
  20. package/dist/font/tables/gdef.d.ts +45 -0
  21. package/dist/font/tables/glyf.d.ts +118 -0
  22. package/dist/font/tables/gpos-contextual.d.ts +88 -0
  23. package/dist/font/tables/gpos-mark.d.ts +95 -0
  24. package/dist/font/tables/gpos.d.ts +137 -0
  25. package/dist/font/tables/gsub-contextual.d.ts +88 -0
  26. package/dist/font/tables/gsub.d.ts +107 -0
  27. package/dist/font/tables/gvar.d.ts +56 -0
  28. package/dist/font/tables/head.d.ts +47 -0
  29. package/dist/font/tables/hhea.d.ts +24 -0
  30. package/dist/font/tables/hmtx.d.ts +23 -0
  31. package/dist/font/tables/hvar.d.ts +77 -0
  32. package/dist/font/tables/jstf.d.ts +97 -0
  33. package/dist/font/tables/kern.d.ts +44 -0
  34. package/dist/font/tables/kerx.d.ts +108 -0
  35. package/dist/font/tables/loca.d.ts +31 -0
  36. package/dist/font/tables/math.d.ts +168 -0
  37. package/dist/font/tables/maxp.d.ts +27 -0
  38. package/dist/font/tables/morx.d.ts +142 -0
  39. package/dist/font/tables/mvar.d.ts +99 -0
  40. package/dist/font/tables/name.d.ts +75 -0
  41. package/dist/font/tables/os2.d.ts +102 -0
  42. package/dist/font/tables/post.d.ts +25 -0
  43. package/dist/font/tables/sbix.d.ts +65 -0
  44. package/dist/font/tables/sfnt.d.ts +20 -0
  45. package/dist/font/tables/stat.d.ts +115 -0
  46. package/dist/font/tables/svg.d.ts +40 -0
  47. package/dist/font/tables/trak.d.ts +43 -0
  48. package/dist/font/tables/vhea.d.ts +41 -0
  49. package/dist/font/tables/vmtx.d.ts +35 -0
  50. package/dist/font/tables/vorg.d.ts +33 -0
  51. package/dist/font/tables/vvar.d.ts +36 -0
  52. package/dist/index.d.ts +80 -0
  53. package/dist/index.js +9 -0
  54. package/dist/index.js.map +92 -0
  55. package/dist/index.test.d.ts +1 -0
  56. package/dist/layout/justify.d.ts +88 -0
  57. package/dist/layout/structures/class-def.d.ts +15 -0
  58. package/dist/layout/structures/coverage.d.ts +17 -0
  59. package/dist/layout/structures/device.d.ts +58 -0
  60. package/dist/layout/structures/feature-variations.d.ts +82 -0
  61. package/dist/layout/structures/layout-common.d.ts +77 -0
  62. package/dist/render/path.d.ts +136 -0
  63. package/dist/shaper/complex/arabic.d.ts +60 -0
  64. package/dist/shaper/complex/ethiopic.d.ts +70 -0
  65. package/dist/shaper/complex/georgian.d.ts +69 -0
  66. package/dist/shaper/complex/hangul.d.ts +64 -0
  67. package/dist/shaper/complex/hebrew.d.ts +28 -0
  68. package/dist/shaper/complex/indic.d.ts +117 -0
  69. package/dist/shaper/complex/khmer.d.ts +48 -0
  70. package/dist/shaper/complex/mongolian.d.ts +89 -0
  71. package/dist/shaper/complex/myanmar.d.ts +47 -0
  72. package/dist/shaper/complex/syriac.d.ts +80 -0
  73. package/dist/shaper/complex/thai-lao.d.ts +42 -0
  74. package/dist/shaper/complex/tibetan.d.ts +57 -0
  75. package/dist/shaper/complex/use.d.ts +80 -0
  76. package/dist/shaper/fallback.d.ts +16 -0
  77. package/dist/shaper/features.d.ts +189 -0
  78. package/dist/shaper/shape-plan.d.ts +29 -0
  79. package/dist/shaper/shaper.d.ts +18 -0
  80. package/dist/types.d.ts +153 -0
  81. package/dist/typeshaper.js +7 -0
  82. package/dist/unicode/bidi/brackets.d.ts +7 -0
  83. package/dist/unicode/bidi/brackets.data.d.ts +5 -0
  84. package/dist/unicode/bidi/char-types.d.ts +19 -0
  85. package/dist/unicode/bidi/char-types.data.d.ts +25 -0
  86. package/dist/unicode/bidi/embedding-levels.d.ts +18 -0
  87. package/dist/unicode/bidi/index.d.ts +9 -0
  88. package/dist/unicode/bidi/mirroring.d.ts +10 -0
  89. package/dist/unicode/bidi/mirroring.data.d.ts +2 -0
  90. package/dist/unicode/bidi/parse-character-map.d.ts +8 -0
  91. package/dist/unicode/bidi/reordering.d.ts +18 -0
  92. package/dist/unicode/bidi.d.ts +93 -0
  93. package/dist/unicode/line-break.d.ts +113 -0
  94. package/dist/unicode/normalize.d.ts +36 -0
  95. package/dist/unicode/script.d.ts +215 -0
  96. package/dist/unicode/segmentation.d.ts +104 -0
  97. package/package.json +33 -0
@@ -0,0 +1,107 @@
1
+ import { type Coverage } from "../../layout/structures/coverage.ts";
2
+ import { type FeatureList, type ScriptList } from "../../layout/structures/layout-common.ts";
3
+ import type { GlyphId, uint16 } from "../../types.ts";
4
+ import type { Reader } from "../binary/reader.ts";
5
+ import { type ChainingContextSubstSubtable, type ContextSubstSubtable } from "./gsub-contextual.ts";
6
+ /** GSUB lookup types */
7
+ export declare enum GsubLookupType {
8
+ Single = 1,
9
+ Multiple = 2,
10
+ Alternate = 3,
11
+ Ligature = 4,
12
+ Context = 5,
13
+ ChainingContext = 6,
14
+ Extension = 7,
15
+ ReverseChainingSingle = 8
16
+ }
17
+ /** Base interface for all GSUB lookups */
18
+ export interface GsubLookup {
19
+ type: GsubLookupType;
20
+ flag: uint16;
21
+ markFilteringSet?: uint16;
22
+ }
23
+ /** Single substitution lookup (Type 1) */
24
+ export interface SingleSubstLookup extends GsubLookup {
25
+ type: GsubLookupType.Single;
26
+ subtables: SingleSubstSubtable[];
27
+ }
28
+ export interface SingleSubstSubtable {
29
+ format: 1 | 2;
30
+ coverage: Coverage;
31
+ deltaGlyphId?: number;
32
+ substituteGlyphIds?: GlyphId[];
33
+ }
34
+ /** Multiple substitution lookup (Type 2) */
35
+ export interface MultipleSubstLookup extends GsubLookup {
36
+ type: GsubLookupType.Multiple;
37
+ subtables: MultipleSubstSubtable[];
38
+ }
39
+ export interface MultipleSubstSubtable {
40
+ coverage: Coverage;
41
+ sequences: GlyphId[][];
42
+ }
43
+ /** Alternate substitution lookup (Type 3) */
44
+ export interface AlternateSubstLookup extends GsubLookup {
45
+ type: GsubLookupType.Alternate;
46
+ subtables: AlternateSubstSubtable[];
47
+ }
48
+ export interface AlternateSubstSubtable {
49
+ coverage: Coverage;
50
+ alternateSets: GlyphId[][];
51
+ }
52
+ /** Ligature substitution lookup (Type 4) */
53
+ export interface LigatureSubstLookup extends GsubLookup {
54
+ type: GsubLookupType.Ligature;
55
+ subtables: LigatureSubstSubtable[];
56
+ }
57
+ export interface LigatureSubstSubtable {
58
+ coverage: Coverage;
59
+ ligatureSets: LigatureSet[];
60
+ }
61
+ export interface LigatureSet {
62
+ ligatures: Ligature[];
63
+ }
64
+ export interface Ligature {
65
+ ligatureGlyph: GlyphId;
66
+ componentGlyphIds: GlyphId[];
67
+ }
68
+ /** Context substitution lookup (Type 5) */
69
+ export interface ContextSubstLookup extends GsubLookup {
70
+ type: GsubLookupType.Context;
71
+ subtables: ContextSubstSubtable[];
72
+ }
73
+ /** Chaining context substitution lookup (Type 6) */
74
+ export interface ChainingContextSubstLookup extends GsubLookup {
75
+ type: GsubLookupType.ChainingContext;
76
+ subtables: ChainingContextSubstSubtable[];
77
+ }
78
+ /** Reverse chaining single substitution lookup (Type 8) */
79
+ export interface ReverseChainingSingleSubstLookup extends GsubLookup {
80
+ type: GsubLookupType.ReverseChainingSingle;
81
+ subtables: ReverseChainingSingleSubstSubtable[];
82
+ }
83
+ export interface ReverseChainingSingleSubstSubtable {
84
+ coverage: Coverage;
85
+ backtrackCoverages: Coverage[];
86
+ lookaheadCoverages: Coverage[];
87
+ substituteGlyphIds: GlyphId[];
88
+ }
89
+ /** Union of all GSUB lookup types */
90
+ export type AnyGsubLookup = SingleSubstLookup | MultipleSubstLookup | AlternateSubstLookup | LigatureSubstLookup | ContextSubstLookup | ChainingContextSubstLookup | ReverseChainingSingleSubstLookup;
91
+ /** GSUB table */
92
+ export interface GsubTable {
93
+ version: {
94
+ major: number;
95
+ minor: number;
96
+ };
97
+ scriptList: ScriptList;
98
+ featureList: FeatureList;
99
+ lookups: AnyGsubLookup[];
100
+ }
101
+ export type { SequenceLookupRecord } from "./gsub-contextual.ts";
102
+ export declare function parseGsub(reader: Reader): GsubTable;
103
+ export declare function applySingleSubst(lookup: SingleSubstLookup, glyphId: GlyphId): GlyphId | null;
104
+ export declare function applyLigatureSubst(lookup: LigatureSubstLookup, glyphIds: GlyphId[], startIndex: number): {
105
+ ligatureGlyph: GlyphId;
106
+ consumed: number;
107
+ } | null;
@@ -0,0 +1,56 @@
1
+ import type { GlyphId, int16, uint16 } from "../../types.ts";
2
+ import type { Reader } from "../binary/reader.ts";
3
+ /**
4
+ * Glyph Variations table (gvar)
5
+ * Contains variation data for TrueType glyph outlines
6
+ */
7
+ export interface GvarTable {
8
+ majorVersion: uint16;
9
+ minorVersion: uint16;
10
+ axisCount: uint16;
11
+ sharedTupleCount: uint16;
12
+ sharedTuples: number[][];
13
+ glyphVariationData: GlyphVariationData[];
14
+ }
15
+ /**
16
+ * Variation data for a single glyph
17
+ */
18
+ export interface GlyphVariationData {
19
+ tupleVariationHeaders: TupleVariationHeader[];
20
+ }
21
+ /**
22
+ * Tuple variation header
23
+ */
24
+ export interface TupleVariationHeader {
25
+ variationDataSize: uint16;
26
+ tupleIndex: uint16;
27
+ peakTuple: number[] | null;
28
+ intermediateStartTuple: number[] | null;
29
+ intermediateEndTuple: number[] | null;
30
+ serializedData: Uint8Array;
31
+ pointNumbers: number[] | null;
32
+ deltas: PointDelta[];
33
+ }
34
+ /**
35
+ * Delta values for a point
36
+ */
37
+ export interface PointDelta {
38
+ x: int16;
39
+ y: int16;
40
+ }
41
+ /**
42
+ * Parse gvar table
43
+ */
44
+ export declare function parseGvar(reader: Reader, _numGlyphs: number): GvarTable;
45
+ /**
46
+ * Parse packed deltas
47
+ */
48
+ export declare function parsePackedDeltas(reader: Reader, count: number): number[];
49
+ /**
50
+ * Calculate the scalar for a tuple given axis coordinates
51
+ */
52
+ export declare function calculateTupleScalar(peakTuple: number[], axisCoords: number[], intermediateStart: number[] | null, intermediateEnd: number[] | null): number;
53
+ /**
54
+ * Get delta for a glyph point at given variation coordinates
55
+ */
56
+ export declare function getGlyphDelta(gvar: GvarTable, glyphId: GlyphId, pointIndex: number, axisCoords: number[]): PointDelta;
@@ -0,0 +1,47 @@
1
+ import type { Fixed, FWord, int16, uint16, uint32 } from "../../types.ts";
2
+ import type { Reader } from "../binary/reader.ts";
3
+ /** Font header table */
4
+ export interface HeadTable {
5
+ majorVersion: uint16;
6
+ minorVersion: uint16;
7
+ fontRevision: Fixed;
8
+ checksumAdjustment: uint32;
9
+ magicNumber: uint32;
10
+ flags: uint16;
11
+ unitsPerEm: uint16;
12
+ created: bigint;
13
+ modified: bigint;
14
+ xMin: FWord;
15
+ yMin: FWord;
16
+ xMax: FWord;
17
+ yMax: FWord;
18
+ macStyle: uint16;
19
+ lowestRecPPEM: uint16;
20
+ fontDirectionHint: int16;
21
+ /** 0 = short offsets (uint16), 1 = long offsets (uint32) in loca table */
22
+ indexToLocFormat: int16;
23
+ glyphDataFormat: int16;
24
+ }
25
+ /** Head table flags */
26
+ export declare const HeadFlags: {
27
+ readonly BaselineAtY0: 1;
28
+ readonly LeftSidebearingAtX0: 2;
29
+ readonly InstructionsDependOnPointSize: 4;
30
+ readonly ForcePPEMToInteger: 8;
31
+ readonly InstructionsAlterAdvanceWidth: 16;
32
+ readonly Lossless: 2048;
33
+ readonly Converted: 4096;
34
+ readonly OptimizedForClearType: 8192;
35
+ readonly LastResortFont: 16384;
36
+ };
37
+ /** Mac style flags */
38
+ export declare const MacStyle: {
39
+ readonly Bold: 1;
40
+ readonly Italic: 2;
41
+ readonly Underline: 4;
42
+ readonly Outline: 8;
43
+ readonly Shadow: 16;
44
+ readonly Condensed: 32;
45
+ readonly Extended: 64;
46
+ };
47
+ export declare function parseHead(reader: Reader): HeadTable;
@@ -0,0 +1,24 @@
1
+ import type { FWord, int16, UFWord, uint16 } from "../../types.ts";
2
+ import type { Reader } from "../binary/reader.ts";
3
+ /** Horizontal header table */
4
+ export interface HheaTable {
5
+ majorVersion: uint16;
6
+ minorVersion: uint16;
7
+ ascender: FWord;
8
+ descender: FWord;
9
+ lineGap: FWord;
10
+ advanceWidthMax: UFWord;
11
+ minLeftSideBearing: FWord;
12
+ minRightSideBearing: FWord;
13
+ xMaxExtent: FWord;
14
+ caretSlopeRise: int16;
15
+ caretSlopeRun: int16;
16
+ caretOffset: int16;
17
+ reserved1: int16;
18
+ reserved2: int16;
19
+ reserved3: int16;
20
+ reserved4: int16;
21
+ metricDataFormat: int16;
22
+ numberOfHMetrics: uint16;
23
+ }
24
+ export declare function parseHhea(reader: Reader): HheaTable;
@@ -0,0 +1,23 @@
1
+ import type { FWord, GlyphId, UFWord } from "../../types.ts";
2
+ import type { Reader } from "../binary/reader.ts";
3
+ /** Horizontal metric for a glyph */
4
+ export interface LongHorMetric {
5
+ advanceWidth: UFWord;
6
+ lsb: FWord;
7
+ }
8
+ /** Horizontal metrics table */
9
+ export interface HmtxTable {
10
+ hMetrics: LongHorMetric[];
11
+ leftSideBearings: FWord[];
12
+ }
13
+ /**
14
+ * Parse hmtx table.
15
+ * @param reader - Reader positioned at hmtx table start
16
+ * @param numberOfHMetrics - From hhea table
17
+ * @param numGlyphs - From maxp table
18
+ */
19
+ export declare function parseHmtx(reader: Reader, numberOfHMetrics: number, numGlyphs: number): HmtxTable;
20
+ /** Get advance width for a glyph */
21
+ export declare function getAdvanceWidth(hmtx: HmtxTable, glyphId: GlyphId): number;
22
+ /** Get left side bearing for a glyph */
23
+ export declare function getLeftSideBearing(hmtx: HmtxTable, glyphId: GlyphId): number;
@@ -0,0 +1,77 @@
1
+ import type { GlyphId, uint16, uint32 } from "../../types.ts";
2
+ import type { Reader } from "../binary/reader.ts";
3
+ /**
4
+ * Horizontal Metrics Variations table (HVAR)
5
+ * Provides variations for horizontal advance widths and LSB
6
+ */
7
+ export interface HvarTable {
8
+ majorVersion: number;
9
+ minorVersion: number;
10
+ itemVariationStore: ItemVariationStore;
11
+ advanceWidthMapping: DeltaSetIndexMap | null;
12
+ lsbMapping: DeltaSetIndexMap | null;
13
+ rsbMapping: DeltaSetIndexMap | null;
14
+ }
15
+ /**
16
+ * Item Variation Store - stores delta values for variations
17
+ */
18
+ export interface ItemVariationStore {
19
+ format: number;
20
+ variationRegions: VariationRegion[];
21
+ itemVariationData: ItemVariationData[];
22
+ }
23
+ /**
24
+ * Variation region defines the space where deltas apply
25
+ */
26
+ export interface VariationRegion {
27
+ regionAxes: RegionAxisCoordinates[];
28
+ }
29
+ /**
30
+ * Axis coordinates for a region
31
+ */
32
+ export interface RegionAxisCoordinates {
33
+ startCoord: number;
34
+ peakCoord: number;
35
+ endCoord: number;
36
+ }
37
+ /**
38
+ * Item variation data subtable
39
+ */
40
+ export interface ItemVariationData {
41
+ itemCount: uint16;
42
+ regionIndexes: uint16[];
43
+ deltaSets: number[][];
44
+ }
45
+ /**
46
+ * Delta set index map for mapping glyphs to variation data
47
+ */
48
+ export interface DeltaSetIndexMap {
49
+ format: number;
50
+ mapCount: uint32;
51
+ entryFormat: number;
52
+ innerIndexBitCount: number;
53
+ mapData: {
54
+ outer: number;
55
+ inner: number;
56
+ }[];
57
+ }
58
+ /**
59
+ * Parse HVAR table
60
+ */
61
+ export declare function parseHvar(reader: Reader): HvarTable;
62
+ /**
63
+ * Calculate scalar for a variation region given axis coordinates
64
+ */
65
+ export declare function calculateRegionScalar(region: VariationRegion, coords: number[]): number;
66
+ /**
67
+ * Get advance width delta for a glyph at given variation coordinates
68
+ */
69
+ export declare function getAdvanceWidthDelta(hvar: HvarTable, glyphId: GlyphId, coords: number[]): number;
70
+ /**
71
+ * Get left side bearing delta for a glyph at given variation coordinates
72
+ */
73
+ export declare function getLsbDelta(hvar: HvarTable, glyphId: GlyphId, coords: number[]): number;
74
+ /**
75
+ * Get right side bearing delta for a glyph at given variation coordinates
76
+ */
77
+ export declare function getRsbDelta(hvar: HvarTable, glyphId: GlyphId, coords: number[]): number;
@@ -0,0 +1,97 @@
1
+ import type { uint16 } from "../../types.ts";
2
+ import type { Reader } from "../binary/reader.ts";
3
+ /**
4
+ * JSTF table - Justification data
5
+ * Provides justification alternatives for scripts
6
+ */
7
+ /** Justification priority levels */
8
+ export declare const JstfPriority: {
9
+ /** Shrink GPOS lookups */
10
+ readonly ShrinkGpos: 0;
11
+ /** Disable GPOS lookups */
12
+ readonly DisableGpos: 1;
13
+ /** Shrink GSUB lookups */
14
+ readonly ShrinkGsub: 2;
15
+ /** Disable GSUB lookups */
16
+ readonly DisableGsub: 3;
17
+ /** Enable GPOS lookups */
18
+ readonly EnableGpos: 4;
19
+ /** Enable GSUB lookups */
20
+ readonly EnableGsub: 5;
21
+ /** Max extension GPOS lookups */
22
+ readonly MaxExtendGpos: 6;
23
+ /** Max extension GSUB lookups */
24
+ readonly MaxExtendGsub: 7;
25
+ };
26
+ /** JstfMax table - lookup indices for maximum extension */
27
+ export interface JstfMax {
28
+ lookupIndices: uint16[];
29
+ }
30
+ /** JstfModList - enable/disable lookup list */
31
+ export interface JstfModList {
32
+ lookupIndices: uint16[];
33
+ }
34
+ /** Justification priority record */
35
+ export interface JstfPriorityRecord {
36
+ /** GSUB lookups to enable for shrinkage */
37
+ shrinkageEnableGsub: JstfModList | null;
38
+ /** GSUB lookups to disable for shrinkage */
39
+ shrinkageDisableGsub: JstfModList | null;
40
+ /** GPOS lookups to enable for shrinkage */
41
+ shrinkageEnableGpos: JstfModList | null;
42
+ /** GPOS lookups to disable for shrinkage */
43
+ shrinkageDisableGpos: JstfModList | null;
44
+ /** Maximum shrinkage GSUB */
45
+ shrinkageJstfMax: JstfMax | null;
46
+ /** GSUB lookups to enable for extension */
47
+ extensionEnableGsub: JstfModList | null;
48
+ /** GSUB lookups to disable for extension */
49
+ extensionDisableGsub: JstfModList | null;
50
+ /** GPOS lookups to enable for extension */
51
+ extensionEnableGpos: JstfModList | null;
52
+ /** GPOS lookups to disable for extension */
53
+ extensionDisableGpos: JstfModList | null;
54
+ /** Maximum extension GSUB */
55
+ extensionJstfMax: JstfMax | null;
56
+ }
57
+ /** Justification language system */
58
+ export interface JstfLangSys {
59
+ priorities: JstfPriorityRecord[];
60
+ }
61
+ /** Justification script record */
62
+ export interface JstfScriptRecord {
63
+ scriptTag: number;
64
+ /** Extender glyphs for Kashida-like justification */
65
+ extenderGlyphs: uint16[];
66
+ /** Default language system */
67
+ defaultLangSys: JstfLangSys | null;
68
+ /** Language-specific systems */
69
+ langSysRecords: Map<number, JstfLangSys>;
70
+ }
71
+ /** JSTF table */
72
+ export interface JstfTable {
73
+ majorVersion: uint16;
74
+ minorVersion: uint16;
75
+ scripts: JstfScriptRecord[];
76
+ }
77
+ export declare function parseJstf(reader: Reader): JstfTable;
78
+ /** Get extender glyphs for a script (e.g., Kashida for Arabic) */
79
+ export declare function getExtenderGlyphs(jstf: JstfTable, scriptTag: number): uint16[];
80
+ /** Get justification priorities for a script/language */
81
+ export declare function getJstfPriorities(jstf: JstfTable, scriptTag: number, languageTag?: number): JstfPriorityRecord[];
82
+ /** Get lookup modifications for shrinkage at a given priority level */
83
+ export declare function getShrinkageMods(priority: JstfPriorityRecord): {
84
+ enableGsub: uint16[];
85
+ disableGsub: uint16[];
86
+ enableGpos: uint16[];
87
+ disableGpos: uint16[];
88
+ maxLookups: uint16[];
89
+ };
90
+ /** Get lookup modifications for extension at a given priority level */
91
+ export declare function getExtensionMods(priority: JstfPriorityRecord): {
92
+ enableGsub: uint16[];
93
+ disableGsub: uint16[];
94
+ enableGpos: uint16[];
95
+ disableGpos: uint16[];
96
+ maxLookups: uint16[];
97
+ };
@@ -0,0 +1,44 @@
1
+ import type { GlyphId, int16, uint16 } from "../../types.ts";
2
+ import type { Reader } from "../binary/reader.ts";
3
+ /**
4
+ * Legacy kern table for kerning pairs
5
+ * Used when GPOS kerning is not available
6
+ */
7
+ export interface KernTable {
8
+ version: number;
9
+ subtables: KernSubtable[];
10
+ }
11
+ export type KernSubtable = KernFormat0 | KernFormat2;
12
+ /**
13
+ * Format 0: Ordered list of kerning pairs
14
+ */
15
+ export interface KernFormat0 {
16
+ format: 0;
17
+ coverage: KernCoverage;
18
+ pairs: Map<number, int16>;
19
+ }
20
+ /**
21
+ * Format 2: Class-based kerning (two-dimensional array)
22
+ */
23
+ export interface KernFormat2 {
24
+ format: 2;
25
+ coverage: KernCoverage;
26
+ rowWidth: uint16;
27
+ leftClassTable: Map<GlyphId, uint16>;
28
+ rightClassTable: Map<GlyphId, uint16>;
29
+ kerningValues: int16[][];
30
+ }
31
+ export interface KernCoverage {
32
+ horizontal: boolean;
33
+ minimum: boolean;
34
+ crossStream: boolean;
35
+ override: boolean;
36
+ }
37
+ /**
38
+ * Parse kern table
39
+ */
40
+ export declare function parseKern(reader: Reader): KernTable;
41
+ /**
42
+ * Get kerning value from kern table
43
+ */
44
+ export declare function getKernValue(kern: KernTable, left: GlyphId, right: GlyphId): number;
@@ -0,0 +1,108 @@
1
+ import type { GlyphId, int16, uint16, uint32 } from "../../types.ts";
2
+ import type { Reader } from "../binary/reader.ts";
3
+ /**
4
+ * Extended Kerning table (kerx)
5
+ * Apple Advanced Typography kerning
6
+ */
7
+ export interface KerxTable {
8
+ version: uint16;
9
+ nTables: uint32;
10
+ subtables: KerxSubtable[];
11
+ }
12
+ /**
13
+ * kerx subtable types
14
+ */
15
+ export declare enum KerxSubtableType {
16
+ OrderedList = 0,
17
+ StateTable = 1,
18
+ SimpleArray = 2,
19
+ ControlPoint = 4,
20
+ Format6 = 6
21
+ }
22
+ /**
23
+ * Coverage flags
24
+ */
25
+ export interface KerxCoverage {
26
+ vertical: boolean;
27
+ crossStream: boolean;
28
+ variation: boolean;
29
+ }
30
+ /**
31
+ * Base subtable
32
+ */
33
+ export interface KerxSubtableBase {
34
+ length: uint32;
35
+ coverage: KerxCoverage;
36
+ tupleCount: uint16;
37
+ }
38
+ export type KerxSubtable = KerxOrderedListSubtable | KerxStateTableSubtable | KerxSimpleArraySubtable | KerxControlPointSubtable | KerxFormat6Subtable;
39
+ /**
40
+ * Format 0: Ordered list of kerning pairs
41
+ */
42
+ export interface KerxOrderedListSubtable extends KerxSubtableBase {
43
+ format: KerxSubtableType.OrderedList;
44
+ nPairs: uint32;
45
+ pairs: KerxPair[];
46
+ }
47
+ export interface KerxPair {
48
+ left: GlyphId;
49
+ right: GlyphId;
50
+ value: int16;
51
+ }
52
+ /**
53
+ * Format 1: State table
54
+ */
55
+ export interface KerxStateTableSubtable extends KerxSubtableBase {
56
+ format: KerxSubtableType.StateTable;
57
+ stateHeader: KerxStateHeader;
58
+ }
59
+ export interface KerxStateHeader {
60
+ nClasses: uint32;
61
+ classTableOffset: uint32;
62
+ stateArrayOffset: uint32;
63
+ entryTableOffset: uint32;
64
+ valueTableOffset: uint32;
65
+ }
66
+ /**
67
+ * Format 2: Simple array
68
+ */
69
+ export interface KerxSimpleArraySubtable extends KerxSubtableBase {
70
+ format: KerxSubtableType.SimpleArray;
71
+ rowWidth: uint16;
72
+ leftClassTable: KerxClassTable;
73
+ rightClassTable: KerxClassTable;
74
+ kerningArray: Int16Array;
75
+ }
76
+ export interface KerxClassTable {
77
+ firstGlyph: GlyphId;
78
+ nGlyphs: uint16;
79
+ classes: Uint8Array;
80
+ }
81
+ /**
82
+ * Format 4: Control point actions
83
+ */
84
+ export interface KerxControlPointSubtable extends KerxSubtableBase {
85
+ format: KerxSubtableType.ControlPoint;
86
+ flags: uint32;
87
+ }
88
+ /**
89
+ * Format 6: Extended kerning pairs
90
+ */
91
+ export interface KerxFormat6Subtable extends KerxSubtableBase {
92
+ format: KerxSubtableType.Format6;
93
+ flags: uint32;
94
+ rowCount: uint16;
95
+ columnCount: uint16;
96
+ rowIndexTableOffset: uint32;
97
+ columnIndexTableOffset: uint32;
98
+ kerningArrayOffset: uint32;
99
+ kerningVectorOffset: uint32;
100
+ }
101
+ /**
102
+ * Parse kerx table
103
+ */
104
+ export declare function parseKerx(reader: Reader): KerxTable;
105
+ /**
106
+ * Get kerning value from kerx table
107
+ */
108
+ export declare function getKerxValue(kerx: KerxTable, left: GlyphId, right: GlyphId): number;
@@ -0,0 +1,31 @@
1
+ import type { GlyphId, uint32 } from "../../types.ts";
2
+ import type { Reader } from "../binary/reader.ts";
3
+ /**
4
+ * loca table - Glyph location index
5
+ * Maps glyph IDs to byte offsets in the glyf table
6
+ */
7
+ export interface LocaTable {
8
+ /** Glyph offsets (numGlyphs + 1 entries) */
9
+ offsets: uint32[];
10
+ /** Whether the font uses short (16-bit) or long (32-bit) offsets */
11
+ isShort: boolean;
12
+ }
13
+ /**
14
+ * Parse loca table
15
+ * @param reader - Reader positioned at start of loca table
16
+ * @param numGlyphs - Number of glyphs from maxp table
17
+ * @param indexToLocFormat - 0 for short offsets, 1 for long (from head table)
18
+ */
19
+ export declare function parseLoca(reader: Reader, numGlyphs: number, indexToLocFormat: number): LocaTable;
20
+ /**
21
+ * Get byte offset and length for a glyph in the glyf table
22
+ * Returns null if glyph has no outline (empty glyph)
23
+ */
24
+ export declare function getGlyphLocation(loca: LocaTable, glyphId: GlyphId): {
25
+ offset: uint32;
26
+ length: uint32;
27
+ } | null;
28
+ /**
29
+ * Check if a glyph has outline data
30
+ */
31
+ export declare function hasGlyphOutline(loca: LocaTable, glyphId: GlyphId): boolean;