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,77 @@
1
+ import type { Fixed, Tag } from "../../types.ts";
2
+ import type { Reader } from "../binary/reader.ts";
3
+ /**
4
+ * Font Variations table (fvar)
5
+ * Defines axes of variation in a variable font
6
+ */
7
+ export interface FvarTable {
8
+ majorVersion: number;
9
+ minorVersion: number;
10
+ axes: VariationAxis[];
11
+ instances: NamedInstance[];
12
+ }
13
+ /**
14
+ * Variation axis definition
15
+ */
16
+ export interface VariationAxis {
17
+ /** 4-byte axis tag (e.g., 'wght', 'wdth', 'ital') */
18
+ tag: Tag;
19
+ /** Minimum coordinate value */
20
+ minValue: Fixed;
21
+ /** Default coordinate value */
22
+ defaultValue: Fixed;
23
+ /** Maximum coordinate value */
24
+ maxValue: Fixed;
25
+ /** Axis qualifiers (flags) */
26
+ flags: number;
27
+ /** Name ID for this axis */
28
+ axisNameId: number;
29
+ }
30
+ /**
31
+ * Named instance (predefined variation)
32
+ */
33
+ export interface NamedInstance {
34
+ /** Name ID for this instance */
35
+ subfamilyNameId: number;
36
+ /** Flags */
37
+ flags: number;
38
+ /** Coordinate values for each axis */
39
+ coordinates: Fixed[];
40
+ /** PostScript name ID (optional) */
41
+ postScriptNameId?: number;
42
+ }
43
+ /**
44
+ * Common axis tags
45
+ */
46
+ export declare const AxisTags: {
47
+ /** Weight (100-900, default 400) */
48
+ readonly wght: 2003265652;
49
+ /** Width (50-200%, default 100) */
50
+ readonly wdth: 2003072104;
51
+ /** Italic (0-1) */
52
+ readonly ital: 1769234796;
53
+ /** Slant (-90 to 90 degrees) */
54
+ readonly slnt: 1936486004;
55
+ /** Optical size (in points) */
56
+ readonly opsz: 1869640570;
57
+ };
58
+ /**
59
+ * Parse fvar table
60
+ */
61
+ export declare function parseFvar(reader: Reader): FvarTable;
62
+ /**
63
+ * Normalize axis value to range [-1, 1]
64
+ */
65
+ export declare function normalizeAxisValue(axis: VariationAxis, value: number): number;
66
+ /**
67
+ * Get axis by tag
68
+ */
69
+ export declare function getAxis(fvar: FvarTable, axisTag: Tag): VariationAxis | null;
70
+ /**
71
+ * Get axis index by tag
72
+ */
73
+ export declare function getAxisIndex(fvar: FvarTable, axisTag: Tag): number;
74
+ /**
75
+ * Debug: Print axis info
76
+ */
77
+ export declare function formatAxis(axis: VariationAxis): string;
@@ -0,0 +1,45 @@
1
+ import { type ClassDef } from "../../layout/structures/class-def.ts";
2
+ import type { GlyphId, uint16 } from "../../types.ts";
3
+ import { GlyphClass } from "../../types.ts";
4
+ import type { Reader } from "../binary/reader.ts";
5
+ /** Attach point for a glyph */
6
+ export interface AttachPoint {
7
+ pointIndices: uint16[];
8
+ }
9
+ /** Ligature caret for a ligature glyph */
10
+ export interface LigatureCaret {
11
+ caretValues: number[];
12
+ }
13
+ /** Mark glyph sets */
14
+ export interface MarkGlyphSets {
15
+ /** Check if glyph is in mark set */
16
+ has(setIndex: number, glyphId: GlyphId): boolean;
17
+ }
18
+ /** Glyph Definition table */
19
+ export interface GdefTable {
20
+ version: {
21
+ major: number;
22
+ minor: number;
23
+ };
24
+ /** Glyph class definitions (Base=1, Ligature=2, Mark=3, Component=4) */
25
+ glyphClassDef: ClassDef;
26
+ /** Attachment point list (optional) */
27
+ attachList: Map<GlyphId, AttachPoint> | null;
28
+ /** Ligature caret list (optional) */
29
+ ligCaretList: Map<GlyphId, LigatureCaret> | null;
30
+ /** Mark attachment class definitions */
31
+ markAttachClassDef: ClassDef;
32
+ /** Mark glyph sets (version 1.2+) */
33
+ markGlyphSets: MarkGlyphSets | null;
34
+ }
35
+ export declare function parseGdef(reader: Reader): GdefTable;
36
+ /** Get glyph class from GDEF */
37
+ export declare function getGlyphClass(gdef: GdefTable | null, glyphId: GlyphId): GlyphClass | 0;
38
+ /** Check if glyph is a base glyph */
39
+ export declare function isBaseGlyph(gdef: GdefTable | null, glyphId: GlyphId): boolean;
40
+ /** Check if glyph is a ligature */
41
+ export declare function isLigature(gdef: GdefTable | null, glyphId: GlyphId): boolean;
42
+ /** Check if glyph is a mark */
43
+ export declare function isMark(gdef: GdefTable | null, glyphId: GlyphId): boolean;
44
+ /** Check if glyph is a component */
45
+ export declare function isComponent(gdef: GdefTable | null, glyphId: GlyphId): boolean;
@@ -0,0 +1,118 @@
1
+ import type { GlyphId, int16, uint16 } from "../../types.ts";
2
+ import type { Reader } from "../binary/reader.ts";
3
+ import type { GvarTable, PointDelta } from "./gvar.ts";
4
+ import type { LocaTable } from "./loca.ts";
5
+ /**
6
+ * glyf table - Glyph outline data
7
+ * Contains TrueType glyph contours as quadratic Bézier curves
8
+ */
9
+ /** Point flags */
10
+ export declare const PointFlag: {
11
+ readonly OnCurve: 1;
12
+ readonly XShortVector: 2;
13
+ readonly YShortVector: 4;
14
+ readonly Repeat: 8;
15
+ readonly XIsSameOrPositive: 16;
16
+ readonly YIsSameOrPositive: 32;
17
+ readonly OverlapSimple: 64;
18
+ };
19
+ /** Composite glyph flags */
20
+ export declare const CompositeFlag: {
21
+ readonly Arg1And2AreWords: 1;
22
+ readonly ArgsAreXYValues: 2;
23
+ readonly RoundXYToGrid: 4;
24
+ readonly WeHaveAScale: 8;
25
+ readonly MoreComponents: 32;
26
+ readonly WeHaveAnXAndYScale: 64;
27
+ readonly WeHaveATwoByTwo: 128;
28
+ readonly WeHaveInstructions: 256;
29
+ readonly UseMyMetrics: 512;
30
+ readonly OverlapCompound: 1024;
31
+ readonly ScaledComponentOffset: 2048;
32
+ readonly UnscaledComponentOffset: 4096;
33
+ };
34
+ /** A point in a glyph contour */
35
+ export interface GlyphPoint {
36
+ x: number;
37
+ y: number;
38
+ onCurve: boolean;
39
+ }
40
+ /** A contour is a closed path of points */
41
+ export type Contour = GlyphPoint[];
42
+ /** Simple glyph with contours */
43
+ export interface SimpleGlyph {
44
+ type: "simple";
45
+ numberOfContours: int16;
46
+ xMin: int16;
47
+ yMin: int16;
48
+ xMax: int16;
49
+ yMax: int16;
50
+ contours: Contour[];
51
+ instructions: Uint8Array<ArrayBufferLike>;
52
+ }
53
+ /** Component of a composite glyph */
54
+ export interface GlyphComponent {
55
+ glyphId: GlyphId;
56
+ flags: uint16;
57
+ /** X offset or point number */
58
+ arg1: number;
59
+ /** Y offset or point number */
60
+ arg2: number;
61
+ /** Transformation matrix [a, b, c, d] */
62
+ transform: [number, number, number, number];
63
+ }
64
+ /** Composite glyph made of other glyphs */
65
+ export interface CompositeGlyph {
66
+ type: "composite";
67
+ numberOfContours: int16;
68
+ xMin: int16;
69
+ yMin: int16;
70
+ xMax: int16;
71
+ yMax: int16;
72
+ components: GlyphComponent[];
73
+ instructions: Uint8Array<ArrayBufferLike>;
74
+ }
75
+ /** Empty glyph (space, etc.) */
76
+ export interface EmptyGlyph {
77
+ type: "empty";
78
+ }
79
+ export type Glyph = SimpleGlyph | CompositeGlyph | EmptyGlyph;
80
+ /** glyf table stores the raw reader for on-demand glyph parsing */
81
+ export interface GlyfTable {
82
+ reader: Reader;
83
+ }
84
+ export declare function parseGlyf(reader: Reader): GlyfTable;
85
+ /**
86
+ * Parse a single glyph from the glyf table
87
+ */
88
+ export declare function parseGlyph(glyf: GlyfTable, loca: LocaTable, glyphId: GlyphId): Glyph;
89
+ /**
90
+ * Flatten a composite glyph into simple contours
91
+ * Recursively resolves all component glyphs and applies transformations
92
+ */
93
+ export declare function flattenCompositeGlyph(glyf: GlyfTable, loca: LocaTable, glyph: CompositeGlyph, depth?: number): Contour[];
94
+ /**
95
+ * Get all contours for a glyph, flattening composites
96
+ */
97
+ export declare function getGlyphContours(glyf: GlyfTable, loca: LocaTable, glyphId: GlyphId): Contour[];
98
+ /**
99
+ * Get bounding box for a glyph
100
+ */
101
+ export declare function getGlyphBounds(glyf: GlyfTable, loca: LocaTable, glyphId: GlyphId): {
102
+ xMin: number;
103
+ yMin: number;
104
+ xMax: number;
105
+ yMax: number;
106
+ } | null;
107
+ /**
108
+ * Get all deltas for a glyph at given variation coordinates
109
+ */
110
+ export declare function getGlyphDeltas(gvar: GvarTable, glyphId: GlyphId, numPoints: number, axisCoords: number[]): PointDelta[];
111
+ /**
112
+ * Apply variation deltas to contours
113
+ */
114
+ export declare function applyVariationDeltas(contours: Contour[], deltas: PointDelta[]): Contour[];
115
+ /**
116
+ * Get contours for a glyph with variation applied
117
+ */
118
+ export declare function getGlyphContoursWithVariation(glyf: GlyfTable, loca: LocaTable, gvar: GvarTable | null, glyphId: GlyphId, axisCoords?: number[]): Contour[];
@@ -0,0 +1,88 @@
1
+ import { type ClassDef } from "../../layout/structures/class-def.ts";
2
+ import { type Coverage } from "../../layout/structures/coverage.ts";
3
+ import type { GlyphId, uint16 } from "../../types.ts";
4
+ import type { Reader } from "../binary/reader.ts";
5
+ import type { GposLookup } from "./gpos.ts";
6
+ /** Position lookup record - applies a lookup at a position */
7
+ export interface PosLookupRecord {
8
+ sequenceIndex: uint16;
9
+ lookupListIndex: uint16;
10
+ }
11
+ /** Context positioning lookup (Type 7) */
12
+ export interface ContextPosLookup extends GposLookup {
13
+ type: 7;
14
+ subtables: ContextPosSubtable[];
15
+ }
16
+ export type ContextPosSubtable = ContextPosFormat1 | ContextPosFormat2 | ContextPosFormat3;
17
+ /** Format 1: Simple glyph contexts */
18
+ export interface ContextPosFormat1 {
19
+ format: 1;
20
+ coverage: Coverage;
21
+ ruleSets: (PosContextRule[] | null)[];
22
+ }
23
+ export interface PosContextRule {
24
+ glyphCount: uint16;
25
+ inputSequence: GlyphId[];
26
+ lookupRecords: PosLookupRecord[];
27
+ }
28
+ /** Format 2: Class-based contexts */
29
+ export interface ContextPosFormat2 {
30
+ format: 2;
31
+ coverage: Coverage;
32
+ classDef: ClassDef;
33
+ classRuleSets: (PosClassRule[] | null)[];
34
+ }
35
+ export interface PosClassRule {
36
+ glyphCount: uint16;
37
+ inputClasses: uint16[];
38
+ lookupRecords: PosLookupRecord[];
39
+ }
40
+ /** Format 3: Coverage-based contexts */
41
+ export interface ContextPosFormat3 {
42
+ format: 3;
43
+ coverages: Coverage[];
44
+ lookupRecords: PosLookupRecord[];
45
+ }
46
+ /** Chaining context positioning lookup (Type 8) */
47
+ export interface ChainingContextPosLookup extends GposLookup {
48
+ type: 8;
49
+ subtables: ChainingContextPosSubtable[];
50
+ }
51
+ export type ChainingContextPosSubtable = ChainingContextPosFormat1 | ChainingContextPosFormat2 | ChainingContextPosFormat3;
52
+ /** Format 1: Simple chaining context */
53
+ export interface ChainingContextPosFormat1 {
54
+ format: 1;
55
+ coverage: Coverage;
56
+ chainRuleSets: (PosChainRule[] | null)[];
57
+ }
58
+ export interface PosChainRule {
59
+ backtrackSequence: GlyphId[];
60
+ inputSequence: GlyphId[];
61
+ lookaheadSequence: GlyphId[];
62
+ lookupRecords: PosLookupRecord[];
63
+ }
64
+ /** Format 2: Class-based chaining context */
65
+ export interface ChainingContextPosFormat2 {
66
+ format: 2;
67
+ coverage: Coverage;
68
+ backtrackClassDef: ClassDef;
69
+ inputClassDef: ClassDef;
70
+ lookaheadClassDef: ClassDef;
71
+ chainClassRuleSets: (PosChainClassRule[] | null)[];
72
+ }
73
+ export interface PosChainClassRule {
74
+ backtrackClasses: uint16[];
75
+ inputClasses: uint16[];
76
+ lookaheadClasses: uint16[];
77
+ lookupRecords: PosLookupRecord[];
78
+ }
79
+ /** Format 3: Coverage-based chaining context */
80
+ export interface ChainingContextPosFormat3 {
81
+ format: 3;
82
+ backtrackCoverages: Coverage[];
83
+ inputCoverages: Coverage[];
84
+ lookaheadCoverages: Coverage[];
85
+ lookupRecords: PosLookupRecord[];
86
+ }
87
+ export declare function parseContextPos(reader: Reader, subtableOffsets: number[]): ContextPosSubtable[];
88
+ export declare function parseChainingContextPos(reader: Reader, subtableOffsets: number[]): ChainingContextPosSubtable[];
@@ -0,0 +1,95 @@
1
+ import { type Coverage } from "../../layout/structures/coverage.ts";
2
+ import type { int16, uint16 } from "../../types.ts";
3
+ import type { Reader } from "../binary/reader.ts";
4
+ import type { GposLookup } from "./gpos.ts";
5
+ /** Anchor point for attachment */
6
+ export interface Anchor {
7
+ xCoordinate: int16;
8
+ yCoordinate: int16;
9
+ /** Contour point index (format 2) */
10
+ anchorPoint?: uint16;
11
+ /** Device table offsets (format 3) */
12
+ xDeviceOffset?: uint16;
13
+ yDeviceOffset?: uint16;
14
+ }
15
+ /** Mark record */
16
+ export interface MarkRecord {
17
+ markClass: uint16;
18
+ markAnchor: Anchor;
19
+ }
20
+ /** Mark array */
21
+ export interface MarkArray {
22
+ markRecords: MarkRecord[];
23
+ }
24
+ /** Base record for mark-to-base */
25
+ export interface BaseRecord {
26
+ baseAnchors: (Anchor | null)[];
27
+ }
28
+ /** Ligature attach record */
29
+ export interface LigatureAttach {
30
+ componentRecords: ComponentRecord[];
31
+ }
32
+ /** Component record for ligature */
33
+ export interface ComponentRecord {
34
+ ligatureAnchors: (Anchor | null)[];
35
+ }
36
+ /** Mark2 record for mark-to-mark */
37
+ export interface Mark2Record {
38
+ mark2Anchors: (Anchor | null)[];
39
+ }
40
+ /** Cursive attachment lookup (Type 3) */
41
+ export interface CursivePosLookup extends GposLookup {
42
+ type: 3;
43
+ subtables: CursivePosSubtable[];
44
+ }
45
+ export interface CursivePosSubtable {
46
+ coverage: Coverage;
47
+ entryExitRecords: EntryExitRecord[];
48
+ }
49
+ export interface EntryExitRecord {
50
+ entryAnchor: Anchor | null;
51
+ exitAnchor: Anchor | null;
52
+ }
53
+ /** Mark-to-base attachment lookup (Type 4) */
54
+ export interface MarkBasePosLookup extends GposLookup {
55
+ type: 4;
56
+ subtables: MarkBasePosSubtable[];
57
+ }
58
+ export interface MarkBasePosSubtable {
59
+ markCoverage: Coverage;
60
+ baseCoverage: Coverage;
61
+ markClassCount: uint16;
62
+ markArray: MarkArray;
63
+ baseArray: BaseRecord[];
64
+ }
65
+ /** Mark-to-ligature attachment lookup (Type 5) */
66
+ export interface MarkLigaturePosLookup extends GposLookup {
67
+ type: 5;
68
+ subtables: MarkLigaturePosSubtable[];
69
+ }
70
+ export interface MarkLigaturePosSubtable {
71
+ markCoverage: Coverage;
72
+ ligatureCoverage: Coverage;
73
+ markClassCount: uint16;
74
+ markArray: MarkArray;
75
+ ligatureArray: LigatureAttach[];
76
+ }
77
+ /** Mark-to-mark attachment lookup (Type 6) */
78
+ export interface MarkMarkPosLookup extends GposLookup {
79
+ type: 6;
80
+ subtables: MarkMarkPosSubtable[];
81
+ }
82
+ export interface MarkMarkPosSubtable {
83
+ mark1Coverage: Coverage;
84
+ mark2Coverage: Coverage;
85
+ markClassCount: uint16;
86
+ mark1Array: MarkArray;
87
+ mark2Array: Mark2Record[];
88
+ }
89
+ export declare function parseAnchor(reader: Reader): Anchor;
90
+ export declare function parseAnchorAt(reader: Reader, offset: number): Anchor | null;
91
+ export declare function parseMarkArray(reader: Reader): MarkArray;
92
+ export declare function parseCursivePos(reader: Reader, subtableOffsets: number[]): CursivePosSubtable[];
93
+ export declare function parseMarkBasePos(reader: Reader, subtableOffsets: number[]): MarkBasePosSubtable[];
94
+ export declare function parseMarkLigaturePos(reader: Reader, subtableOffsets: number[]): MarkLigaturePosSubtable[];
95
+ export declare function parseMarkMarkPos(reader: Reader, subtableOffsets: number[]): MarkMarkPosSubtable[];
@@ -0,0 +1,137 @@
1
+ import { type ClassDef } from "../../layout/structures/class-def.ts";
2
+ import { type Coverage } from "../../layout/structures/coverage.ts";
3
+ import { type DeviceOrVariationIndex } from "../../layout/structures/device.ts";
4
+ import { type FeatureList, type ScriptList } from "../../layout/structures/layout-common.ts";
5
+ import type { GlyphId, int16, uint16 } from "../../types.ts";
6
+ import type { Reader } from "../binary/reader.ts";
7
+ import { type ChainingContextPosLookup, type ContextPosLookup } from "./gpos-contextual.ts";
8
+ import { type CursivePosSubtable, type MarkBasePosSubtable, type MarkLigaturePosSubtable, type MarkMarkPosSubtable } from "./gpos-mark.ts";
9
+ /** GPOS lookup types */
10
+ export declare enum GposLookupType {
11
+ Single = 1,
12
+ Pair = 2,
13
+ Cursive = 3,
14
+ MarkToBase = 4,
15
+ MarkToLigature = 5,
16
+ MarkToMark = 6,
17
+ Context = 7,
18
+ ChainingContext = 8,
19
+ Extension = 9
20
+ }
21
+ /** Value record - positioning adjustments */
22
+ export interface ValueRecord {
23
+ xPlacement?: int16;
24
+ yPlacement?: int16;
25
+ xAdvance?: int16;
26
+ yAdvance?: int16;
27
+ xPlaDevice?: DeviceOrVariationIndex;
28
+ yPlaDevice?: DeviceOrVariationIndex;
29
+ xAdvDevice?: DeviceOrVariationIndex;
30
+ yAdvDevice?: DeviceOrVariationIndex;
31
+ }
32
+ /** Value format flags */
33
+ export declare const ValueFormat: {
34
+ readonly XPlacement: 1;
35
+ readonly YPlacement: 2;
36
+ readonly XAdvance: 4;
37
+ readonly YAdvance: 8;
38
+ readonly XPlaDevice: 16;
39
+ readonly YPlaDevice: 32;
40
+ readonly XAdvDevice: 64;
41
+ readonly YAdvDevice: 128;
42
+ };
43
+ /** Base interface for all GPOS lookups */
44
+ export interface GposLookup {
45
+ type: GposLookupType;
46
+ flag: uint16;
47
+ markFilteringSet?: uint16;
48
+ }
49
+ /** Single adjustment lookup (Type 1) */
50
+ export interface SinglePosLookup extends GposLookup {
51
+ type: GposLookupType.Single;
52
+ subtables: SinglePosSubtable[];
53
+ }
54
+ export interface SinglePosSubtable {
55
+ format: 1 | 2;
56
+ coverage: Coverage;
57
+ valueFormat: uint16;
58
+ value?: ValueRecord;
59
+ values?: ValueRecord[];
60
+ }
61
+ /** Pair adjustment lookup (Type 2) - kerning */
62
+ export interface PairPosLookup extends GposLookup {
63
+ type: GposLookupType.Pair;
64
+ subtables: PairPosSubtable[];
65
+ }
66
+ export type PairPosSubtable = PairPosFormat1 | PairPosFormat2;
67
+ export interface PairPosFormat1 {
68
+ format: 1;
69
+ coverage: Coverage;
70
+ valueFormat1: uint16;
71
+ valueFormat2: uint16;
72
+ pairSets: PairSet[];
73
+ }
74
+ export interface PairSet {
75
+ pairValueRecords: PairValueRecord[];
76
+ }
77
+ export interface PairValueRecord {
78
+ secondGlyph: GlyphId;
79
+ value1: ValueRecord;
80
+ value2: ValueRecord;
81
+ }
82
+ export interface PairPosFormat2 {
83
+ format: 2;
84
+ coverage: Coverage;
85
+ valueFormat1: uint16;
86
+ valueFormat2: uint16;
87
+ classDef1: ClassDef;
88
+ classDef2: ClassDef;
89
+ class1Count: uint16;
90
+ class2Count: uint16;
91
+ class1Records: Class1Record[];
92
+ }
93
+ export interface Class1Record {
94
+ class2Records: Class2Record[];
95
+ }
96
+ export interface Class2Record {
97
+ value1: ValueRecord;
98
+ value2: ValueRecord;
99
+ }
100
+ /** Cursive attachment lookup (Type 3) */
101
+ export interface CursivePosLookup extends GposLookup {
102
+ type: GposLookupType.Cursive;
103
+ subtables: CursivePosSubtable[];
104
+ }
105
+ /** Mark-to-base attachment lookup (Type 4) */
106
+ export interface MarkBasePosLookup extends GposLookup {
107
+ type: GposLookupType.MarkToBase;
108
+ subtables: MarkBasePosSubtable[];
109
+ }
110
+ /** Mark-to-ligature attachment lookup (Type 5) */
111
+ export interface MarkLigaturePosLookup extends GposLookup {
112
+ type: GposLookupType.MarkToLigature;
113
+ subtables: MarkLigaturePosSubtable[];
114
+ }
115
+ /** Mark-to-mark attachment lookup (Type 6) */
116
+ export interface MarkMarkPosLookup extends GposLookup {
117
+ type: GposLookupType.MarkToMark;
118
+ subtables: MarkMarkPosSubtable[];
119
+ }
120
+ /** Union of all GPOS lookup types */
121
+ export type AnyGposLookup = SinglePosLookup | PairPosLookup | CursivePosLookup | MarkBasePosLookup | MarkLigaturePosLookup | MarkMarkPosLookup | ContextPosLookup | ChainingContextPosLookup;
122
+ /** GPOS table */
123
+ export interface GposTable {
124
+ version: {
125
+ major: number;
126
+ minor: number;
127
+ };
128
+ scriptList: ScriptList;
129
+ featureList: FeatureList;
130
+ lookups: AnyGposLookup[];
131
+ }
132
+ export type { Anchor, MarkArray } from "./gpos-mark.ts";
133
+ export declare function parseGpos(reader: Reader): GposTable;
134
+ export declare function getKerning(lookup: PairPosLookup, firstGlyph: GlyphId, secondGlyph: GlyphId): {
135
+ xAdvance1: number;
136
+ xAdvance2: number;
137
+ } | null;
@@ -0,0 +1,88 @@
1
+ import { type ClassDef } from "../../layout/structures/class-def.ts";
2
+ import { type Coverage } from "../../layout/structures/coverage.ts";
3
+ import type { GlyphId, uint16 } from "../../types.ts";
4
+ import type { Reader } from "../binary/reader.ts";
5
+ import type { GsubLookup } from "./gsub.ts";
6
+ /** Sequence lookup record - applies a lookup at a position */
7
+ export interface SequenceLookupRecord {
8
+ sequenceIndex: uint16;
9
+ lookupListIndex: uint16;
10
+ }
11
+ /** Context substitution lookup (Type 5) */
12
+ export interface ContextSubstLookup extends GsubLookup {
13
+ type: 5;
14
+ subtables: ContextSubstSubtable[];
15
+ }
16
+ export type ContextSubstSubtable = ContextSubstFormat1 | ContextSubstFormat2 | ContextSubstFormat3;
17
+ /** Format 1: Simple glyph contexts */
18
+ export interface ContextSubstFormat1 {
19
+ format: 1;
20
+ coverage: Coverage;
21
+ ruleSets: (ContextRule[] | null)[];
22
+ }
23
+ export interface ContextRule {
24
+ glyphCount: uint16;
25
+ inputSequence: GlyphId[];
26
+ lookupRecords: SequenceLookupRecord[];
27
+ }
28
+ /** Format 2: Class-based contexts */
29
+ export interface ContextSubstFormat2 {
30
+ format: 2;
31
+ coverage: Coverage;
32
+ classDef: ClassDef;
33
+ classRuleSets: (ClassRule[] | null)[];
34
+ }
35
+ export interface ClassRule {
36
+ glyphCount: uint16;
37
+ inputClasses: uint16[];
38
+ lookupRecords: SequenceLookupRecord[];
39
+ }
40
+ /** Format 3: Coverage-based contexts */
41
+ export interface ContextSubstFormat3 {
42
+ format: 3;
43
+ coverages: Coverage[];
44
+ lookupRecords: SequenceLookupRecord[];
45
+ }
46
+ /** Chaining context substitution lookup (Type 6) */
47
+ export interface ChainingContextSubstLookup extends GsubLookup {
48
+ type: 6;
49
+ subtables: ChainingContextSubstSubtable[];
50
+ }
51
+ export type ChainingContextSubstSubtable = ChainingContextFormat1 | ChainingContextFormat2 | ChainingContextFormat3;
52
+ /** Format 1: Simple chaining context */
53
+ export interface ChainingContextFormat1 {
54
+ format: 1;
55
+ coverage: Coverage;
56
+ chainRuleSets: (ChainRule[] | null)[];
57
+ }
58
+ export interface ChainRule {
59
+ backtrackSequence: GlyphId[];
60
+ inputSequence: GlyphId[];
61
+ lookaheadSequence: GlyphId[];
62
+ lookupRecords: SequenceLookupRecord[];
63
+ }
64
+ /** Format 2: Class-based chaining context */
65
+ export interface ChainingContextFormat2 {
66
+ format: 2;
67
+ coverage: Coverage;
68
+ backtrackClassDef: ClassDef;
69
+ inputClassDef: ClassDef;
70
+ lookaheadClassDef: ClassDef;
71
+ chainClassRuleSets: (ChainClassRule[] | null)[];
72
+ }
73
+ export interface ChainClassRule {
74
+ backtrackClasses: uint16[];
75
+ inputClasses: uint16[];
76
+ lookaheadClasses: uint16[];
77
+ lookupRecords: SequenceLookupRecord[];
78
+ }
79
+ /** Format 3: Coverage-based chaining context */
80
+ export interface ChainingContextFormat3 {
81
+ format: 3;
82
+ backtrackCoverages: Coverage[];
83
+ inputCoverages: Coverage[];
84
+ lookaheadCoverages: Coverage[];
85
+ lookupRecords: SequenceLookupRecord[];
86
+ }
87
+ export declare function parseContextSubst(reader: Reader, subtableOffsets: number[]): ContextSubstSubtable[];
88
+ export declare function parseChainingContextSubst(reader: Reader, subtableOffsets: number[]): ChainingContextSubstSubtable[];