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.
- package/LICENSE +21 -0
- package/README.md +161 -0
- package/dist/aat/state-machine.d.ts +34 -0
- package/dist/buffer/glyph-buffer.d.ts +55 -0
- package/dist/buffer/unicode-buffer.d.ts +51 -0
- package/dist/font/binary/reader.d.ts +72 -0
- package/dist/font/face.d.ts +65 -0
- package/dist/font/font.d.ts +189 -0
- package/dist/font/tables/avar.d.ts +36 -0
- package/dist/font/tables/base.d.ts +79 -0
- package/dist/font/tables/cbdt.d.ts +120 -0
- package/dist/font/tables/cff-charstring.d.ts +16 -0
- package/dist/font/tables/cff.d.ts +93 -0
- package/dist/font/tables/cff2.d.ts +85 -0
- package/dist/font/tables/cmap.d.ts +81 -0
- package/dist/font/tables/colr.d.ts +278 -0
- package/dist/font/tables/cpal.d.ts +46 -0
- package/dist/font/tables/feat.d.ts +359 -0
- package/dist/font/tables/fvar.d.ts +77 -0
- package/dist/font/tables/gdef.d.ts +45 -0
- package/dist/font/tables/glyf.d.ts +118 -0
- package/dist/font/tables/gpos-contextual.d.ts +88 -0
- package/dist/font/tables/gpos-mark.d.ts +95 -0
- package/dist/font/tables/gpos.d.ts +137 -0
- package/dist/font/tables/gsub-contextual.d.ts +88 -0
- package/dist/font/tables/gsub.d.ts +107 -0
- package/dist/font/tables/gvar.d.ts +56 -0
- package/dist/font/tables/head.d.ts +47 -0
- package/dist/font/tables/hhea.d.ts +24 -0
- package/dist/font/tables/hmtx.d.ts +23 -0
- package/dist/font/tables/hvar.d.ts +77 -0
- package/dist/font/tables/jstf.d.ts +97 -0
- package/dist/font/tables/kern.d.ts +44 -0
- package/dist/font/tables/kerx.d.ts +108 -0
- package/dist/font/tables/loca.d.ts +31 -0
- package/dist/font/tables/math.d.ts +168 -0
- package/dist/font/tables/maxp.d.ts +27 -0
- package/dist/font/tables/morx.d.ts +142 -0
- package/dist/font/tables/mvar.d.ts +99 -0
- package/dist/font/tables/name.d.ts +75 -0
- package/dist/font/tables/os2.d.ts +102 -0
- package/dist/font/tables/post.d.ts +25 -0
- package/dist/font/tables/sbix.d.ts +65 -0
- package/dist/font/tables/sfnt.d.ts +20 -0
- package/dist/font/tables/stat.d.ts +115 -0
- package/dist/font/tables/svg.d.ts +40 -0
- package/dist/font/tables/trak.d.ts +43 -0
- package/dist/font/tables/vhea.d.ts +41 -0
- package/dist/font/tables/vmtx.d.ts +35 -0
- package/dist/font/tables/vorg.d.ts +33 -0
- package/dist/font/tables/vvar.d.ts +36 -0
- package/dist/index.d.ts +80 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +92 -0
- package/dist/index.test.d.ts +1 -0
- package/dist/layout/justify.d.ts +88 -0
- package/dist/layout/structures/class-def.d.ts +15 -0
- package/dist/layout/structures/coverage.d.ts +17 -0
- package/dist/layout/structures/device.d.ts +58 -0
- package/dist/layout/structures/feature-variations.d.ts +82 -0
- package/dist/layout/structures/layout-common.d.ts +77 -0
- package/dist/render/path.d.ts +136 -0
- package/dist/shaper/complex/arabic.d.ts +60 -0
- package/dist/shaper/complex/ethiopic.d.ts +70 -0
- package/dist/shaper/complex/georgian.d.ts +69 -0
- package/dist/shaper/complex/hangul.d.ts +64 -0
- package/dist/shaper/complex/hebrew.d.ts +28 -0
- package/dist/shaper/complex/indic.d.ts +117 -0
- package/dist/shaper/complex/khmer.d.ts +48 -0
- package/dist/shaper/complex/mongolian.d.ts +89 -0
- package/dist/shaper/complex/myanmar.d.ts +47 -0
- package/dist/shaper/complex/syriac.d.ts +80 -0
- package/dist/shaper/complex/thai-lao.d.ts +42 -0
- package/dist/shaper/complex/tibetan.d.ts +57 -0
- package/dist/shaper/complex/use.d.ts +80 -0
- package/dist/shaper/fallback.d.ts +16 -0
- package/dist/shaper/features.d.ts +189 -0
- package/dist/shaper/shape-plan.d.ts +29 -0
- package/dist/shaper/shaper.d.ts +18 -0
- package/dist/types.d.ts +153 -0
- package/dist/typeshaper.js +7 -0
- package/dist/unicode/bidi/brackets.d.ts +7 -0
- package/dist/unicode/bidi/brackets.data.d.ts +5 -0
- package/dist/unicode/bidi/char-types.d.ts +19 -0
- package/dist/unicode/bidi/char-types.data.d.ts +25 -0
- package/dist/unicode/bidi/embedding-levels.d.ts +18 -0
- package/dist/unicode/bidi/index.d.ts +9 -0
- package/dist/unicode/bidi/mirroring.d.ts +10 -0
- package/dist/unicode/bidi/mirroring.data.d.ts +2 -0
- package/dist/unicode/bidi/parse-character-map.d.ts +8 -0
- package/dist/unicode/bidi/reordering.d.ts +18 -0
- package/dist/unicode/bidi.d.ts +93 -0
- package/dist/unicode/line-break.d.ts +113 -0
- package/dist/unicode/normalize.d.ts +36 -0
- package/dist/unicode/script.d.ts +215 -0
- package/dist/unicode/segmentation.d.ts +104 -0
- package/package.json +33 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { type Coverage } from "../../layout/structures/coverage.ts";
|
|
2
|
+
import { type DeviceOrVariationIndex } from "../../layout/structures/device.ts";
|
|
3
|
+
import type { GlyphId, int16, uint16 } from "../../types.ts";
|
|
4
|
+
import type { Reader } from "../binary/reader.ts";
|
|
5
|
+
/**
|
|
6
|
+
* MATH table - Mathematical typesetting data
|
|
7
|
+
* Provides metrics and glyph information for math layout
|
|
8
|
+
*/
|
|
9
|
+
/** MathValueRecord - value with optional device correction */
|
|
10
|
+
export interface MathValueRecord {
|
|
11
|
+
value: int16;
|
|
12
|
+
device: DeviceOrVariationIndex | null;
|
|
13
|
+
}
|
|
14
|
+
/** MathConstants - global math constants */
|
|
15
|
+
export interface MathConstants {
|
|
16
|
+
scriptPercentScaleDown: int16;
|
|
17
|
+
scriptScriptPercentScaleDown: int16;
|
|
18
|
+
delimitedSubFormulaMinHeight: uint16;
|
|
19
|
+
displayOperatorMinHeight: uint16;
|
|
20
|
+
mathLeading: MathValueRecord;
|
|
21
|
+
axisHeight: MathValueRecord;
|
|
22
|
+
accentBaseHeight: MathValueRecord;
|
|
23
|
+
flattenedAccentBaseHeight: MathValueRecord;
|
|
24
|
+
subscriptShiftDown: MathValueRecord;
|
|
25
|
+
subscriptTopMax: MathValueRecord;
|
|
26
|
+
subscriptBaselineDropMin: MathValueRecord;
|
|
27
|
+
superscriptShiftUp: MathValueRecord;
|
|
28
|
+
superscriptShiftUpCramped: MathValueRecord;
|
|
29
|
+
superscriptBottomMin: MathValueRecord;
|
|
30
|
+
superscriptBaselineDropMax: MathValueRecord;
|
|
31
|
+
subSuperscriptGapMin: MathValueRecord;
|
|
32
|
+
superscriptBottomMaxWithSubscript: MathValueRecord;
|
|
33
|
+
spaceAfterScript: MathValueRecord;
|
|
34
|
+
upperLimitGapMin: MathValueRecord;
|
|
35
|
+
upperLimitBaselineRiseMin: MathValueRecord;
|
|
36
|
+
lowerLimitGapMin: MathValueRecord;
|
|
37
|
+
lowerLimitBaselineDropMin: MathValueRecord;
|
|
38
|
+
stackTopShiftUp: MathValueRecord;
|
|
39
|
+
stackTopDisplayStyleShiftUp: MathValueRecord;
|
|
40
|
+
stackBottomShiftDown: MathValueRecord;
|
|
41
|
+
stackBottomDisplayStyleShiftDown: MathValueRecord;
|
|
42
|
+
stackGapMin: MathValueRecord;
|
|
43
|
+
stackDisplayStyleGapMin: MathValueRecord;
|
|
44
|
+
stretchStackTopShiftUp: MathValueRecord;
|
|
45
|
+
stretchStackBottomShiftDown: MathValueRecord;
|
|
46
|
+
stretchStackGapAboveMin: MathValueRecord;
|
|
47
|
+
stretchStackGapBelowMin: MathValueRecord;
|
|
48
|
+
fractionNumeratorShiftUp: MathValueRecord;
|
|
49
|
+
fractionNumeratorDisplayStyleShiftUp: MathValueRecord;
|
|
50
|
+
fractionDenominatorShiftDown: MathValueRecord;
|
|
51
|
+
fractionDenominatorDisplayStyleShiftDown: MathValueRecord;
|
|
52
|
+
fractionNumeratorGapMin: MathValueRecord;
|
|
53
|
+
fractionNumDisplayStyleGapMin: MathValueRecord;
|
|
54
|
+
fractionRuleThickness: MathValueRecord;
|
|
55
|
+
fractionDenominatorGapMin: MathValueRecord;
|
|
56
|
+
fractionDenomDisplayStyleGapMin: MathValueRecord;
|
|
57
|
+
skewedFractionHorizontalGap: MathValueRecord;
|
|
58
|
+
skewedFractionVerticalGap: MathValueRecord;
|
|
59
|
+
overbarVerticalGap: MathValueRecord;
|
|
60
|
+
overbarRuleThickness: MathValueRecord;
|
|
61
|
+
overbarExtraAscender: MathValueRecord;
|
|
62
|
+
underbarVerticalGap: MathValueRecord;
|
|
63
|
+
underbarRuleThickness: MathValueRecord;
|
|
64
|
+
underbarExtraDescender: MathValueRecord;
|
|
65
|
+
radicalVerticalGap: MathValueRecord;
|
|
66
|
+
radicalDisplayStyleVerticalGap: MathValueRecord;
|
|
67
|
+
radicalRuleThickness: MathValueRecord;
|
|
68
|
+
radicalExtraAscender: MathValueRecord;
|
|
69
|
+
radicalKernBeforeDegree: MathValueRecord;
|
|
70
|
+
radicalKernAfterDegree: MathValueRecord;
|
|
71
|
+
radicalDegreeBottomRaisePercent: int16;
|
|
72
|
+
}
|
|
73
|
+
/** Italic correction info */
|
|
74
|
+
export interface MathItalicsCorrection {
|
|
75
|
+
coverage: Coverage;
|
|
76
|
+
values: MathValueRecord[];
|
|
77
|
+
}
|
|
78
|
+
/** Top accent attachment */
|
|
79
|
+
export interface MathTopAccentAttachment {
|
|
80
|
+
coverage: Coverage;
|
|
81
|
+
values: MathValueRecord[];
|
|
82
|
+
}
|
|
83
|
+
/** Extended shape coverage */
|
|
84
|
+
export interface ExtendedShapeCoverage {
|
|
85
|
+
coverage: Coverage;
|
|
86
|
+
}
|
|
87
|
+
/** Math kern record for corner kerns */
|
|
88
|
+
export interface MathKernRecord {
|
|
89
|
+
correctionHeights: MathValueRecord[];
|
|
90
|
+
kernValues: MathValueRecord[];
|
|
91
|
+
}
|
|
92
|
+
/** Math kern info for a glyph */
|
|
93
|
+
export interface MathKernInfo {
|
|
94
|
+
topRight: MathKernRecord | null;
|
|
95
|
+
topLeft: MathKernRecord | null;
|
|
96
|
+
bottomRight: MathKernRecord | null;
|
|
97
|
+
bottomLeft: MathKernRecord | null;
|
|
98
|
+
}
|
|
99
|
+
/** Math kern info table */
|
|
100
|
+
export interface MathKernInfoTable {
|
|
101
|
+
coverage: Coverage;
|
|
102
|
+
kernInfo: MathKernInfo[];
|
|
103
|
+
}
|
|
104
|
+
/** MathGlyphInfo - per-glyph math info */
|
|
105
|
+
export interface MathGlyphInfo {
|
|
106
|
+
italicsCorrection: MathItalicsCorrection | null;
|
|
107
|
+
topAccentAttachment: MathTopAccentAttachment | null;
|
|
108
|
+
extendedShapeCoverage: ExtendedShapeCoverage | null;
|
|
109
|
+
kernInfo: MathKernInfoTable | null;
|
|
110
|
+
}
|
|
111
|
+
/** Glyph part record for assembly */
|
|
112
|
+
export interface GlyphPartRecord {
|
|
113
|
+
glyphId: GlyphId;
|
|
114
|
+
startConnectorLength: uint16;
|
|
115
|
+
endConnectorLength: uint16;
|
|
116
|
+
fullAdvance: uint16;
|
|
117
|
+
partFlags: uint16;
|
|
118
|
+
}
|
|
119
|
+
/** Glyph assembly */
|
|
120
|
+
export interface GlyphAssembly {
|
|
121
|
+
italicsCorrection: MathValueRecord;
|
|
122
|
+
parts: GlyphPartRecord[];
|
|
123
|
+
}
|
|
124
|
+
/** Math glyph construction */
|
|
125
|
+
export interface MathGlyphConstruction {
|
|
126
|
+
glyphAssembly: GlyphAssembly | null;
|
|
127
|
+
variants: Array<{
|
|
128
|
+
variantGlyph: GlyphId;
|
|
129
|
+
advanceMeasurement: uint16;
|
|
130
|
+
}>;
|
|
131
|
+
}
|
|
132
|
+
/** MathVariants - glyph variants and construction */
|
|
133
|
+
export interface MathVariants {
|
|
134
|
+
minConnectorOverlap: uint16;
|
|
135
|
+
vertGlyphCoverage: Coverage | null;
|
|
136
|
+
horizGlyphCoverage: Coverage | null;
|
|
137
|
+
vertGlyphConstruction: MathGlyphConstruction[];
|
|
138
|
+
horizGlyphConstruction: MathGlyphConstruction[];
|
|
139
|
+
}
|
|
140
|
+
/** MATH table */
|
|
141
|
+
export interface MathTable {
|
|
142
|
+
majorVersion: uint16;
|
|
143
|
+
minorVersion: uint16;
|
|
144
|
+
constants: MathConstants | null;
|
|
145
|
+
glyphInfo: MathGlyphInfo | null;
|
|
146
|
+
variants: MathVariants | null;
|
|
147
|
+
}
|
|
148
|
+
export declare function parseMath(reader: Reader): MathTable;
|
|
149
|
+
/** Get italic correction for a glyph */
|
|
150
|
+
export declare function getItalicsCorrection(math: MathTable, glyphId: GlyphId): MathValueRecord | null;
|
|
151
|
+
/** Get top accent attachment for a glyph */
|
|
152
|
+
export declare function getTopAccentAttachment(math: MathTable, glyphId: GlyphId): MathValueRecord | null;
|
|
153
|
+
/** Check if glyph is an extended shape */
|
|
154
|
+
export declare function isExtendedShape(math: MathTable, glyphId: GlyphId): boolean;
|
|
155
|
+
/** Get vertical glyph variants */
|
|
156
|
+
export declare function getVerticalVariants(math: MathTable, glyphId: GlyphId): Array<{
|
|
157
|
+
variantGlyph: GlyphId;
|
|
158
|
+
advanceMeasurement: uint16;
|
|
159
|
+
}> | null;
|
|
160
|
+
/** Get horizontal glyph variants */
|
|
161
|
+
export declare function getHorizontalVariants(math: MathTable, glyphId: GlyphId): Array<{
|
|
162
|
+
variantGlyph: GlyphId;
|
|
163
|
+
advanceMeasurement: uint16;
|
|
164
|
+
}> | null;
|
|
165
|
+
/** Get vertical glyph assembly */
|
|
166
|
+
export declare function getVerticalAssembly(math: MathTable, glyphId: GlyphId): GlyphAssembly | null;
|
|
167
|
+
/** Get horizontal glyph assembly */
|
|
168
|
+
export declare function getHorizontalAssembly(math: MathTable, glyphId: GlyphId): GlyphAssembly | null;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { uint16 } from "../../types.ts";
|
|
2
|
+
import type { Reader } from "../binary/reader.ts";
|
|
3
|
+
/** Maximum profile table (version 0.5 - CFF) */
|
|
4
|
+
export interface MaxpTable05 {
|
|
5
|
+
version: 0x00005000;
|
|
6
|
+
numGlyphs: uint16;
|
|
7
|
+
}
|
|
8
|
+
/** Maximum profile table (version 1.0 - TrueType) */
|
|
9
|
+
export interface MaxpTable10 {
|
|
10
|
+
version: 0x00010000;
|
|
11
|
+
numGlyphs: uint16;
|
|
12
|
+
maxPoints: uint16;
|
|
13
|
+
maxContours: uint16;
|
|
14
|
+
maxCompositePoints: uint16;
|
|
15
|
+
maxCompositeContours: uint16;
|
|
16
|
+
maxZones: uint16;
|
|
17
|
+
maxTwilightPoints: uint16;
|
|
18
|
+
maxStorage: uint16;
|
|
19
|
+
maxFunctionDefs: uint16;
|
|
20
|
+
maxInstructionDefs: uint16;
|
|
21
|
+
maxStackElements: uint16;
|
|
22
|
+
maxSizeOfInstructions: uint16;
|
|
23
|
+
maxComponentElements: uint16;
|
|
24
|
+
maxComponentDepth: uint16;
|
|
25
|
+
}
|
|
26
|
+
export type MaxpTable = MaxpTable05 | MaxpTable10;
|
|
27
|
+
export declare function parseMaxp(reader: Reader): MaxpTable;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { GlyphId, uint16, uint32 } from "../../types.ts";
|
|
2
|
+
import type { Reader } from "../binary/reader.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Extended Glyph Metamorphosis table (morx)
|
|
5
|
+
* Apple Advanced Typography substitution
|
|
6
|
+
*/
|
|
7
|
+
export interface MorxTable {
|
|
8
|
+
version: number;
|
|
9
|
+
chains: MorxChain[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Feature chain in morx
|
|
13
|
+
*/
|
|
14
|
+
export interface MorxChain {
|
|
15
|
+
defaultFlags: uint32;
|
|
16
|
+
features: MorxFeature[];
|
|
17
|
+
subtables: MorxSubtable[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Feature entry
|
|
21
|
+
*/
|
|
22
|
+
export interface MorxFeature {
|
|
23
|
+
featureType: uint16;
|
|
24
|
+
featureSetting: uint16;
|
|
25
|
+
enableFlags: uint32;
|
|
26
|
+
disableFlags: uint32;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Subtable types
|
|
30
|
+
*/
|
|
31
|
+
export declare enum MorxSubtableType {
|
|
32
|
+
Rearrangement = 0,
|
|
33
|
+
Contextual = 1,
|
|
34
|
+
Ligature = 2,
|
|
35
|
+
NonContextual = 4,
|
|
36
|
+
Insertion = 5
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Base subtable
|
|
40
|
+
*/
|
|
41
|
+
export interface MorxSubtableBase {
|
|
42
|
+
type: MorxSubtableType;
|
|
43
|
+
coverage: MorxCoverage;
|
|
44
|
+
subFeatureFlags: uint32;
|
|
45
|
+
}
|
|
46
|
+
export interface MorxCoverage {
|
|
47
|
+
vertical: boolean;
|
|
48
|
+
descending: boolean;
|
|
49
|
+
logical: boolean;
|
|
50
|
+
}
|
|
51
|
+
export type MorxSubtable = MorxRearrangementSubtable | MorxContextualSubtable | MorxLigatureSubtable | MorxNonContextualSubtable | MorxInsertionSubtable;
|
|
52
|
+
/**
|
|
53
|
+
* Type 0: Rearrangement (reorders glyphs)
|
|
54
|
+
*/
|
|
55
|
+
export interface MorxRearrangementSubtable extends MorxSubtableBase {
|
|
56
|
+
type: MorxSubtableType.Rearrangement;
|
|
57
|
+
stateTable: StateTable<RearrangementEntry>;
|
|
58
|
+
}
|
|
59
|
+
export interface RearrangementEntry {
|
|
60
|
+
newState: uint16;
|
|
61
|
+
flags: uint16;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Type 1: Contextual substitution
|
|
65
|
+
*/
|
|
66
|
+
export interface MorxContextualSubtable extends MorxSubtableBase {
|
|
67
|
+
type: MorxSubtableType.Contextual;
|
|
68
|
+
stateTable: StateTable<ContextualEntry>;
|
|
69
|
+
substitutionTable: Map<GlyphId, GlyphId>[];
|
|
70
|
+
}
|
|
71
|
+
export interface ContextualEntry {
|
|
72
|
+
newState: uint16;
|
|
73
|
+
flags: uint16;
|
|
74
|
+
markIndex: uint16;
|
|
75
|
+
currentIndex: uint16;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Type 2: Ligature
|
|
79
|
+
*/
|
|
80
|
+
export interface MorxLigatureSubtable extends MorxSubtableBase {
|
|
81
|
+
type: MorxSubtableType.Ligature;
|
|
82
|
+
stateTable: StateTable<LigatureEntry>;
|
|
83
|
+
ligatureActions: uint32[];
|
|
84
|
+
components: uint16[];
|
|
85
|
+
ligatures: GlyphId[];
|
|
86
|
+
}
|
|
87
|
+
export interface LigatureEntry {
|
|
88
|
+
newState: uint16;
|
|
89
|
+
flags: uint16;
|
|
90
|
+
ligActionIndex: uint16;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Type 4: Non-contextual (simple substitution)
|
|
94
|
+
*/
|
|
95
|
+
export interface MorxNonContextualSubtable extends MorxSubtableBase {
|
|
96
|
+
type: MorxSubtableType.NonContextual;
|
|
97
|
+
lookupTable: LookupTable;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Type 5: Insertion
|
|
101
|
+
*/
|
|
102
|
+
export interface MorxInsertionSubtable extends MorxSubtableBase {
|
|
103
|
+
type: MorxSubtableType.Insertion;
|
|
104
|
+
stateTable: StateTable<InsertionEntry>;
|
|
105
|
+
insertionGlyphs: GlyphId[];
|
|
106
|
+
}
|
|
107
|
+
export interface InsertionEntry {
|
|
108
|
+
newState: uint16;
|
|
109
|
+
flags: uint16;
|
|
110
|
+
currentInsertIndex: uint16;
|
|
111
|
+
markedInsertIndex: uint16;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* State table for state machine processing
|
|
115
|
+
*/
|
|
116
|
+
export interface StateTable<E> {
|
|
117
|
+
nClasses: uint32;
|
|
118
|
+
classTable: ClassTable;
|
|
119
|
+
stateArray: E[][];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Class lookup table
|
|
123
|
+
*/
|
|
124
|
+
export interface ClassTable {
|
|
125
|
+
format: number;
|
|
126
|
+
classArray: number[];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Lookup table for substitutions
|
|
130
|
+
*/
|
|
131
|
+
export interface LookupTable {
|
|
132
|
+
format: number;
|
|
133
|
+
mapping: Map<GlyphId, GlyphId>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Parse morx table
|
|
137
|
+
*/
|
|
138
|
+
export declare function parseMorx(reader: Reader): MorxTable;
|
|
139
|
+
/**
|
|
140
|
+
* Apply non-contextual substitution
|
|
141
|
+
*/
|
|
142
|
+
export declare function applyNonContextual(subtable: MorxNonContextualSubtable, glyphId: GlyphId): GlyphId | null;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { Tag } from "../../types.ts";
|
|
2
|
+
import type { Reader } from "../binary/reader.ts";
|
|
3
|
+
import { type ItemVariationStore } from "./hvar.ts";
|
|
4
|
+
/**
|
|
5
|
+
* Metrics Variations table (MVAR)
|
|
6
|
+
* Provides variations for global font metrics
|
|
7
|
+
*/
|
|
8
|
+
export interface MvarTable {
|
|
9
|
+
majorVersion: number;
|
|
10
|
+
minorVersion: number;
|
|
11
|
+
itemVariationStore: ItemVariationStore;
|
|
12
|
+
valueRecords: MvarValueRecord[];
|
|
13
|
+
}
|
|
14
|
+
export interface MvarValueRecord {
|
|
15
|
+
valueTag: Tag;
|
|
16
|
+
deltaSetOuterIndex: number;
|
|
17
|
+
deltaSetInnerIndex: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Common MVAR value tags
|
|
21
|
+
*/
|
|
22
|
+
export declare const MvarTags: {
|
|
23
|
+
readonly hasc: number;
|
|
24
|
+
readonly hdsc: number;
|
|
25
|
+
readonly hlgp: number;
|
|
26
|
+
readonly hcla: number;
|
|
27
|
+
readonly hcld: number;
|
|
28
|
+
readonly hcof: number;
|
|
29
|
+
readonly hcrn: number;
|
|
30
|
+
readonly hcrs: number;
|
|
31
|
+
readonly vasc: number;
|
|
32
|
+
readonly vdsc: number;
|
|
33
|
+
readonly vlgp: number;
|
|
34
|
+
readonly vcof: number;
|
|
35
|
+
readonly vcrn: number;
|
|
36
|
+
readonly vcrs: number;
|
|
37
|
+
readonly xhgt: number;
|
|
38
|
+
readonly cpht: number;
|
|
39
|
+
readonly sbxs: number;
|
|
40
|
+
readonly sbys: number;
|
|
41
|
+
readonly sbxo: number;
|
|
42
|
+
readonly sbyo: number;
|
|
43
|
+
readonly spxs: number;
|
|
44
|
+
readonly spys: number;
|
|
45
|
+
readonly spxo: number;
|
|
46
|
+
readonly spyo: number;
|
|
47
|
+
readonly strs: number;
|
|
48
|
+
readonly stro: number;
|
|
49
|
+
readonly undo: number;
|
|
50
|
+
readonly unds: number;
|
|
51
|
+
readonly gsp0: number;
|
|
52
|
+
readonly gsp1: number;
|
|
53
|
+
readonly gsp2: number;
|
|
54
|
+
readonly gsp3: number;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Parse MVAR table
|
|
58
|
+
*/
|
|
59
|
+
export declare function parseMvar(reader: Reader): MvarTable;
|
|
60
|
+
/**
|
|
61
|
+
* Get metric delta by tag
|
|
62
|
+
*/
|
|
63
|
+
export declare function getMetricDelta(mvar: MvarTable, valueTag: Tag, coords: number[]): number;
|
|
64
|
+
/**
|
|
65
|
+
* Get horizontal ascender delta
|
|
66
|
+
*/
|
|
67
|
+
export declare function getHAscenderDelta(mvar: MvarTable, coords: number[]): number;
|
|
68
|
+
/**
|
|
69
|
+
* Get horizontal descender delta
|
|
70
|
+
*/
|
|
71
|
+
export declare function getHDescenderDelta(mvar: MvarTable, coords: number[]): number;
|
|
72
|
+
/**
|
|
73
|
+
* Get horizontal line gap delta
|
|
74
|
+
*/
|
|
75
|
+
export declare function getHLineGapDelta(mvar: MvarTable, coords: number[]): number;
|
|
76
|
+
/**
|
|
77
|
+
* Get x-height delta
|
|
78
|
+
*/
|
|
79
|
+
export declare function getXHeightDelta(mvar: MvarTable, coords: number[]): number;
|
|
80
|
+
/**
|
|
81
|
+
* Get cap height delta
|
|
82
|
+
*/
|
|
83
|
+
export declare function getCapHeightDelta(mvar: MvarTable, coords: number[]): number;
|
|
84
|
+
/**
|
|
85
|
+
* Get underline offset delta
|
|
86
|
+
*/
|
|
87
|
+
export declare function getUnderlineOffsetDelta(mvar: MvarTable, coords: number[]): number;
|
|
88
|
+
/**
|
|
89
|
+
* Get underline size delta
|
|
90
|
+
*/
|
|
91
|
+
export declare function getUnderlineSizeDelta(mvar: MvarTable, coords: number[]): number;
|
|
92
|
+
/**
|
|
93
|
+
* Get strikeout offset delta
|
|
94
|
+
*/
|
|
95
|
+
export declare function getStrikeoutOffsetDelta(mvar: MvarTable, coords: number[]): number;
|
|
96
|
+
/**
|
|
97
|
+
* Get strikeout size delta
|
|
98
|
+
*/
|
|
99
|
+
export declare function getStrikeoutSizeDelta(mvar: MvarTable, coords: number[]): number;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { uint16 } from "../../types.ts";
|
|
2
|
+
import type { Reader } from "../binary/reader.ts";
|
|
3
|
+
/** Name IDs */
|
|
4
|
+
export declare const NameId: {
|
|
5
|
+
readonly Copyright: 0;
|
|
6
|
+
readonly FontFamily: 1;
|
|
7
|
+
readonly FontSubfamily: 2;
|
|
8
|
+
readonly UniqueID: 3;
|
|
9
|
+
readonly FullName: 4;
|
|
10
|
+
readonly Version: 5;
|
|
11
|
+
readonly PostScriptName: 6;
|
|
12
|
+
readonly Trademark: 7;
|
|
13
|
+
readonly Manufacturer: 8;
|
|
14
|
+
readonly Designer: 9;
|
|
15
|
+
readonly Description: 10;
|
|
16
|
+
readonly ManufacturerURL: 11;
|
|
17
|
+
readonly DesignerURL: 12;
|
|
18
|
+
readonly License: 13;
|
|
19
|
+
readonly LicenseURL: 14;
|
|
20
|
+
readonly Reserved: 15;
|
|
21
|
+
readonly TypographicFamily: 16;
|
|
22
|
+
readonly TypographicSubfamily: 17;
|
|
23
|
+
readonly CompatibleFullName: 18;
|
|
24
|
+
readonly SampleText: 19;
|
|
25
|
+
readonly PostScriptCIDFindfontName: 20;
|
|
26
|
+
readonly WWSFamily: 21;
|
|
27
|
+
readonly WWSSubfamily: 22;
|
|
28
|
+
readonly LightBackgroundPalette: 23;
|
|
29
|
+
readonly DarkBackgroundPalette: 24;
|
|
30
|
+
readonly VariationsPostScriptNamePrefix: 25;
|
|
31
|
+
};
|
|
32
|
+
/** Platform IDs */
|
|
33
|
+
export declare const PlatformId: {
|
|
34
|
+
readonly Unicode: 0;
|
|
35
|
+
readonly Macintosh: 1;
|
|
36
|
+
readonly Reserved: 2;
|
|
37
|
+
readonly Windows: 3;
|
|
38
|
+
};
|
|
39
|
+
/** Windows encoding IDs */
|
|
40
|
+
export declare const WindowsEncodingId: {
|
|
41
|
+
readonly Symbol: 0;
|
|
42
|
+
readonly UnicodeBMP: 1;
|
|
43
|
+
readonly ShiftJIS: 2;
|
|
44
|
+
readonly PRC: 3;
|
|
45
|
+
readonly Big5: 4;
|
|
46
|
+
readonly Wansung: 5;
|
|
47
|
+
readonly Johab: 6;
|
|
48
|
+
readonly UnicodeFullRepertoire: 10;
|
|
49
|
+
};
|
|
50
|
+
/** A single name record */
|
|
51
|
+
export interface NameRecord {
|
|
52
|
+
platformId: uint16;
|
|
53
|
+
encodingId: uint16;
|
|
54
|
+
languageId: uint16;
|
|
55
|
+
nameId: uint16;
|
|
56
|
+
value: string;
|
|
57
|
+
}
|
|
58
|
+
/** Name table */
|
|
59
|
+
export interface NameTable {
|
|
60
|
+
format: uint16;
|
|
61
|
+
records: NameRecord[];
|
|
62
|
+
}
|
|
63
|
+
export declare function parseName(reader: Reader): NameTable;
|
|
64
|
+
/** Get a specific name by ID, preferring Windows Unicode */
|
|
65
|
+
export declare function getNameById(table: NameTable, nameId: number, languageId?: number): string | null;
|
|
66
|
+
/** Get font family name */
|
|
67
|
+
export declare function getFontFamily(table: NameTable): string | null;
|
|
68
|
+
/** Get font subfamily (style) */
|
|
69
|
+
export declare function getFontSubfamily(table: NameTable): string | null;
|
|
70
|
+
/** Get full font name */
|
|
71
|
+
export declare function getFullName(table: NameTable): string | null;
|
|
72
|
+
/** Get PostScript name */
|
|
73
|
+
export declare function getPostScriptName(table: NameTable): string | null;
|
|
74
|
+
/** Get version string */
|
|
75
|
+
export declare function getVersion(table: NameTable): string | null;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { int16, uint8, uint16, uint32 } from "../../types.ts";
|
|
2
|
+
import type { Reader } from "../binary/reader.ts";
|
|
3
|
+
/**
|
|
4
|
+
* OS/2 table - Font metrics and classification
|
|
5
|
+
* Contains Windows-specific metrics and font embedding information
|
|
6
|
+
*/
|
|
7
|
+
export interface Os2Table {
|
|
8
|
+
version: uint16;
|
|
9
|
+
xAvgCharWidth: int16;
|
|
10
|
+
usWeightClass: uint16;
|
|
11
|
+
usWidthClass: uint16;
|
|
12
|
+
fsType: uint16;
|
|
13
|
+
ySubscriptXSize: int16;
|
|
14
|
+
ySubscriptYSize: int16;
|
|
15
|
+
ySubscriptXOffset: int16;
|
|
16
|
+
ySubscriptYOffset: int16;
|
|
17
|
+
ySuperscriptXSize: int16;
|
|
18
|
+
ySuperscriptYSize: int16;
|
|
19
|
+
ySuperscriptXOffset: int16;
|
|
20
|
+
ySuperscriptYOffset: int16;
|
|
21
|
+
yStrikeoutSize: int16;
|
|
22
|
+
yStrikeoutPosition: int16;
|
|
23
|
+
sFamilyClass: int16;
|
|
24
|
+
panose: uint8[];
|
|
25
|
+
ulUnicodeRange1: uint32;
|
|
26
|
+
ulUnicodeRange2: uint32;
|
|
27
|
+
ulUnicodeRange3: uint32;
|
|
28
|
+
ulUnicodeRange4: uint32;
|
|
29
|
+
achVendID: string;
|
|
30
|
+
fsSelection: uint16;
|
|
31
|
+
usFirstCharIndex: uint16;
|
|
32
|
+
usLastCharIndex: uint16;
|
|
33
|
+
sTypoAscender: int16;
|
|
34
|
+
sTypoDescender: int16;
|
|
35
|
+
sTypoLineGap: int16;
|
|
36
|
+
usWinAscent: uint16;
|
|
37
|
+
usWinDescent: uint16;
|
|
38
|
+
ulCodePageRange1?: uint32;
|
|
39
|
+
ulCodePageRange2?: uint32;
|
|
40
|
+
sxHeight?: int16;
|
|
41
|
+
sCapHeight?: int16;
|
|
42
|
+
usDefaultChar?: uint16;
|
|
43
|
+
usBreakChar?: uint16;
|
|
44
|
+
usMaxContext?: uint16;
|
|
45
|
+
usLowerOpticalPointSize?: uint16;
|
|
46
|
+
usUpperOpticalPointSize?: uint16;
|
|
47
|
+
}
|
|
48
|
+
/** Weight class constants */
|
|
49
|
+
export declare const WeightClass: {
|
|
50
|
+
readonly Thin: 100;
|
|
51
|
+
readonly ExtraLight: 200;
|
|
52
|
+
readonly Light: 300;
|
|
53
|
+
readonly Normal: 400;
|
|
54
|
+
readonly Medium: 500;
|
|
55
|
+
readonly SemiBold: 600;
|
|
56
|
+
readonly Bold: 700;
|
|
57
|
+
readonly ExtraBold: 800;
|
|
58
|
+
readonly Black: 900;
|
|
59
|
+
};
|
|
60
|
+
/** Width class constants */
|
|
61
|
+
export declare const WidthClass: {
|
|
62
|
+
readonly UltraCondensed: 1;
|
|
63
|
+
readonly ExtraCondensed: 2;
|
|
64
|
+
readonly Condensed: 3;
|
|
65
|
+
readonly SemiCondensed: 4;
|
|
66
|
+
readonly Normal: 5;
|
|
67
|
+
readonly SemiExpanded: 6;
|
|
68
|
+
readonly Expanded: 7;
|
|
69
|
+
readonly ExtraExpanded: 8;
|
|
70
|
+
readonly UltraExpanded: 9;
|
|
71
|
+
};
|
|
72
|
+
/** Font selection flags (fsSelection) */
|
|
73
|
+
export declare const FsSelection: {
|
|
74
|
+
readonly Italic: 1;
|
|
75
|
+
readonly Underscore: 2;
|
|
76
|
+
readonly Negative: 4;
|
|
77
|
+
readonly Outlined: 8;
|
|
78
|
+
readonly Strikeout: 16;
|
|
79
|
+
readonly Bold: 32;
|
|
80
|
+
readonly Regular: 64;
|
|
81
|
+
readonly UseTypoMetrics: 128;
|
|
82
|
+
readonly WWS: 256;
|
|
83
|
+
readonly Oblique: 512;
|
|
84
|
+
};
|
|
85
|
+
/** Font embedding permissions (fsType) */
|
|
86
|
+
export declare const FsType: {
|
|
87
|
+
readonly InstallableEmbedding: 0;
|
|
88
|
+
readonly RestrictedLicense: 2;
|
|
89
|
+
readonly PreviewAndPrint: 4;
|
|
90
|
+
readonly Editable: 8;
|
|
91
|
+
readonly NoSubsetting: 256;
|
|
92
|
+
readonly BitmapOnly: 512;
|
|
93
|
+
};
|
|
94
|
+
export declare function parseOs2(reader: Reader): Os2Table;
|
|
95
|
+
/** Check if font is italic */
|
|
96
|
+
export declare function isItalic(os2: Os2Table): boolean;
|
|
97
|
+
/** Check if font is bold */
|
|
98
|
+
export declare function isBold(os2: Os2Table): boolean;
|
|
99
|
+
/** Check if USE_TYPO_METRICS flag is set */
|
|
100
|
+
export declare function useTypoMetrics(os2: Os2Table): boolean;
|
|
101
|
+
/** Get embedding permission level */
|
|
102
|
+
export declare function getEmbeddingPermission(os2: Os2Table): "installable" | "restricted" | "preview" | "editable";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { int16, uint16, uint32 } from "../../types.ts";
|
|
2
|
+
import type { Reader } from "../binary/reader.ts";
|
|
3
|
+
/**
|
|
4
|
+
* post table - PostScript font information
|
|
5
|
+
* Contains additional PostScript info like glyph names and italic angle
|
|
6
|
+
*/
|
|
7
|
+
export interface PostTable {
|
|
8
|
+
version: number;
|
|
9
|
+
italicAngle: number;
|
|
10
|
+
underlinePosition: int16;
|
|
11
|
+
underlineThickness: int16;
|
|
12
|
+
isFixedPitch: uint32;
|
|
13
|
+
minMemType42: uint32;
|
|
14
|
+
maxMemType42: uint32;
|
|
15
|
+
minMemType1: uint32;
|
|
16
|
+
maxMemType1: uint32;
|
|
17
|
+
numberOfGlyphs?: uint16;
|
|
18
|
+
glyphNameIndex?: uint16[];
|
|
19
|
+
names?: string[];
|
|
20
|
+
}
|
|
21
|
+
export declare function parsePost(reader: Reader): PostTable;
|
|
22
|
+
/** Get glyph name by glyph ID */
|
|
23
|
+
export declare function getGlyphName(post: PostTable, glyphId: number): string | null;
|
|
24
|
+
/** Check if font is monospaced */
|
|
25
|
+
export declare function isMonospaced(post: PostTable): boolean;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { GlyphId, int16, uint16 } from "../../types.ts";
|
|
2
|
+
import type { Reader } from "../binary/reader.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Standard Bitmap Graphics table (sbix)
|
|
5
|
+
* Apple's bitmap/PNG glyph table for color emoji and bitmap fonts
|
|
6
|
+
*/
|
|
7
|
+
export interface SbixTable {
|
|
8
|
+
version: uint16;
|
|
9
|
+
flags: uint16;
|
|
10
|
+
strikes: SbixStrike[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Strike (bitmap size) in sbix
|
|
14
|
+
*/
|
|
15
|
+
export interface SbixStrike {
|
|
16
|
+
ppem: uint16;
|
|
17
|
+
ppi: uint16;
|
|
18
|
+
glyphData: Map<GlyphId, SbixGlyph>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Glyph data in sbix
|
|
22
|
+
*/
|
|
23
|
+
export interface SbixGlyph {
|
|
24
|
+
originOffsetX: int16;
|
|
25
|
+
originOffsetY: int16;
|
|
26
|
+
graphicType: string;
|
|
27
|
+
data: Uint8Array;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Common graphic types in sbix
|
|
31
|
+
*/
|
|
32
|
+
export declare const SbixGraphicType: {
|
|
33
|
+
readonly PNG: "png ";
|
|
34
|
+
readonly JPG: "jpg ";
|
|
35
|
+
readonly TIFF: "tiff";
|
|
36
|
+
readonly PDF: "pdf ";
|
|
37
|
+
readonly MASK: "mask";
|
|
38
|
+
readonly DUPE: "dupe";
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Parse sbix table
|
|
42
|
+
*/
|
|
43
|
+
export declare function parseSbix(reader: Reader, numGlyphs: number): SbixTable;
|
|
44
|
+
/**
|
|
45
|
+
* Get glyph bitmap for a specific ppem
|
|
46
|
+
* Returns the best matching strike
|
|
47
|
+
*/
|
|
48
|
+
export declare function getGlyphBitmap(sbix: SbixTable, glyphId: GlyphId, ppem: number): SbixGlyph | null;
|
|
49
|
+
/**
|
|
50
|
+
* Get exact ppem strike
|
|
51
|
+
*/
|
|
52
|
+
export declare function getStrikeForPpem(sbix: SbixTable, ppem: number): SbixStrike | null;
|
|
53
|
+
/**
|
|
54
|
+
* Get all available ppem sizes
|
|
55
|
+
*/
|
|
56
|
+
export declare function getAvailablePpemSizes(sbix: SbixTable): number[];
|
|
57
|
+
/**
|
|
58
|
+
* Check if glyph has bitmap data
|
|
59
|
+
*/
|
|
60
|
+
export declare function hasGlyphBitmap(sbix: SbixTable, glyphId: GlyphId, ppem?: number): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Resolve dupe graphic type
|
|
63
|
+
* Returns the actual glyph data for duplicates
|
|
64
|
+
*/
|
|
65
|
+
export declare function resolveDupeGlyph(sbix: SbixTable, strike: SbixStrike, glyph: SbixGlyph): SbixGlyph | null;
|