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,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bidi bracket pair functions
|
|
3
|
+
* Port of bidi-js brackets.js
|
|
4
|
+
*/
|
|
5
|
+
export declare function openingToClosingBracket(char: string): string | null;
|
|
6
|
+
export declare function closingToOpeningBracket(char: string): string | null;
|
|
7
|
+
export declare function getCanonicalBracket(char: string): string | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bidi character type detection
|
|
3
|
+
* Port of bidi-js charTypes.js
|
|
4
|
+
*/
|
|
5
|
+
export declare const TYPES: Record<string, number>;
|
|
6
|
+
export declare const TYPES_TO_NAMES: Record<number, string>;
|
|
7
|
+
export declare const ISOLATE_INIT_TYPES: number;
|
|
8
|
+
export declare const STRONG_TYPES: number;
|
|
9
|
+
export declare const NEUTRAL_ISOLATE_TYPES: number;
|
|
10
|
+
export declare const BN_LIKE_TYPES: number;
|
|
11
|
+
export declare const TRAILING_TYPES: number;
|
|
12
|
+
/**
|
|
13
|
+
* Get the bidi character type for a character
|
|
14
|
+
*/
|
|
15
|
+
export declare function getBidiCharType(char: string): number;
|
|
16
|
+
/**
|
|
17
|
+
* Get the name of a bidi character type
|
|
18
|
+
*/
|
|
19
|
+
export declare function getBidiCharTypeName(char: string): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
R: string;
|
|
3
|
+
EN: string;
|
|
4
|
+
ES: string;
|
|
5
|
+
ET: string;
|
|
6
|
+
AN: string;
|
|
7
|
+
CS: string;
|
|
8
|
+
B: string;
|
|
9
|
+
S: string;
|
|
10
|
+
WS: string;
|
|
11
|
+
ON: string;
|
|
12
|
+
BN: string;
|
|
13
|
+
NSM: string;
|
|
14
|
+
AL: string;
|
|
15
|
+
LRO: string;
|
|
16
|
+
RLO: string;
|
|
17
|
+
LRE: string;
|
|
18
|
+
RLE: string;
|
|
19
|
+
PDF: string;
|
|
20
|
+
LRI: string;
|
|
21
|
+
RLI: string;
|
|
22
|
+
FSI: string;
|
|
23
|
+
PDI: string;
|
|
24
|
+
};
|
|
25
|
+
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bidi embedding levels calculation (UAX #9)
|
|
3
|
+
* Port of bidi-js embeddingLevels.js
|
|
4
|
+
*/
|
|
5
|
+
export interface EmbeddingLevelsResult {
|
|
6
|
+
paragraphs: Array<{
|
|
7
|
+
start: number;
|
|
8
|
+
end: number;
|
|
9
|
+
level: number;
|
|
10
|
+
}>;
|
|
11
|
+
levels: Uint8Array;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* This function applies the Bidirectional Algorithm to a string, returning the resolved embedding levels
|
|
15
|
+
* in a single Uint8Array plus a list of objects holding each paragraph's start and end indices and resolved
|
|
16
|
+
* base embedding level.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getEmbeddingLevels(string: string, baseDirection?: "ltr" | "rtl" | "auto"): EmbeddingLevelsResult;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bidi algorithm implementation
|
|
3
|
+
* Port of bidi-js
|
|
4
|
+
*/
|
|
5
|
+
export { closingToOpeningBracket, getCanonicalBracket, openingToClosingBracket, } from "./brackets.ts";
|
|
6
|
+
export { BN_LIKE_TYPES, getBidiCharType, getBidiCharTypeName, ISOLATE_INIT_TYPES, NEUTRAL_ISOLATE_TYPES, STRONG_TYPES, TRAILING_TYPES, TYPES, TYPES_TO_NAMES, } from "./char-types.ts";
|
|
7
|
+
export { type EmbeddingLevelsResult, getEmbeddingLevels, } from "./embedding-levels.ts";
|
|
8
|
+
export { getMirroredCharacter, getMirroredCharactersMap, } from "./mirroring.ts";
|
|
9
|
+
export { getReorderedIndices, getReorderedString, getReorderSegments, } from "./reordering.ts";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bidi character mirroring
|
|
3
|
+
* Port of bidi-js mirroring.js
|
|
4
|
+
*/
|
|
5
|
+
export declare function getMirroredCharacter(char: string): string | null;
|
|
6
|
+
/**
|
|
7
|
+
* Given a string and its resolved embedding levels, build a map of indices to replacement chars
|
|
8
|
+
* for any characters in right-to-left segments that have defined mirrored characters.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getMirroredCharactersMap(string: string, embeddingLevels: Uint8Array, start?: number, end?: number): Map<number, string>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "14>1,j>2,t>2,u>2,1a>g,2v3>1,1>1,1ge>1,1wd>1,b>1,1j>1,f>1,ai>3,-2>3,+1,8>1k0,-1jq>1y7,-1y6>1hf,-1he>1h6,-1h5>1ha,-1h8>1qi,-1pu>1,6>3u,-3s>7,6>1,1>1,f>1,1>1,+2,3>1,1>1,+13,4>1,1>1,6>1eo,-1ee>1,3>1mg,-1me>1mk,-1mj>1mi,-1mg>1mi,-1md>1,1>1,+2,1>10k,-103>1,1>1,4>1,5>1,1>1,+10,3>1,1>8,-7>8,+1,-6>7,+1,a>1,1>1,u>1,u6>1,1>1,+5,26>1,1>1,2>1,2>2,8>1,7>1,4>1,1>1,+5,b8>1,1>1,+3,1>3,-2>1,2>1,1>1,+2,c>1,3>1,1>1,+2,h>1,3>1,a>1,1>1,2>1,3>1,1>1,d>1,f>1,3>1,1a>1,1>1,6>1,7>1,13>1,k>1,1>1,+19,4>1,1>1,+2,2>1,1>1,+18,m>1,a>1,1>1,lk>1,1>1,4>1,2>1,f>1,3>1,1>1,+3,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,6>1,4j>1,j>2,t>2,u>2,2>1,+1";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses an string that holds encoded codepoint mappings, e.g. for bracket pairs or
|
|
3
|
+
* mirroring characters. Returns an object holding the `map`, and optionally a `reverseMap`.
|
|
4
|
+
*/
|
|
5
|
+
export declare function parseCharacterMap(encodedString: string, includeReverse: boolean): {
|
|
6
|
+
map: Map<string, string>;
|
|
7
|
+
reverseMap: Map<string, string> | null;
|
|
8
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bidi reordering
|
|
3
|
+
* Port of bidi-js reordering.js
|
|
4
|
+
*/
|
|
5
|
+
import type { EmbeddingLevelsResult } from "./embedding-levels.ts";
|
|
6
|
+
/**
|
|
7
|
+
* Given a start and end denoting a single line within a string, and a set of precalculated
|
|
8
|
+
* bidi embedding levels, produce a list of segments whose ordering should be flipped, in sequence.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getReorderSegments(string: string, embeddingLevelsResult: EmbeddingLevelsResult, start?: number, end?: number): Array<[number, number]>;
|
|
11
|
+
/**
|
|
12
|
+
* Get the reordered string with bidi segments reversed
|
|
13
|
+
*/
|
|
14
|
+
export declare function getReorderedString(string: string, embedLevelsResult: EmbeddingLevelsResult, start?: number, end?: number): string;
|
|
15
|
+
/**
|
|
16
|
+
* Get an array with character indices in their new bidi order
|
|
17
|
+
*/
|
|
18
|
+
export declare function getReorderedIndices(string: string, embedLevelsResult: EmbeddingLevelsResult, start?: number, end?: number): number[];
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bidirectional text processing (UAX #9)
|
|
3
|
+
*/
|
|
4
|
+
import type { GlyphInfo } from "../types.ts";
|
|
5
|
+
import { Direction } from "../types.ts";
|
|
6
|
+
/**
|
|
7
|
+
* Result of BiDi processing
|
|
8
|
+
*/
|
|
9
|
+
export interface BidiResult {
|
|
10
|
+
/** Embedding levels per character */
|
|
11
|
+
levels: Uint8Array;
|
|
12
|
+
/** Paragraph information */
|
|
13
|
+
paragraphs: BidiParagraph[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Paragraph info from BiDi algorithm
|
|
17
|
+
*/
|
|
18
|
+
export interface BidiParagraph {
|
|
19
|
+
start: number;
|
|
20
|
+
end: number;
|
|
21
|
+
level: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get embedding levels for a string
|
|
25
|
+
*/
|
|
26
|
+
export declare function getEmbeddings(text: string, baseDirection?: Direction): BidiResult;
|
|
27
|
+
/**
|
|
28
|
+
* Get reordered indices for visual display
|
|
29
|
+
*/
|
|
30
|
+
export declare function getVisualOrder(text: string, result: BidiResult, start?: number, end?: number): number[];
|
|
31
|
+
/**
|
|
32
|
+
* Apply BiDi reordering to glyph infos
|
|
33
|
+
*/
|
|
34
|
+
export declare function reorderGlyphs(infos: GlyphInfo[], result: BidiResult): GlyphInfo[];
|
|
35
|
+
/**
|
|
36
|
+
* Get mirrored character for RTL contexts
|
|
37
|
+
*/
|
|
38
|
+
export declare function getMirror(codepoint: number): number;
|
|
39
|
+
/**
|
|
40
|
+
* Apply character mirroring for RTL runs
|
|
41
|
+
*/
|
|
42
|
+
export declare function applyMirroring(infos: GlyphInfo[], levels: Uint8Array): void;
|
|
43
|
+
/**
|
|
44
|
+
* BiDi character type constants
|
|
45
|
+
*/
|
|
46
|
+
export declare const BidiType: {
|
|
47
|
+
readonly L: 1;
|
|
48
|
+
readonly R: 2;
|
|
49
|
+
readonly EN: 4;
|
|
50
|
+
readonly ES: 8;
|
|
51
|
+
readonly ET: 16;
|
|
52
|
+
readonly AN: 32;
|
|
53
|
+
readonly CS: 64;
|
|
54
|
+
readonly B: 128;
|
|
55
|
+
readonly S: 256;
|
|
56
|
+
readonly WS: 512;
|
|
57
|
+
readonly ON: 1024;
|
|
58
|
+
readonly BN: 2048;
|
|
59
|
+
readonly NSM: 4096;
|
|
60
|
+
readonly AL: 8192;
|
|
61
|
+
readonly LRO: 16384;
|
|
62
|
+
readonly RLO: 32768;
|
|
63
|
+
readonly LRE: 65536;
|
|
64
|
+
readonly RLE: 131072;
|
|
65
|
+
readonly PDF: 262144;
|
|
66
|
+
readonly LRI: 524288;
|
|
67
|
+
readonly RLI: 1048576;
|
|
68
|
+
readonly FSI: 2097152;
|
|
69
|
+
readonly PDI: 4194304;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Get BiDi character type for a character
|
|
73
|
+
*/
|
|
74
|
+
export declare function getCharType(char: string): number;
|
|
75
|
+
/**
|
|
76
|
+
* Check if a character is strongly RTL
|
|
77
|
+
*/
|
|
78
|
+
export declare function isRTL(codepoint: number): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Check if a character is strongly LTR
|
|
81
|
+
*/
|
|
82
|
+
export declare function isLTR(codepoint: number): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Detect base direction from text content
|
|
85
|
+
*/
|
|
86
|
+
export declare function detectDirection(text: string): Direction;
|
|
87
|
+
/**
|
|
88
|
+
* Full BiDi processing for shaping
|
|
89
|
+
*/
|
|
90
|
+
export declare function processBidi(infos: GlyphInfo[], baseDirection?: Direction): {
|
|
91
|
+
infos: GlyphInfo[];
|
|
92
|
+
levels: Uint8Array;
|
|
93
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unicode Line Breaking Algorithm (UAX #14)
|
|
3
|
+
* Determines line break opportunities in text
|
|
4
|
+
*/
|
|
5
|
+
import type { GlyphInfo } from "../types.ts";
|
|
6
|
+
/**
|
|
7
|
+
* Line break class from UAX #14
|
|
8
|
+
*/
|
|
9
|
+
export declare enum LineBreakClass {
|
|
10
|
+
BK = 0,// Mandatory Break
|
|
11
|
+
CR = 1,// Carriage Return
|
|
12
|
+
LF = 2,// Line Feed
|
|
13
|
+
CM = 3,// Combining Mark
|
|
14
|
+
NL = 4,// Next Line
|
|
15
|
+
SG = 5,// Surrogate (not used)
|
|
16
|
+
WJ = 6,// Word Joiner
|
|
17
|
+
ZW = 7,// Zero Width Space
|
|
18
|
+
GL = 8,// Non-breaking ("Glue")
|
|
19
|
+
SP = 9,// Space
|
|
20
|
+
ZWJ = 10,// Zero Width Joiner
|
|
21
|
+
B2 = 11,// Break Opportunity Before and After
|
|
22
|
+
BA = 12,// Break After
|
|
23
|
+
BB = 13,// Break Before
|
|
24
|
+
HY = 14,// Hyphen
|
|
25
|
+
CB = 15,// Contingent Break Opportunity
|
|
26
|
+
CL = 16,// Close Punctuation
|
|
27
|
+
CP = 17,// Close Parenthesis
|
|
28
|
+
EX = 18,// Exclamation/Interrogation
|
|
29
|
+
IN = 19,// Inseparable
|
|
30
|
+
NS = 20,// Nonstarter
|
|
31
|
+
OP = 21,// Open Punctuation
|
|
32
|
+
QU = 22,// Quotation
|
|
33
|
+
IS = 23,// Infix Numeric Separator
|
|
34
|
+
NU = 24,// Numeric
|
|
35
|
+
PO = 25,// Postfix Numeric
|
|
36
|
+
PR = 26,// Prefix Numeric
|
|
37
|
+
SY = 27,// Symbols Allowing Break After
|
|
38
|
+
AI = 28,// Ambiguous (Alphabetic or Ideographic)
|
|
39
|
+
AL = 29,// Alphabetic
|
|
40
|
+
CJ = 30,// Conditional Japanese Starter
|
|
41
|
+
EB = 31,// Emoji Base
|
|
42
|
+
EM = 32,// Emoji Modifier
|
|
43
|
+
H2 = 33,// Hangul LV Syllable
|
|
44
|
+
H3 = 34,// Hangul LVT Syllable
|
|
45
|
+
HL = 35,// Hebrew Letter
|
|
46
|
+
ID = 36,// Ideographic
|
|
47
|
+
JL = 37,// Hangul L Jamo
|
|
48
|
+
JV = 38,// Hangul V Jamo
|
|
49
|
+
JT = 39,// Hangul T Jamo
|
|
50
|
+
RI = 40,// Regional Indicator
|
|
51
|
+
SA = 41,// Complex Context Dependent (South East Asian)
|
|
52
|
+
XX = 42
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Break action
|
|
56
|
+
*/
|
|
57
|
+
export declare enum BreakAction {
|
|
58
|
+
Direct = 0,// Direct break opportunity (after space)
|
|
59
|
+
Indirect = 1,// Indirect break (only if spaces intervene)
|
|
60
|
+
CombiningIndirect = 2,// Indirect break for combining marks
|
|
61
|
+
CombiningProhibited = 3,// Prohibited break for combining marks
|
|
62
|
+
Prohibited = 4,// No break allowed
|
|
63
|
+
Explicit = 5
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Line break opportunity
|
|
67
|
+
*/
|
|
68
|
+
export declare enum BreakOpportunity {
|
|
69
|
+
NoBreak = 0,
|
|
70
|
+
Optional = 1,
|
|
71
|
+
Mandatory = 2
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get line break class for a codepoint
|
|
75
|
+
*/
|
|
76
|
+
export declare function getLineBreakClass(cp: number): LineBreakClass;
|
|
77
|
+
/**
|
|
78
|
+
* Result of line break analysis
|
|
79
|
+
*/
|
|
80
|
+
export interface LineBreakAnalysis {
|
|
81
|
+
/** Break opportunities (one per character boundary) */
|
|
82
|
+
breaks: BreakOpportunity[];
|
|
83
|
+
/** Line break classes for each character */
|
|
84
|
+
classes: LineBreakClass[];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Analyze line break opportunities in text
|
|
88
|
+
*/
|
|
89
|
+
export declare function analyzeLineBreaks(text: string): LineBreakAnalysis;
|
|
90
|
+
/**
|
|
91
|
+
* Analyze line break opportunities from codepoints
|
|
92
|
+
*/
|
|
93
|
+
export declare function analyzeLineBreaksFromCodepoints(codepoints: number[]): LineBreakAnalysis;
|
|
94
|
+
/**
|
|
95
|
+
* Analyze line breaks for glyph infos
|
|
96
|
+
*/
|
|
97
|
+
export declare function analyzeLineBreaksForGlyphs(infos: GlyphInfo[]): LineBreakAnalysis;
|
|
98
|
+
/**
|
|
99
|
+
* Find next line break opportunity
|
|
100
|
+
*/
|
|
101
|
+
export declare function findNextBreak(analysis: LineBreakAnalysis, startIndex: number): number;
|
|
102
|
+
/**
|
|
103
|
+
* Check if break is allowed at position
|
|
104
|
+
*/
|
|
105
|
+
export declare function canBreakAt(analysis: LineBreakAnalysis, index: number): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Check if break is mandatory at position
|
|
108
|
+
*/
|
|
109
|
+
export declare function mustBreakAt(analysis: LineBreakAnalysis, index: number): boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Get all break opportunities
|
|
112
|
+
*/
|
|
113
|
+
export declare function getAllBreakOpportunities(analysis: LineBreakAnalysis): number[];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { GlyphInfo } from "../types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Normalization mode for shaping
|
|
4
|
+
*/
|
|
5
|
+
export declare enum NormalizationMode {
|
|
6
|
+
/** No normalization */
|
|
7
|
+
None = 0,
|
|
8
|
+
/** Decompose (NFD-like) */
|
|
9
|
+
Decompose = 1,
|
|
10
|
+
/** Compose (NFC-like) */
|
|
11
|
+
Compose = 2,
|
|
12
|
+
/** Auto-detect based on script */
|
|
13
|
+
Auto = 3
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Canonical Combining Class (ccc) for combining marks
|
|
17
|
+
* Based on Unicode 15.0
|
|
18
|
+
*/
|
|
19
|
+
export declare function getCombiningClass(cp: number): number;
|
|
20
|
+
/**
|
|
21
|
+
* Reorder combining marks according to canonical combining class
|
|
22
|
+
*/
|
|
23
|
+
export declare function reorderMarks(infos: GlyphInfo[]): void;
|
|
24
|
+
/**
|
|
25
|
+
* Decompose a codepoint if it has a canonical decomposition
|
|
26
|
+
*/
|
|
27
|
+
export declare function decompose(cp: number): number[] | null;
|
|
28
|
+
/**
|
|
29
|
+
* Try to compose a base character with a combining mark
|
|
30
|
+
* Returns the composed character or null if no composition exists
|
|
31
|
+
*/
|
|
32
|
+
export declare function tryCompose(base: number, combining: number): number | null;
|
|
33
|
+
/**
|
|
34
|
+
* Apply normalization to glyph infos
|
|
35
|
+
*/
|
|
36
|
+
export declare function normalize(infos: GlyphInfo[], mode: NormalizationMode): GlyphInfo[];
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unicode Script Detection
|
|
3
|
+
* Detects the script of text based on codepoints
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Unicode script values (ISO 15924)
|
|
7
|
+
*/
|
|
8
|
+
export declare enum Script {
|
|
9
|
+
Common = "Zyyy",
|
|
10
|
+
Inherited = "Zinh",
|
|
11
|
+
Unknown = "Zzzz",
|
|
12
|
+
Latin = "Latn",
|
|
13
|
+
Greek = "Grek",
|
|
14
|
+
Cyrillic = "Cyrl",
|
|
15
|
+
Armenian = "Armn",
|
|
16
|
+
Hebrew = "Hebr",
|
|
17
|
+
Arabic = "Arab",
|
|
18
|
+
Syriac = "Syrc",
|
|
19
|
+
Thaana = "Thaa",
|
|
20
|
+
Devanagari = "Deva",
|
|
21
|
+
Bengali = "Beng",
|
|
22
|
+
Gurmukhi = "Guru",
|
|
23
|
+
Gujarati = "Gujr",
|
|
24
|
+
Oriya = "Orya",
|
|
25
|
+
Tamil = "Taml",
|
|
26
|
+
Telugu = "Telu",
|
|
27
|
+
Kannada = "Knda",
|
|
28
|
+
Malayalam = "Mlym",
|
|
29
|
+
Sinhala = "Sinh",
|
|
30
|
+
Thai = "Thai",
|
|
31
|
+
Lao = "Laoo",
|
|
32
|
+
Tibetan = "Tibt",
|
|
33
|
+
Myanmar = "Mymr",
|
|
34
|
+
Georgian = "Geor",
|
|
35
|
+
Hangul = "Hang",
|
|
36
|
+
Ethiopic = "Ethi",
|
|
37
|
+
Cherokee = "Cher",
|
|
38
|
+
CanadianAboriginal = "Cans",
|
|
39
|
+
Ogham = "Ogam",
|
|
40
|
+
Runic = "Runr",
|
|
41
|
+
Khmer = "Khmr",
|
|
42
|
+
Mongolian = "Mong",
|
|
43
|
+
Hiragana = "Hira",
|
|
44
|
+
Katakana = "Kana",
|
|
45
|
+
Bopomofo = "Bopo",
|
|
46
|
+
Han = "Hani",
|
|
47
|
+
Yi = "Yiii",
|
|
48
|
+
OldItalic = "Ital",
|
|
49
|
+
Gothic = "Goth",
|
|
50
|
+
Deseret = "Dsrt",
|
|
51
|
+
Tagalog = "Tglg",
|
|
52
|
+
Hanunoo = "Hano",
|
|
53
|
+
Buhid = "Buhd",
|
|
54
|
+
Tagbanwa = "Tagb",
|
|
55
|
+
Limbu = "Limb",
|
|
56
|
+
TaiLe = "Tale",
|
|
57
|
+
LinearB = "Linb",
|
|
58
|
+
Ugaritic = "Ugar",
|
|
59
|
+
Shavian = "Shaw",
|
|
60
|
+
Osmanya = "Osma",
|
|
61
|
+
Cypriot = "Cprt",
|
|
62
|
+
Braille = "Brai",
|
|
63
|
+
Buginese = "Bugi",
|
|
64
|
+
Coptic = "Copt",
|
|
65
|
+
NewTaiLue = "Talu",
|
|
66
|
+
Glagolitic = "Glag",
|
|
67
|
+
Tifinagh = "Tfng",
|
|
68
|
+
SylotiNagri = "Sylo",
|
|
69
|
+
OldPersian = "Xpeo",
|
|
70
|
+
Kharoshthi = "Khar",
|
|
71
|
+
Balinese = "Bali",
|
|
72
|
+
Cuneiform = "Xsux",
|
|
73
|
+
Phoenician = "Phnx",
|
|
74
|
+
PhagsPa = "Phag",
|
|
75
|
+
Nko = "Nkoo",
|
|
76
|
+
Sundanese = "Sund",
|
|
77
|
+
Lepcha = "Lepc",
|
|
78
|
+
OlChiki = "Olck",
|
|
79
|
+
Vai = "Vaii",
|
|
80
|
+
Saurashtra = "Saur",
|
|
81
|
+
KayahLi = "Kali",
|
|
82
|
+
Rejang = "Rjng",
|
|
83
|
+
Lycian = "Lyci",
|
|
84
|
+
Carian = "Cari",
|
|
85
|
+
Lydian = "Lydi",
|
|
86
|
+
Cham = "Cham",
|
|
87
|
+
TaiTham = "Lana",
|
|
88
|
+
TaiViet = "Tavt",
|
|
89
|
+
Avestan = "Avst",
|
|
90
|
+
EgyptianHieroglyphs = "Egyp",
|
|
91
|
+
Samaritan = "Samr",
|
|
92
|
+
Lisu = "Lisu",
|
|
93
|
+
Bamum = "Bamu",
|
|
94
|
+
Javanese = "Java",
|
|
95
|
+
MeeteiMayek = "Mtei",
|
|
96
|
+
ImperialAramaic = "Armi",
|
|
97
|
+
OldSouthArabian = "Sarb",
|
|
98
|
+
InscriptionalParthian = "Prti",
|
|
99
|
+
InscriptionalPahlavi = "Phli",
|
|
100
|
+
OldTurkic = "Orkh",
|
|
101
|
+
Kaithi = "Kthi",
|
|
102
|
+
Batak = "Batk",
|
|
103
|
+
Brahmi = "Brah",
|
|
104
|
+
Mandaic = "Mand",
|
|
105
|
+
Chakma = "Cakm",
|
|
106
|
+
MeroiticCursive = "Merc",
|
|
107
|
+
MeroiticHieroglyphs = "Mero",
|
|
108
|
+
Miao = "Plrd",
|
|
109
|
+
Sharada = "Shrd",
|
|
110
|
+
SoraSompeng = "Sora",
|
|
111
|
+
Takri = "Takr",
|
|
112
|
+
CaucasianAlbanian = "Aghb",
|
|
113
|
+
BassaVah = "Bass",
|
|
114
|
+
Duployan = "Dupl",
|
|
115
|
+
Elbasan = "Elba",
|
|
116
|
+
Grantha = "Gran",
|
|
117
|
+
PahawhHmong = "Hmng",
|
|
118
|
+
Khojki = "Khoj",
|
|
119
|
+
LinearA = "Lina",
|
|
120
|
+
Mahajani = "Mahj",
|
|
121
|
+
Manichaean = "Mani",
|
|
122
|
+
MendeKikakui = "Mend",
|
|
123
|
+
Modi = "Modi",
|
|
124
|
+
Mro = "Mroo",
|
|
125
|
+
OldNorthArabian = "Narb",
|
|
126
|
+
Nabataean = "Nbat",
|
|
127
|
+
Palmyrene = "Palm",
|
|
128
|
+
PauCinHau = "Pauc",
|
|
129
|
+
OldPermic = "Perm",
|
|
130
|
+
PsalterPahlavi = "Phlp",
|
|
131
|
+
Siddham = "Sidd",
|
|
132
|
+
Khudawadi = "Sind",
|
|
133
|
+
Tirhuta = "Tirh",
|
|
134
|
+
WarangCiti = "Wara",
|
|
135
|
+
Ahom = "Ahom",
|
|
136
|
+
AnatolianHieroglyphs = "Hluw",
|
|
137
|
+
Hatran = "Hatr",
|
|
138
|
+
Multani = "Mult",
|
|
139
|
+
OldHungarian = "Hung",
|
|
140
|
+
SignWriting = "Sgnw",
|
|
141
|
+
Adlam = "Adlm",
|
|
142
|
+
Bhaiksuki = "Bhks",
|
|
143
|
+
Marchen = "Marc",
|
|
144
|
+
Newa = "Newa",
|
|
145
|
+
Osage = "Osge",
|
|
146
|
+
Tangut = "Tang",
|
|
147
|
+
MasaramGondi = "Gonm",
|
|
148
|
+
Nushu = "Nshu",
|
|
149
|
+
Soyombo = "Soyo",
|
|
150
|
+
ZanabazarSquare = "Zanb",
|
|
151
|
+
Dogra = "Dogr",
|
|
152
|
+
GunjalaGondi = "Gong",
|
|
153
|
+
Makasar = "Maka",
|
|
154
|
+
Medefaidrin = "Medf",
|
|
155
|
+
HanifiRohingya = "Rohg",
|
|
156
|
+
Sogdian = "Sogd",
|
|
157
|
+
OldSogdian = "Sogo",
|
|
158
|
+
Elymaic = "Elym",
|
|
159
|
+
Nandinagari = "Nand",
|
|
160
|
+
NyiakengPuachueHmong = "Hmnp",
|
|
161
|
+
Wancho = "Wcho",
|
|
162
|
+
Yezidi = "Yezi",
|
|
163
|
+
Chorasmian = "Chrs",
|
|
164
|
+
DivesAkuru = "Diak",
|
|
165
|
+
KhitanSmallScript = "Kits",
|
|
166
|
+
Vithkuqi = "Vith",
|
|
167
|
+
OldUyghur = "Ougr",
|
|
168
|
+
Cypro_Minoan = "Cpmn",
|
|
169
|
+
Tangsa = "Tnsa",
|
|
170
|
+
Toto = "Toto",
|
|
171
|
+
Kawi = "Kawi",
|
|
172
|
+
NagMundari = "Nagm"
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Get script for a codepoint using binary search
|
|
176
|
+
*/
|
|
177
|
+
export declare function getScript(cp: number): Script;
|
|
178
|
+
/**
|
|
179
|
+
* Get script for a string (returns the dominant non-Common/Inherited script)
|
|
180
|
+
*/
|
|
181
|
+
export declare function detectScript(text: string): Script;
|
|
182
|
+
/**
|
|
183
|
+
* Get all scripts present in text
|
|
184
|
+
*/
|
|
185
|
+
export declare function getScripts(text: string): Script[];
|
|
186
|
+
/**
|
|
187
|
+
* Check if text contains only characters from a specific script
|
|
188
|
+
* (Common and Inherited are allowed)
|
|
189
|
+
*/
|
|
190
|
+
export declare function isScript(text: string, script: Script): boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Script run - a contiguous sequence of characters with the same script
|
|
193
|
+
*/
|
|
194
|
+
export interface ScriptRun {
|
|
195
|
+
script: Script;
|
|
196
|
+
start: number;
|
|
197
|
+
end: number;
|
|
198
|
+
text: string;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Split text into script runs
|
|
202
|
+
*/
|
|
203
|
+
export declare function getScriptRuns(text: string): ScriptRun[];
|
|
204
|
+
/**
|
|
205
|
+
* Get OpenType script tag for a Unicode script
|
|
206
|
+
*/
|
|
207
|
+
export declare function getScriptTag(script: Script): string;
|
|
208
|
+
/**
|
|
209
|
+
* Check if a script requires complex shaping
|
|
210
|
+
*/
|
|
211
|
+
export declare function isComplexScript(script: Script): boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Get script direction (LTR or RTL)
|
|
214
|
+
*/
|
|
215
|
+
export declare function getScriptDirection(script: Script): "ltr" | "rtl";
|