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,64 @@
|
|
|
1
|
+
import type { GlyphInfo } from "../../types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Check if codepoint is a Hangul syllable
|
|
4
|
+
*/
|
|
5
|
+
export declare function isHangulSyllable(cp: number): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Check if codepoint is a Hangul Jamo (conjoining)
|
|
8
|
+
*/
|
|
9
|
+
export declare function isHangulJamo(cp: number): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Check if codepoint is a leading consonant (L)
|
|
12
|
+
*/
|
|
13
|
+
export declare function isJamoL(cp: number): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Check if codepoint is a vowel (V)
|
|
16
|
+
*/
|
|
17
|
+
export declare function isJamoV(cp: number): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Check if codepoint is a trailing consonant (T)
|
|
20
|
+
*/
|
|
21
|
+
export declare function isJamoT(cp: number): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Decompose a precomposed Hangul syllable into Jamo
|
|
24
|
+
*/
|
|
25
|
+
export declare function decomposeHangul(cp: number): number[];
|
|
26
|
+
/**
|
|
27
|
+
* Compose Jamo into a precomposed Hangul syllable
|
|
28
|
+
*/
|
|
29
|
+
export declare function composeHangul(l: number, v: number, t?: number): number | null;
|
|
30
|
+
/**
|
|
31
|
+
* Hangul syllable types
|
|
32
|
+
*/
|
|
33
|
+
export declare enum HangulSyllableType {
|
|
34
|
+
NotApplicable = 0,
|
|
35
|
+
LeadingJamo = 1,// L
|
|
36
|
+
VowelJamo = 2,// V
|
|
37
|
+
TrailingJamo = 3,// T
|
|
38
|
+
LVSyllable = 4,// LV (no trailing)
|
|
39
|
+
LVTSyllable = 5
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get the syllable type of a codepoint
|
|
43
|
+
*/
|
|
44
|
+
export declare function getHangulSyllableType(cp: number): HangulSyllableType;
|
|
45
|
+
/**
|
|
46
|
+
* Feature masks for Hangul
|
|
47
|
+
*/
|
|
48
|
+
export declare const HangulFeatureMask: {
|
|
49
|
+
readonly ljmo: 1;
|
|
50
|
+
readonly vjmo: 2;
|
|
51
|
+
readonly tjmo: 4;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Setup Hangul masks for feature application
|
|
55
|
+
*/
|
|
56
|
+
export declare function setupHangulMasks(infos: GlyphInfo[]): void;
|
|
57
|
+
/**
|
|
58
|
+
* Normalize Hangul - compose Jamo sequences into syllables where possible
|
|
59
|
+
*/
|
|
60
|
+
export declare function normalizeHangul(infos: GlyphInfo[]): GlyphInfo[];
|
|
61
|
+
/**
|
|
62
|
+
* Check if codepoint is Korean (Hangul or Jamo)
|
|
63
|
+
*/
|
|
64
|
+
export declare function isKorean(cp: number): boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { GlyphInfo } from "../../types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Hebrew character categories
|
|
4
|
+
*/
|
|
5
|
+
export declare enum HebrewCategory {
|
|
6
|
+
Other = 0,
|
|
7
|
+
Letter = 1,// Regular letter
|
|
8
|
+
Point = 2,// Niqqud (vowel point)
|
|
9
|
+
Dagesh = 3,// Dagesh/Mapiq
|
|
10
|
+
Shin = 4,// Shin/Sin dot
|
|
11
|
+
Rafe = 5,// Rafe mark
|
|
12
|
+
Accent = 6,// Cantillation marks
|
|
13
|
+
Maqaf = 7,// Hebrew hyphen
|
|
14
|
+
Punctuation = 8
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Check if codepoint is Hebrew
|
|
18
|
+
*/
|
|
19
|
+
export declare function isHebrew(cp: number): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Get Hebrew category for a codepoint
|
|
22
|
+
*/
|
|
23
|
+
export declare function getHebrewCategory(cp: number): HebrewCategory;
|
|
24
|
+
/**
|
|
25
|
+
* Set up masks for Hebrew shaping
|
|
26
|
+
* Hebrew is relatively simple - mainly RTL with marks
|
|
27
|
+
*/
|
|
28
|
+
export declare function setupHebrewMasks(infos: GlyphInfo[]): void;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { GlyphInfo } from "../../types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Indic syllable categories based on Unicode and OpenType spec
|
|
4
|
+
*/
|
|
5
|
+
export declare enum IndicCategory {
|
|
6
|
+
X = 0,// Other/Unknown
|
|
7
|
+
C = 1,// Consonant
|
|
8
|
+
V = 2,// Independent vowel
|
|
9
|
+
N = 3,// Nukta
|
|
10
|
+
H = 4,// Halant/Virama
|
|
11
|
+
ZWNJ = 5,// Zero Width Non-Joiner
|
|
12
|
+
ZWJ = 6,// Zero Width Joiner
|
|
13
|
+
M = 7,// Matra (dependent vowel)
|
|
14
|
+
SM = 8,// Syllable modifier (anusvara, visarga)
|
|
15
|
+
A = 9,// Accent mark
|
|
16
|
+
VD = 10,// Vedic mark
|
|
17
|
+
Placeholder = 11,// Placeholder (dotted circle)
|
|
18
|
+
Dotted_Circle = 12,// Explicit dotted circle
|
|
19
|
+
RS = 13,// Repha form
|
|
20
|
+
Coeng = 14,// Coeng (Khmer virama)
|
|
21
|
+
Ra = 15,// Ra consonant (for repha)
|
|
22
|
+
CM = 16,// Consonant modifier
|
|
23
|
+
Symbol = 17,// Symbol
|
|
24
|
+
CS = 18
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Indic syllabic position
|
|
28
|
+
*/
|
|
29
|
+
export declare enum IndicPosition {
|
|
30
|
+
Start = 0,
|
|
31
|
+
RaToBecomeReph = 1,
|
|
32
|
+
PreM = 2,
|
|
33
|
+
PreC = 3,
|
|
34
|
+
BaseC = 4,
|
|
35
|
+
AfterMain = 5,
|
|
36
|
+
AboveC = 6,
|
|
37
|
+
BeforeSub = 7,
|
|
38
|
+
BelowC = 8,
|
|
39
|
+
AfterSub = 9,
|
|
40
|
+
BeforePost = 10,
|
|
41
|
+
PostC = 11,
|
|
42
|
+
AfterPost = 12,
|
|
43
|
+
FinalC = 13,
|
|
44
|
+
SMVD = 14,
|
|
45
|
+
End = 15
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Per-glyph Indic shaping data
|
|
49
|
+
*/
|
|
50
|
+
export interface IndicGlyphData {
|
|
51
|
+
category: IndicCategory;
|
|
52
|
+
position: IndicPosition;
|
|
53
|
+
syllableIndex: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Check if a codepoint is an Indic script
|
|
57
|
+
*/
|
|
58
|
+
export declare function isIndic(cp: number): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Get the Indic category for a codepoint
|
|
61
|
+
*/
|
|
62
|
+
export declare function getIndicCategory(cp: number): IndicCategory;
|
|
63
|
+
/**
|
|
64
|
+
* Syllable structure for Indic scripts
|
|
65
|
+
*/
|
|
66
|
+
interface Syllable {
|
|
67
|
+
start: number;
|
|
68
|
+
end: number;
|
|
69
|
+
hasReph: boolean;
|
|
70
|
+
baseConsonant: number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Find syllable boundaries in the glyph buffer
|
|
74
|
+
*/
|
|
75
|
+
export declare function findSyllables(infos: GlyphInfo[]): Syllable[];
|
|
76
|
+
/**
|
|
77
|
+
* Indic feature masks for OpenType features
|
|
78
|
+
*/
|
|
79
|
+
export declare const IndicFeatureMask: {
|
|
80
|
+
readonly nukt: 1;
|
|
81
|
+
readonly akhn: 2;
|
|
82
|
+
readonly rphf: 4;
|
|
83
|
+
readonly rkrf: 8;
|
|
84
|
+
readonly pref: 16;
|
|
85
|
+
readonly blwf: 32;
|
|
86
|
+
readonly abvf: 64;
|
|
87
|
+
readonly half: 128;
|
|
88
|
+
readonly pstf: 256;
|
|
89
|
+
readonly vatu: 512;
|
|
90
|
+
readonly cjct: 1024;
|
|
91
|
+
readonly init: 2048;
|
|
92
|
+
readonly pres: 4096;
|
|
93
|
+
readonly abvs: 8192;
|
|
94
|
+
readonly blws: 16384;
|
|
95
|
+
readonly psts: 32768;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Matra position in syllable
|
|
99
|
+
*/
|
|
100
|
+
export declare enum MatraPosition {
|
|
101
|
+
PreBase = 0,
|
|
102
|
+
AboveBase = 1,
|
|
103
|
+
BelowBase = 2,
|
|
104
|
+
PostBase = 3
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Set up masks and syllable indices for Indic shaping
|
|
108
|
+
*/
|
|
109
|
+
export declare function setupIndicMasks(infos: GlyphInfo[]): void;
|
|
110
|
+
/**
|
|
111
|
+
* Reorder glyphs within a syllable for correct visual display
|
|
112
|
+
* This handles:
|
|
113
|
+
* - Moving pre-base matras before the base consonant
|
|
114
|
+
* - Moving reph to its final position
|
|
115
|
+
*/
|
|
116
|
+
export declare function reorderIndic(infos: GlyphInfo[]): void;
|
|
117
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { GlyphInfo } from "../../types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Khmer character categories
|
|
4
|
+
*/
|
|
5
|
+
export declare enum KhmerCategory {
|
|
6
|
+
Other = 0,
|
|
7
|
+
Consonant = 1,
|
|
8
|
+
IndependentVowel = 2,
|
|
9
|
+
DependentVowel = 3,
|
|
10
|
+
Coeng = 4,// Subscript sign (្)
|
|
11
|
+
Register = 5,// Register shifters
|
|
12
|
+
Robat = 6,// Consonant shifter (៌)
|
|
13
|
+
Sign = 7,
|
|
14
|
+
Anusvara = 8,// Nikahit (ំ)
|
|
15
|
+
Visarga = 9
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get Khmer character category
|
|
19
|
+
*/
|
|
20
|
+
export declare function getKhmerCategory(cp: number): KhmerCategory;
|
|
21
|
+
/**
|
|
22
|
+
* Khmer feature masks
|
|
23
|
+
*/
|
|
24
|
+
export declare const KhmerFeatureMask: {
|
|
25
|
+
readonly pref: 1;
|
|
26
|
+
readonly blwf: 2;
|
|
27
|
+
readonly abvf: 4;
|
|
28
|
+
readonly pstf: 8;
|
|
29
|
+
readonly cfar: 16;
|
|
30
|
+
readonly pres: 32;
|
|
31
|
+
readonly abvs: 64;
|
|
32
|
+
readonly blws: 128;
|
|
33
|
+
readonly psts: 256;
|
|
34
|
+
readonly clig: 512;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Check if codepoint is Khmer
|
|
38
|
+
*/
|
|
39
|
+
export declare function isKhmer(cp: number): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Setup Khmer masks for feature application
|
|
42
|
+
*/
|
|
43
|
+
export declare function setupKhmerMasks(infos: GlyphInfo[]): void;
|
|
44
|
+
/**
|
|
45
|
+
* Reorder Khmer pre-base vowels
|
|
46
|
+
* Pre-base vowels (◌េ ◌ែ ◌ៃ) should visually appear before the base
|
|
47
|
+
*/
|
|
48
|
+
export declare function reorderKhmer(infos: GlyphInfo[]): void;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { GlyphInfo } from "../../types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Mongolian shaper
|
|
4
|
+
* Handles Traditional Mongolian, Manchu, and Sibe scripts
|
|
5
|
+
*
|
|
6
|
+
* Mongolian is written vertically (top to bottom, left to right columns).
|
|
7
|
+
* Like Arabic, it has context-sensitive letter forms:
|
|
8
|
+
* - Initial, Medial, Final, and Isolated forms
|
|
9
|
+
*
|
|
10
|
+
* Key characteristics:
|
|
11
|
+
* - Vertical writing
|
|
12
|
+
* - Positional forms (like Arabic joining)
|
|
13
|
+
* - Free variation selectors (FVS1-FVS4)
|
|
14
|
+
* - Vowel separators (MVS, NNBSP)
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Mongolian character categories
|
|
18
|
+
*/
|
|
19
|
+
export declare enum MongolianCategory {
|
|
20
|
+
Other = 0,
|
|
21
|
+
Letter = 1,// Regular letters
|
|
22
|
+
Vowel = 2,// Vowels
|
|
23
|
+
Digit = 3,// Digits
|
|
24
|
+
Punctuation = 4,// Punctuation
|
|
25
|
+
FVS = 5,// Free Variation Selector
|
|
26
|
+
MVS = 6,// Mongolian Vowel Separator (180E)
|
|
27
|
+
NNBSP = 7,// Narrow No-Break Space (202F)
|
|
28
|
+
ZWJ = 8,// Zero Width Joiner
|
|
29
|
+
ZWNJ = 9
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Mongolian joining types (like Arabic)
|
|
33
|
+
*/
|
|
34
|
+
export declare enum MongolianJoining {
|
|
35
|
+
NonJoining = 0,
|
|
36
|
+
RightJoining = 1,// Joins to right (previous in text order)
|
|
37
|
+
DualJoining = 2,// Joins both sides
|
|
38
|
+
LeftJoining = 3,// Joins to left (next in text order) - rare
|
|
39
|
+
Transparent = 4,// Invisible control characters
|
|
40
|
+
Causing = 5
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get Mongolian category
|
|
44
|
+
*/
|
|
45
|
+
export declare function getMongolianCategory(cp: number): MongolianCategory;
|
|
46
|
+
/**
|
|
47
|
+
* Get Mongolian joining type for a codepoint
|
|
48
|
+
*/
|
|
49
|
+
export declare function getMongolianJoining(cp: number): MongolianJoining;
|
|
50
|
+
/**
|
|
51
|
+
* Mongolian positional forms
|
|
52
|
+
*/
|
|
53
|
+
export declare enum MongolianForm {
|
|
54
|
+
Isolated = 0,
|
|
55
|
+
Initial = 1,
|
|
56
|
+
Medial = 2,
|
|
57
|
+
Final = 3
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Determine positional form for a Mongolian character
|
|
61
|
+
*/
|
|
62
|
+
export declare function getMongolianForm(prev: MongolianJoining, current: MongolianJoining, next: MongolianJoining): MongolianForm;
|
|
63
|
+
/**
|
|
64
|
+
* Mongolian feature masks
|
|
65
|
+
*/
|
|
66
|
+
export declare const MongolianFeatureMask: {
|
|
67
|
+
readonly ccmp: 1;
|
|
68
|
+
readonly locl: 2;
|
|
69
|
+
readonly isol: 4;
|
|
70
|
+
readonly init: 8;
|
|
71
|
+
readonly medi: 16;
|
|
72
|
+
readonly fina: 32;
|
|
73
|
+
readonly rlig: 64;
|
|
74
|
+
readonly calt: 128;
|
|
75
|
+
readonly liga: 256;
|
|
76
|
+
readonly vert: 512;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Set up masks for Mongolian shaping
|
|
80
|
+
*/
|
|
81
|
+
export declare function setupMongolianMasks(infos: GlyphInfo[]): void;
|
|
82
|
+
/**
|
|
83
|
+
* Get default Mongolian features in order
|
|
84
|
+
*/
|
|
85
|
+
export declare function getMongolianFeatures(): string[];
|
|
86
|
+
/**
|
|
87
|
+
* Check if script uses Mongolian shaper
|
|
88
|
+
*/
|
|
89
|
+
export declare function usesMongolian(script: string): boolean;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { GlyphInfo } from "../../types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Myanmar character categories
|
|
4
|
+
*/
|
|
5
|
+
export declare enum MyanmarCategory {
|
|
6
|
+
Other = 0,
|
|
7
|
+
Consonant = 1,
|
|
8
|
+
IndependentVowel = 2,
|
|
9
|
+
DependentVowel = 3,
|
|
10
|
+
Medial = 4,
|
|
11
|
+
Asat = 5,// Killer (္)
|
|
12
|
+
Anusvara = 6,// Dot below
|
|
13
|
+
Visarga = 7,// Visarga
|
|
14
|
+
Sign = 8,
|
|
15
|
+
Number = 9,
|
|
16
|
+
Placeholder = 10
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get Myanmar character category
|
|
20
|
+
*/
|
|
21
|
+
export declare function getMyanmarCategory(cp: number): MyanmarCategory;
|
|
22
|
+
/**
|
|
23
|
+
* Myanmar feature masks
|
|
24
|
+
*/
|
|
25
|
+
export declare const MyanmarFeatureMask: {
|
|
26
|
+
readonly rphf: 1;
|
|
27
|
+
readonly pref: 2;
|
|
28
|
+
readonly blwf: 4;
|
|
29
|
+
readonly pstf: 8;
|
|
30
|
+
readonly pres: 16;
|
|
31
|
+
readonly abvs: 32;
|
|
32
|
+
readonly blws: 64;
|
|
33
|
+
readonly psts: 128;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Check if codepoint is Myanmar
|
|
37
|
+
*/
|
|
38
|
+
export declare function isMyanmar(cp: number): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Setup Myanmar masks for feature application
|
|
41
|
+
*/
|
|
42
|
+
export declare function setupMyanmarMasks(infos: GlyphInfo[]): void;
|
|
43
|
+
/**
|
|
44
|
+
* Reorder Myanmar pre-base vowels and medials
|
|
45
|
+
* ေ and ြ should visually appear before the base consonant
|
|
46
|
+
*/
|
|
47
|
+
export declare function reorderMyanmar(infos: GlyphInfo[]): void;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { GlyphInfo } from "../../types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Syriac shaper
|
|
4
|
+
* Handles Syriac script (Estrangela, Serto, Eastern)
|
|
5
|
+
*
|
|
6
|
+
* Syriac is a right-to-left script with:
|
|
7
|
+
* - Joining behavior (like Arabic)
|
|
8
|
+
* - Vowel marks (diacritics above/below)
|
|
9
|
+
* - Multiple script styles (Estrangela, Serto, East Syriac)
|
|
10
|
+
* - Dalath/Rish distinction marks
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Syriac joining types
|
|
14
|
+
*/
|
|
15
|
+
export declare enum SyriacJoining {
|
|
16
|
+
NonJoining = 0,
|
|
17
|
+
RightJoining = 1,
|
|
18
|
+
DualJoining = 2,
|
|
19
|
+
LeftJoining = 3,
|
|
20
|
+
Transparent = 4,
|
|
21
|
+
Causing = 5
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Syriac character categories
|
|
25
|
+
*/
|
|
26
|
+
export declare enum SyriacCategory {
|
|
27
|
+
Other = 0,
|
|
28
|
+
Letter = 1,
|
|
29
|
+
Diacritic = 2,
|
|
30
|
+
Punctuation = 3,
|
|
31
|
+
Digit = 4
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get Syriac joining type for codepoint
|
|
35
|
+
*/
|
|
36
|
+
export declare function getSyriacJoining(cp: number): SyriacJoining;
|
|
37
|
+
/**
|
|
38
|
+
* Get Syriac category
|
|
39
|
+
*/
|
|
40
|
+
export declare function getSyriacCategory(cp: number): SyriacCategory;
|
|
41
|
+
/**
|
|
42
|
+
* Syriac positional forms
|
|
43
|
+
*/
|
|
44
|
+
export declare enum SyriacForm {
|
|
45
|
+
Isolated = 0,
|
|
46
|
+
Initial = 1,
|
|
47
|
+
Medial = 2,
|
|
48
|
+
Final = 3
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Determine Syriac positional form
|
|
52
|
+
*/
|
|
53
|
+
export declare function getSyriacForm(prev: SyriacJoining, current: SyriacJoining, next: SyriacJoining): SyriacForm;
|
|
54
|
+
/**
|
|
55
|
+
* Syriac feature masks
|
|
56
|
+
*/
|
|
57
|
+
export declare const SyriacFeatureMask: {
|
|
58
|
+
readonly ccmp: 1;
|
|
59
|
+
readonly locl: 2;
|
|
60
|
+
readonly isol: 4;
|
|
61
|
+
readonly init: 8;
|
|
62
|
+
readonly medi: 16;
|
|
63
|
+
readonly fina: 32;
|
|
64
|
+
readonly rlig: 64;
|
|
65
|
+
readonly calt: 128;
|
|
66
|
+
readonly liga: 256;
|
|
67
|
+
readonly stch: 512;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Set up masks for Syriac shaping
|
|
71
|
+
*/
|
|
72
|
+
export declare function setupSyriacMasks(infos: GlyphInfo[]): void;
|
|
73
|
+
/**
|
|
74
|
+
* Get default Syriac features in order
|
|
75
|
+
*/
|
|
76
|
+
export declare function getSyriacFeatures(): string[];
|
|
77
|
+
/**
|
|
78
|
+
* Check if script uses Syriac shaper
|
|
79
|
+
*/
|
|
80
|
+
export declare function usesSyriac(script: string): boolean;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { GlyphInfo } from "../../types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Thai/Lao character categories
|
|
4
|
+
*/
|
|
5
|
+
export declare enum ThaiLaoCategory {
|
|
6
|
+
Other = 0,
|
|
7
|
+
Consonant = 1,
|
|
8
|
+
LeadingVowel = 2,// Vowels that appear before consonant
|
|
9
|
+
AboveVowel = 3,// Vowels above consonant
|
|
10
|
+
BelowVowel = 4,// Vowels below consonant
|
|
11
|
+
FollowingVowel = 5,// Vowels after consonant
|
|
12
|
+
Tone = 6,// Tone marks
|
|
13
|
+
NikhahitMaiEk = 7,// Special combining marks
|
|
14
|
+
SaraAm = 8,// Thai Sara Am (combines anusvara + aa)
|
|
15
|
+
Symbol = 9
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Check if codepoint is Thai
|
|
19
|
+
*/
|
|
20
|
+
export declare function isThai(cp: number): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Check if codepoint is Lao
|
|
23
|
+
*/
|
|
24
|
+
export declare function isLao(cp: number): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Get Thai/Lao category for a codepoint
|
|
27
|
+
*/
|
|
28
|
+
export declare function getThaiLaoCategory(cp: number): ThaiLaoCategory;
|
|
29
|
+
/**
|
|
30
|
+
* Set up masks for Thai/Lao shaping
|
|
31
|
+
*
|
|
32
|
+
* Thai/Lao require:
|
|
33
|
+
* 1. Reordering of pre-base vowels (they appear before consonant visually but after in Unicode)
|
|
34
|
+
* 2. Proper stacking of above/below vowels and tone marks
|
|
35
|
+
*/
|
|
36
|
+
export declare function setupThaiLaoMasks(infos: GlyphInfo[]): void;
|
|
37
|
+
/**
|
|
38
|
+
* Reorder Thai/Lao clusters
|
|
39
|
+
* Leading vowels (Sara E, Sara Ae, Sara O, Sara Ai Mai Muan, Sara Ai Mai Malai)
|
|
40
|
+
* are stored after consonant in Unicode but displayed before
|
|
41
|
+
*/
|
|
42
|
+
export declare function reorderThaiLao(infos: GlyphInfo[]): void;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { GlyphInfo } from "../../types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Tibetan shaper
|
|
4
|
+
* Handles Tibetan script complex text layout
|
|
5
|
+
*
|
|
6
|
+
* Tibetan is an Indic-derived script with:
|
|
7
|
+
* - Base consonants (Ka, Kha, Ga, etc.)
|
|
8
|
+
* - Subjoined consonants (below base)
|
|
9
|
+
* - Vowel signs (above/below)
|
|
10
|
+
* - Head letters (pre-composed stacks)
|
|
11
|
+
* - Various combining marks
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Tibetan character categories
|
|
15
|
+
*/
|
|
16
|
+
export declare enum TibetanCategory {
|
|
17
|
+
Other = 0,
|
|
18
|
+
Base = 1,// Base consonants (Ka-A)
|
|
19
|
+
Subjoined = 2,// Subjoined consonants (0F90-0FBC)
|
|
20
|
+
VowelAbove = 3,// Vowel signs above (0F71-0F7D, 0F80-0F83)
|
|
21
|
+
VowelBelow = 4,// Vowel signs below (0F71, 0F7A-0F7D)
|
|
22
|
+
ASubjoin = 5,// Subjoined A (0FB0)
|
|
23
|
+
HeadMark = 6,// Head marks (0F39)
|
|
24
|
+
Anusvara = 7,// Anusvara/Candrabindu (0F7E, 0F7F, 0F82, 0F83)
|
|
25
|
+
Halanta = 8,// Halanta (0F84)
|
|
26
|
+
Digit = 9,// Digits (0F20-0F33)
|
|
27
|
+
Symbol = 10,// Symbols and punctuation
|
|
28
|
+
ZWNJ = 11,// Zero Width Non-Joiner
|
|
29
|
+
ZWJ = 12
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Classify Tibetan codepoint
|
|
33
|
+
*/
|
|
34
|
+
export declare function getTibetanCategory(cp: number): TibetanCategory;
|
|
35
|
+
/**
|
|
36
|
+
* Tibetan feature masks
|
|
37
|
+
*/
|
|
38
|
+
export declare const TibetanFeatureMask: {
|
|
39
|
+
readonly ccmp: 1;
|
|
40
|
+
readonly locl: 2;
|
|
41
|
+
readonly abvs: 4;
|
|
42
|
+
readonly blws: 8;
|
|
43
|
+
readonly calt: 16;
|
|
44
|
+
readonly liga: 32;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Set up masks for Tibetan shaping
|
|
48
|
+
*/
|
|
49
|
+
export declare function setupTibetanMasks(infos: GlyphInfo[]): void;
|
|
50
|
+
/**
|
|
51
|
+
* Get default Tibetan features in order
|
|
52
|
+
*/
|
|
53
|
+
export declare function getTibetanFeatures(): string[];
|
|
54
|
+
/**
|
|
55
|
+
* Check if script uses Tibetan shaper
|
|
56
|
+
*/
|
|
57
|
+
export declare function usesTibetan(script: string): boolean;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { GlyphInfo } from "../../types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Universal Shaping Engine (USE) categories
|
|
4
|
+
* Based on Unicode USE specification
|
|
5
|
+
*/
|
|
6
|
+
export declare enum UseCategory {
|
|
7
|
+
O = 0,// Other
|
|
8
|
+
B = 1,// Base
|
|
9
|
+
CGJ = 2,// Combining Grapheme Joiner
|
|
10
|
+
CM = 3,// Consonant modifier
|
|
11
|
+
CS = 4,// Consonant with stacker
|
|
12
|
+
F = 5,// Final
|
|
13
|
+
FM = 6,// Final modifier
|
|
14
|
+
GB = 7,// Generic base
|
|
15
|
+
H = 8,// Halant/Virama
|
|
16
|
+
HN = 9,// Halant or Nukta
|
|
17
|
+
IND = 10,// Independent
|
|
18
|
+
J = 11,// Joiner
|
|
19
|
+
N = 12,// Nukta
|
|
20
|
+
R = 13,// Repha
|
|
21
|
+
S = 14,// Symbol
|
|
22
|
+
SB = 15,// Symbol modifier
|
|
23
|
+
SE = 16,// Syllable ending
|
|
24
|
+
SUB = 17,// Subjoined
|
|
25
|
+
VS = 18,// Variation selector
|
|
26
|
+
WJ = 19,// Word joiner
|
|
27
|
+
ZWJ = 20,// Zero Width Joiner
|
|
28
|
+
ZWNJ = 21,// Zero Width Non-Joiner
|
|
29
|
+
V = 22,// Vowel (independent)
|
|
30
|
+
VD = 23,// Vowel dependent
|
|
31
|
+
VMAbv = 24,// Vowel modifier above
|
|
32
|
+
VMBlw = 25,// Vowel modifier below
|
|
33
|
+
VMPre = 26,// Vowel modifier pre
|
|
34
|
+
VMPst = 27,// Vowel modifier post
|
|
35
|
+
VAbv = 28,// Vowel above
|
|
36
|
+
VBlw = 29,// Vowel below
|
|
37
|
+
VPre = 30,// Vowel pre
|
|
38
|
+
VPst = 31,// Vowel post
|
|
39
|
+
SMAbv = 32,// Syllable modifier above
|
|
40
|
+
SMBlw = 33,// Syllable modifier below
|
|
41
|
+
FAbv = 34,// Final above
|
|
42
|
+
FBlw = 35,// Final below
|
|
43
|
+
FPst = 36,// Final post
|
|
44
|
+
MAbv = 37,// Medial above
|
|
45
|
+
MBlw = 38,// Medial below
|
|
46
|
+
MPre = 39,// Medial pre
|
|
47
|
+
MPst = 40
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Check if a script uses USE
|
|
51
|
+
*/
|
|
52
|
+
export declare function usesUSE(script: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Get USE category for a codepoint
|
|
55
|
+
*/
|
|
56
|
+
export declare function getUseCategory(cp: number): UseCategory;
|
|
57
|
+
/** USE feature masks */
|
|
58
|
+
export declare const UseFeatureMask: {
|
|
59
|
+
readonly rphf: 1;
|
|
60
|
+
readonly pref: 2;
|
|
61
|
+
readonly blwf: 4;
|
|
62
|
+
readonly abvf: 8;
|
|
63
|
+
readonly pstf: 16;
|
|
64
|
+
readonly half: 32;
|
|
65
|
+
readonly cjct: 64;
|
|
66
|
+
readonly vatu: 128;
|
|
67
|
+
readonly pres: 256;
|
|
68
|
+
readonly abvs: 512;
|
|
69
|
+
readonly blws: 1024;
|
|
70
|
+
readonly psts: 2048;
|
|
71
|
+
readonly haln: 4096;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Set up masks for USE shaping
|
|
75
|
+
*/
|
|
76
|
+
export declare function setupUseMasks(infos: GlyphInfo[]): void;
|
|
77
|
+
/**
|
|
78
|
+
* Reorder USE syllables (pre-base vowels, reph)
|
|
79
|
+
*/
|
|
80
|
+
export declare function reorderUSE(infos: GlyphInfo[]): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Font } from "../font/font.ts";
|
|
2
|
+
import type { GlyphInfo, GlyphPosition } from "../types.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Fallback mark positioning when GPOS is not available
|
|
5
|
+
* Uses combining class information to position marks
|
|
6
|
+
*/
|
|
7
|
+
export declare function applyFallbackMarkPositioning(font: Font, infos: GlyphInfo[], positions: GlyphPosition[]): void;
|
|
8
|
+
/**
|
|
9
|
+
* Apply fallback kerning using kern table
|
|
10
|
+
*/
|
|
11
|
+
export declare function applyFallbackKerning(font: Font, infos: GlyphInfo[], positions: GlyphPosition[]): void;
|
|
12
|
+
/**
|
|
13
|
+
* Recategorize combining marks for proper processing
|
|
14
|
+
* Some scripts need marks to be processed in specific order
|
|
15
|
+
*/
|
|
16
|
+
export declare function recategorizeCombiningMarks(_font: Font, infos: GlyphInfo[]): void;
|