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,79 @@
|
|
|
1
|
+
import type { int16, uint16 } from "../../types.ts";
|
|
2
|
+
import type { Reader } from "../binary/reader.ts";
|
|
3
|
+
/**
|
|
4
|
+
* BASE table - Baseline alignment data
|
|
5
|
+
* Provides baseline offsets for scripts to align mixed-script text
|
|
6
|
+
*/
|
|
7
|
+
/** Baseline tags */
|
|
8
|
+
export declare const BaselineTag: {
|
|
9
|
+
/** Hanging baseline (Devanagari, Tibetan) */
|
|
10
|
+
readonly hang: 1751215719;
|
|
11
|
+
/** Ideographic character face bottom edge (CJK) */
|
|
12
|
+
readonly icfb: 1768121954;
|
|
13
|
+
/** Ideographic character face top edge (CJK) */
|
|
14
|
+
readonly icft: 1768121972;
|
|
15
|
+
/** Ideographic em-box bottom edge (CJK) */
|
|
16
|
+
readonly ideo: 1768187247;
|
|
17
|
+
/** Ideographic em-box top edge */
|
|
18
|
+
readonly idtp: 1768191088;
|
|
19
|
+
/** Mathematical baseline (math layout) */
|
|
20
|
+
readonly math: 1835103336;
|
|
21
|
+
/** Roman baseline (Latin, Greek, Cyrillic) */
|
|
22
|
+
readonly romn: 1919905134;
|
|
23
|
+
};
|
|
24
|
+
/** A single baseline value */
|
|
25
|
+
export interface BaselineValue {
|
|
26
|
+
baselineTag: number;
|
|
27
|
+
coordinate: int16;
|
|
28
|
+
}
|
|
29
|
+
/** Min/max extent values */
|
|
30
|
+
export interface MinMaxRecord {
|
|
31
|
+
minCoord: int16 | null;
|
|
32
|
+
maxCoord: int16 | null;
|
|
33
|
+
}
|
|
34
|
+
/** Feature-specific min/max values */
|
|
35
|
+
export interface FeatMinMaxRecord {
|
|
36
|
+
featureTag: number;
|
|
37
|
+
minCoord: int16 | null;
|
|
38
|
+
maxCoord: int16 | null;
|
|
39
|
+
}
|
|
40
|
+
/** Base values for a script */
|
|
41
|
+
export interface BaseValues {
|
|
42
|
+
defaultBaselineIndex: uint16;
|
|
43
|
+
baseCoords: int16[];
|
|
44
|
+
}
|
|
45
|
+
/** MinMax values for a language system */
|
|
46
|
+
export interface MinMax {
|
|
47
|
+
minCoord: int16 | null;
|
|
48
|
+
maxCoord: int16 | null;
|
|
49
|
+
featMinMaxRecords: FeatMinMaxRecord[];
|
|
50
|
+
}
|
|
51
|
+
/** Base script record */
|
|
52
|
+
export interface BaseScriptRecord {
|
|
53
|
+
scriptTag: number;
|
|
54
|
+
baseValues: BaseValues | null;
|
|
55
|
+
defaultMinMax: MinMax | null;
|
|
56
|
+
baseLangSysRecords: Map<number, MinMax>;
|
|
57
|
+
}
|
|
58
|
+
/** Axis table (horizontal or vertical) */
|
|
59
|
+
export interface AxisTable {
|
|
60
|
+
baseTagList: number[];
|
|
61
|
+
baseScriptList: BaseScriptRecord[];
|
|
62
|
+
}
|
|
63
|
+
/** BASE table */
|
|
64
|
+
export interface BaseTable {
|
|
65
|
+
majorVersion: uint16;
|
|
66
|
+
minorVersion: uint16;
|
|
67
|
+
horizAxis: AxisTable | null;
|
|
68
|
+
vertAxis: AxisTable | null;
|
|
69
|
+
}
|
|
70
|
+
export declare function parseBase(reader: Reader): BaseTable;
|
|
71
|
+
/** Get baseline value for a script */
|
|
72
|
+
export declare function getBaselineForScript(base: BaseTable, scriptTag: number, baselineTag: number, horizontal?: boolean): int16 | null;
|
|
73
|
+
/** Get default baseline for a script */
|
|
74
|
+
export declare function getDefaultBaseline(base: BaseTable, scriptTag: number, horizontal?: boolean): {
|
|
75
|
+
tag: number;
|
|
76
|
+
coordinate: int16;
|
|
77
|
+
} | null;
|
|
78
|
+
/** Get min/max extent for a script/language */
|
|
79
|
+
export declare function getMinMaxExtent(base: BaseTable, scriptTag: number, languageTag?: number, horizontal?: boolean): MinMaxRecord | null;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { GlyphId, int8, uint8, uint16, uint32 } from "../../types.ts";
|
|
2
|
+
import type { Reader } from "../binary/reader.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Color Bitmap Data Table (CBDT)
|
|
5
|
+
* Google's color bitmap table for emoji fonts
|
|
6
|
+
* Used together with CBLC (Color Bitmap Location Table)
|
|
7
|
+
*/
|
|
8
|
+
export interface CbdtTable {
|
|
9
|
+
majorVersion: uint16;
|
|
10
|
+
minorVersion: uint16;
|
|
11
|
+
/** Raw data for bitmap lookup */
|
|
12
|
+
data: Uint8Array;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Color Bitmap Location Table (CBLC)
|
|
16
|
+
* Index for looking up bitmaps in CBDT
|
|
17
|
+
*/
|
|
18
|
+
export interface CblcTable {
|
|
19
|
+
majorVersion: uint16;
|
|
20
|
+
minorVersion: uint16;
|
|
21
|
+
bitmapSizes: BitmapSize[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Bitmap size record
|
|
25
|
+
*/
|
|
26
|
+
export interface BitmapSize {
|
|
27
|
+
indexSubTableArrayOffset: uint32;
|
|
28
|
+
indexTablesSize: uint32;
|
|
29
|
+
numberOfIndexSubTables: uint32;
|
|
30
|
+
colorRef: uint32;
|
|
31
|
+
hori: SbitLineMetrics;
|
|
32
|
+
vert: SbitLineMetrics;
|
|
33
|
+
startGlyphIndex: GlyphId;
|
|
34
|
+
endGlyphIndex: GlyphId;
|
|
35
|
+
ppemX: uint8;
|
|
36
|
+
ppemY: uint8;
|
|
37
|
+
bitDepth: uint8;
|
|
38
|
+
flags: int8;
|
|
39
|
+
indexSubTables: IndexSubTable[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Line metrics for bitmap glyphs
|
|
43
|
+
*/
|
|
44
|
+
export interface SbitLineMetrics {
|
|
45
|
+
ascender: int8;
|
|
46
|
+
descender: int8;
|
|
47
|
+
widthMax: uint8;
|
|
48
|
+
caretSlopeNumerator: int8;
|
|
49
|
+
caretSlopeDenominator: int8;
|
|
50
|
+
caretOffset: int8;
|
|
51
|
+
minOriginSB: int8;
|
|
52
|
+
minAdvanceSB: int8;
|
|
53
|
+
maxBeforeBL: int8;
|
|
54
|
+
minAfterBL: int8;
|
|
55
|
+
pad1: int8;
|
|
56
|
+
pad2: int8;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Index sub-table for glyph lookup
|
|
60
|
+
*/
|
|
61
|
+
export interface IndexSubTable {
|
|
62
|
+
firstGlyphIndex: GlyphId;
|
|
63
|
+
lastGlyphIndex: GlyphId;
|
|
64
|
+
indexFormat: uint16;
|
|
65
|
+
imageFormat: uint16;
|
|
66
|
+
imageDataOffset: uint32;
|
|
67
|
+
/** Glyph offsets (format-dependent) */
|
|
68
|
+
glyphOffsets: Map<GlyphId, {
|
|
69
|
+
offset: uint32;
|
|
70
|
+
length: uint32;
|
|
71
|
+
}>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Bitmap glyph metrics
|
|
75
|
+
*/
|
|
76
|
+
export interface GlyphBitmapMetrics {
|
|
77
|
+
height: uint8;
|
|
78
|
+
width: uint8;
|
|
79
|
+
bearingX: int8;
|
|
80
|
+
bearingY: int8;
|
|
81
|
+
advance: uint8;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Bitmap glyph data
|
|
85
|
+
*/
|
|
86
|
+
export interface BitmapGlyph {
|
|
87
|
+
metrics: GlyphBitmapMetrics;
|
|
88
|
+
imageFormat: uint16;
|
|
89
|
+
data: Uint8Array;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Image formats in CBDT
|
|
93
|
+
*/
|
|
94
|
+
export declare const CbdtImageFormat: {
|
|
95
|
+
readonly SmallMetrics: 1;
|
|
96
|
+
readonly SmallMetricsPng: 17;
|
|
97
|
+
readonly BigMetrics: 2;
|
|
98
|
+
readonly BigMetricsPng: 18;
|
|
99
|
+
readonly CompressedPng: 19;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Parse CBLC table
|
|
103
|
+
*/
|
|
104
|
+
export declare function parseCblc(reader: Reader): CblcTable;
|
|
105
|
+
/**
|
|
106
|
+
* Parse CBDT table
|
|
107
|
+
*/
|
|
108
|
+
export declare function parseCbdt(reader: Reader): CbdtTable;
|
|
109
|
+
/**
|
|
110
|
+
* Get bitmap glyph from CBDT using CBLC index
|
|
111
|
+
*/
|
|
112
|
+
export declare function getBitmapGlyph(cblc: CblcTable, cbdt: CbdtTable, glyphId: GlyphId, ppem: number): BitmapGlyph | null;
|
|
113
|
+
/**
|
|
114
|
+
* Check if glyph has color bitmap
|
|
115
|
+
*/
|
|
116
|
+
export declare function hasColorBitmap(cblc: CblcTable, glyphId: GlyphId, ppem?: number): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Get available ppem sizes for color bitmaps
|
|
119
|
+
*/
|
|
120
|
+
export declare function getColorBitmapSizes(cblc: CblcTable): number[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { GlyphId } from "../../types.ts";
|
|
2
|
+
import type { CffTable } from "./cff.ts";
|
|
3
|
+
import type { Cff2Table } from "./cff2.ts";
|
|
4
|
+
import type { Contour } from "./glyf.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Execute a CFF charstring and return contours
|
|
7
|
+
*/
|
|
8
|
+
export declare function executeCffCharString(cff: CffTable, glyphId: GlyphId, fontIndex?: number): Contour[] | null;
|
|
9
|
+
/**
|
|
10
|
+
* Execute a CFF2 charstring with variation support
|
|
11
|
+
*/
|
|
12
|
+
export declare function executeCff2CharString(cff2: Cff2Table, glyphId: GlyphId, axisCoords?: number[] | null): Contour[] | null;
|
|
13
|
+
/**
|
|
14
|
+
* Get glyph width from CFF charstring
|
|
15
|
+
*/
|
|
16
|
+
export declare function getCffGlyphWidth(cff: CffTable, _glyphId: GlyphId, fontIndex?: number): number;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Reader } from "../binary/reader.ts";
|
|
2
|
+
/**
|
|
3
|
+
* CFF (Compact Font Format) table parser
|
|
4
|
+
* Used by OpenType fonts with PostScript outlines
|
|
5
|
+
*/
|
|
6
|
+
export interface CffTable {
|
|
7
|
+
version: {
|
|
8
|
+
major: number;
|
|
9
|
+
minor: number;
|
|
10
|
+
};
|
|
11
|
+
names: string[];
|
|
12
|
+
topDicts: TopDict[];
|
|
13
|
+
strings: string[];
|
|
14
|
+
globalSubrs: Uint8Array[];
|
|
15
|
+
charStrings: Uint8Array[][];
|
|
16
|
+
localSubrs: Uint8Array[][];
|
|
17
|
+
fdArrays: FDDict[][];
|
|
18
|
+
fdSelects: FDSelect[];
|
|
19
|
+
}
|
|
20
|
+
export interface TopDict {
|
|
21
|
+
version?: string;
|
|
22
|
+
notice?: string;
|
|
23
|
+
copyright?: string;
|
|
24
|
+
fullName?: string;
|
|
25
|
+
familyName?: string;
|
|
26
|
+
weight?: string;
|
|
27
|
+
isFixedPitch?: boolean;
|
|
28
|
+
italicAngle?: number;
|
|
29
|
+
underlinePosition?: number;
|
|
30
|
+
underlineThickness?: number;
|
|
31
|
+
paintType?: number;
|
|
32
|
+
charstringType?: number;
|
|
33
|
+
fontMatrix?: number[];
|
|
34
|
+
uniqueID?: number;
|
|
35
|
+
fontBBox?: number[];
|
|
36
|
+
strokeWidth?: number;
|
|
37
|
+
charset?: number;
|
|
38
|
+
encoding?: number;
|
|
39
|
+
charStrings?: number;
|
|
40
|
+
private?: [number, number];
|
|
41
|
+
syntheticBase?: number;
|
|
42
|
+
postScript?: string;
|
|
43
|
+
baseFontName?: string;
|
|
44
|
+
baseFontBlend?: number[];
|
|
45
|
+
ros?: {
|
|
46
|
+
registry: string;
|
|
47
|
+
ordering: string;
|
|
48
|
+
supplement: number;
|
|
49
|
+
};
|
|
50
|
+
cidFontVersion?: number;
|
|
51
|
+
cidFontRevision?: number;
|
|
52
|
+
cidFontType?: number;
|
|
53
|
+
cidCount?: number;
|
|
54
|
+
uidBase?: number;
|
|
55
|
+
fdArray?: number;
|
|
56
|
+
fdSelect?: number;
|
|
57
|
+
fontName?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface PrivateDict {
|
|
60
|
+
blueValues?: number[];
|
|
61
|
+
otherBlues?: number[];
|
|
62
|
+
familyBlues?: number[];
|
|
63
|
+
familyOtherBlues?: number[];
|
|
64
|
+
blueScale?: number;
|
|
65
|
+
blueShift?: number;
|
|
66
|
+
blueFuzz?: number;
|
|
67
|
+
stdHW?: number;
|
|
68
|
+
stdVW?: number;
|
|
69
|
+
stemSnapH?: number[];
|
|
70
|
+
stemSnapV?: number[];
|
|
71
|
+
forceBold?: boolean;
|
|
72
|
+
languageGroup?: number;
|
|
73
|
+
expansionFactor?: number;
|
|
74
|
+
initialRandomSeed?: number;
|
|
75
|
+
subrs?: number;
|
|
76
|
+
defaultWidthX?: number;
|
|
77
|
+
nominalWidthX?: number;
|
|
78
|
+
}
|
|
79
|
+
export interface FDDict extends PrivateDict {
|
|
80
|
+
fontName?: string;
|
|
81
|
+
}
|
|
82
|
+
export interface FDSelect {
|
|
83
|
+
format: number;
|
|
84
|
+
select: (glyphId: number) => number;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Parse CFF table
|
|
88
|
+
*/
|
|
89
|
+
export declare function parseCff(reader: Reader): CffTable;
|
|
90
|
+
/**
|
|
91
|
+
* Get string by SID
|
|
92
|
+
*/
|
|
93
|
+
export declare function getCffString(cff: CffTable, sid: number): string;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Reader } from "../binary/reader.ts";
|
|
2
|
+
/**
|
|
3
|
+
* CFF2 (Compact Font Format 2) table parser
|
|
4
|
+
* Used by variable fonts with PostScript outlines
|
|
5
|
+
*/
|
|
6
|
+
export interface Cff2Table {
|
|
7
|
+
version: {
|
|
8
|
+
major: number;
|
|
9
|
+
minor: number;
|
|
10
|
+
};
|
|
11
|
+
topDict: Cff2TopDict;
|
|
12
|
+
globalSubrs: Uint8Array[];
|
|
13
|
+
charStrings: Uint8Array[];
|
|
14
|
+
fdArray: Cff2FDDict[];
|
|
15
|
+
fdSelect: Cff2FDSelect | null;
|
|
16
|
+
vstore: ItemVariationStore | null;
|
|
17
|
+
}
|
|
18
|
+
export interface Cff2TopDict {
|
|
19
|
+
charStrings?: number;
|
|
20
|
+
fdArray?: number;
|
|
21
|
+
fdSelect?: number;
|
|
22
|
+
vstore?: number;
|
|
23
|
+
fontMatrix?: number[];
|
|
24
|
+
}
|
|
25
|
+
export interface Cff2PrivateDict {
|
|
26
|
+
blueValues?: number[];
|
|
27
|
+
otherBlues?: number[];
|
|
28
|
+
familyBlues?: number[];
|
|
29
|
+
familyOtherBlues?: number[];
|
|
30
|
+
blueScale?: number;
|
|
31
|
+
blueShift?: number;
|
|
32
|
+
blueFuzz?: number;
|
|
33
|
+
stdHW?: number;
|
|
34
|
+
stdVW?: number;
|
|
35
|
+
stemSnapH?: number[];
|
|
36
|
+
stemSnapV?: number[];
|
|
37
|
+
languageGroup?: number;
|
|
38
|
+
expansionFactor?: number;
|
|
39
|
+
subrs?: number;
|
|
40
|
+
vsindex?: number;
|
|
41
|
+
blend?: number[];
|
|
42
|
+
}
|
|
43
|
+
export interface Cff2FDDict {
|
|
44
|
+
fontName?: string;
|
|
45
|
+
private?: Cff2PrivateDict;
|
|
46
|
+
privateOffset?: number;
|
|
47
|
+
privateSize?: number;
|
|
48
|
+
localSubrs?: Uint8Array[];
|
|
49
|
+
}
|
|
50
|
+
export interface Cff2FDSelect {
|
|
51
|
+
format: number;
|
|
52
|
+
select: (glyphId: number) => number;
|
|
53
|
+
}
|
|
54
|
+
export interface ItemVariationStore {
|
|
55
|
+
format: number;
|
|
56
|
+
variationRegionList: VariationRegionList;
|
|
57
|
+
itemVariationData: ItemVariationData[];
|
|
58
|
+
}
|
|
59
|
+
export interface VariationRegionList {
|
|
60
|
+
axisCount: number;
|
|
61
|
+
regionCount: number;
|
|
62
|
+
regions: VariationRegion[];
|
|
63
|
+
}
|
|
64
|
+
export interface VariationRegion {
|
|
65
|
+
axes: RegionAxisCoordinates[];
|
|
66
|
+
}
|
|
67
|
+
export interface RegionAxisCoordinates {
|
|
68
|
+
startCoord: number;
|
|
69
|
+
peakCoord: number;
|
|
70
|
+
endCoord: number;
|
|
71
|
+
}
|
|
72
|
+
export interface ItemVariationData {
|
|
73
|
+
itemCount: number;
|
|
74
|
+
regionIndexCount: number;
|
|
75
|
+
regionIndexes: number[];
|
|
76
|
+
deltaSets: number[][];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Parse CFF2 table
|
|
80
|
+
*/
|
|
81
|
+
export declare function parseCff2(reader: Reader): Cff2Table;
|
|
82
|
+
/**
|
|
83
|
+
* Calculate variation delta for given coordinates
|
|
84
|
+
*/
|
|
85
|
+
export declare function calculateVariationDelta(vstore: ItemVariationStore, outerIndex: number, innerIndex: number, normalizedCoords: number[]): number;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { GlyphId, uint16, uint32 } from "../../types.ts";
|
|
2
|
+
import type { Reader } from "../binary/reader.ts";
|
|
3
|
+
/** Platform IDs */
|
|
4
|
+
export declare enum PlatformId {
|
|
5
|
+
Unicode = 0,
|
|
6
|
+
Macintosh = 1,
|
|
7
|
+
ISO = 2,// deprecated
|
|
8
|
+
Windows = 3,
|
|
9
|
+
Custom = 4
|
|
10
|
+
}
|
|
11
|
+
/** Encoding record in cmap header */
|
|
12
|
+
export interface EncodingRecord {
|
|
13
|
+
platformId: uint16;
|
|
14
|
+
encodingId: uint16;
|
|
15
|
+
offset: uint32;
|
|
16
|
+
}
|
|
17
|
+
/** Base interface for cmap subtables */
|
|
18
|
+
interface CmapSubtableBase {
|
|
19
|
+
format: number;
|
|
20
|
+
lookup(codepoint: number): GlyphId | undefined;
|
|
21
|
+
}
|
|
22
|
+
/** Format 0: Byte encoding table (legacy, 256 entries) */
|
|
23
|
+
interface CmapFormat0 extends CmapSubtableBase {
|
|
24
|
+
format: 0;
|
|
25
|
+
glyphIdArray: Uint8Array;
|
|
26
|
+
}
|
|
27
|
+
/** Format 4: Segment mapping to delta values (BMP characters) */
|
|
28
|
+
interface CmapFormat4 extends CmapSubtableBase {
|
|
29
|
+
format: 4;
|
|
30
|
+
segCount: number;
|
|
31
|
+
endCodes: Uint16Array;
|
|
32
|
+
startCodes: Uint16Array;
|
|
33
|
+
idDeltas: Int16Array;
|
|
34
|
+
idRangeOffsets: Uint16Array;
|
|
35
|
+
glyphIdArray: Uint16Array;
|
|
36
|
+
}
|
|
37
|
+
/** Format 12: Segmented coverage (full Unicode) */
|
|
38
|
+
interface CmapFormat12 extends CmapSubtableBase {
|
|
39
|
+
format: 12;
|
|
40
|
+
groups: Array<{
|
|
41
|
+
startCharCode: uint32;
|
|
42
|
+
endCharCode: uint32;
|
|
43
|
+
startGlyphId: uint32;
|
|
44
|
+
}>;
|
|
45
|
+
}
|
|
46
|
+
/** Variation selector record */
|
|
47
|
+
interface VariationSelectorRecord {
|
|
48
|
+
varSelector: number;
|
|
49
|
+
defaultUVS: Array<{
|
|
50
|
+
startUnicodeValue: number;
|
|
51
|
+
additionalCount: number;
|
|
52
|
+
}> | null;
|
|
53
|
+
nonDefaultUVS: Array<{
|
|
54
|
+
unicodeValue: number;
|
|
55
|
+
glyphId: GlyphId;
|
|
56
|
+
}> | null;
|
|
57
|
+
}
|
|
58
|
+
/** Format 14: Unicode Variation Sequences */
|
|
59
|
+
interface CmapFormat14 extends CmapSubtableBase {
|
|
60
|
+
format: 14;
|
|
61
|
+
varSelectorRecords: VariationSelectorRecord[];
|
|
62
|
+
lookupVariation(codepoint: number, variationSelector: number): GlyphId | undefined | "default";
|
|
63
|
+
}
|
|
64
|
+
export type CmapSubtable = CmapFormat0 | CmapFormat4 | CmapFormat12 | CmapFormat14;
|
|
65
|
+
/** Character to glyph index mapping table */
|
|
66
|
+
export interface CmapTable {
|
|
67
|
+
version: uint16;
|
|
68
|
+
numTables: uint16;
|
|
69
|
+
encodingRecords: EncodingRecord[];
|
|
70
|
+
subtables: Map<string, CmapSubtable>;
|
|
71
|
+
/** Best subtable for Unicode lookup */
|
|
72
|
+
bestSubtable: CmapSubtable | null;
|
|
73
|
+
}
|
|
74
|
+
export declare function parseCmap(reader: Reader, tableLength: number): CmapTable;
|
|
75
|
+
/** Get glyph ID for a codepoint using the best subtable */
|
|
76
|
+
export declare function getGlyphId(cmap: CmapTable, codepoint: number): GlyphId;
|
|
77
|
+
/** Get glyph ID for a variation sequence (base + variation selector) */
|
|
78
|
+
export declare function getVariationGlyphId(cmap: CmapTable, codepoint: number, variationSelector: number): GlyphId | undefined;
|
|
79
|
+
/** Check if a codepoint is a variation selector */
|
|
80
|
+
export declare function isVariationSelector(codepoint: number): boolean;
|
|
81
|
+
export {};
|