text-shaper 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +161 -0
  3. package/dist/aat/state-machine.d.ts +34 -0
  4. package/dist/buffer/glyph-buffer.d.ts +55 -0
  5. package/dist/buffer/unicode-buffer.d.ts +51 -0
  6. package/dist/font/binary/reader.d.ts +72 -0
  7. package/dist/font/face.d.ts +65 -0
  8. package/dist/font/font.d.ts +189 -0
  9. package/dist/font/tables/avar.d.ts +36 -0
  10. package/dist/font/tables/base.d.ts +79 -0
  11. package/dist/font/tables/cbdt.d.ts +120 -0
  12. package/dist/font/tables/cff-charstring.d.ts +16 -0
  13. package/dist/font/tables/cff.d.ts +93 -0
  14. package/dist/font/tables/cff2.d.ts +85 -0
  15. package/dist/font/tables/cmap.d.ts +81 -0
  16. package/dist/font/tables/colr.d.ts +278 -0
  17. package/dist/font/tables/cpal.d.ts +46 -0
  18. package/dist/font/tables/feat.d.ts +359 -0
  19. package/dist/font/tables/fvar.d.ts +77 -0
  20. package/dist/font/tables/gdef.d.ts +45 -0
  21. package/dist/font/tables/glyf.d.ts +118 -0
  22. package/dist/font/tables/gpos-contextual.d.ts +88 -0
  23. package/dist/font/tables/gpos-mark.d.ts +95 -0
  24. package/dist/font/tables/gpos.d.ts +137 -0
  25. package/dist/font/tables/gsub-contextual.d.ts +88 -0
  26. package/dist/font/tables/gsub.d.ts +107 -0
  27. package/dist/font/tables/gvar.d.ts +56 -0
  28. package/dist/font/tables/head.d.ts +47 -0
  29. package/dist/font/tables/hhea.d.ts +24 -0
  30. package/dist/font/tables/hmtx.d.ts +23 -0
  31. package/dist/font/tables/hvar.d.ts +77 -0
  32. package/dist/font/tables/jstf.d.ts +97 -0
  33. package/dist/font/tables/kern.d.ts +44 -0
  34. package/dist/font/tables/kerx.d.ts +108 -0
  35. package/dist/font/tables/loca.d.ts +31 -0
  36. package/dist/font/tables/math.d.ts +168 -0
  37. package/dist/font/tables/maxp.d.ts +27 -0
  38. package/dist/font/tables/morx.d.ts +142 -0
  39. package/dist/font/tables/mvar.d.ts +99 -0
  40. package/dist/font/tables/name.d.ts +75 -0
  41. package/dist/font/tables/os2.d.ts +102 -0
  42. package/dist/font/tables/post.d.ts +25 -0
  43. package/dist/font/tables/sbix.d.ts +65 -0
  44. package/dist/font/tables/sfnt.d.ts +20 -0
  45. package/dist/font/tables/stat.d.ts +115 -0
  46. package/dist/font/tables/svg.d.ts +40 -0
  47. package/dist/font/tables/trak.d.ts +43 -0
  48. package/dist/font/tables/vhea.d.ts +41 -0
  49. package/dist/font/tables/vmtx.d.ts +35 -0
  50. package/dist/font/tables/vorg.d.ts +33 -0
  51. package/dist/font/tables/vvar.d.ts +36 -0
  52. package/dist/index.d.ts +80 -0
  53. package/dist/index.js +9 -0
  54. package/dist/index.js.map +92 -0
  55. package/dist/index.test.d.ts +1 -0
  56. package/dist/layout/justify.d.ts +88 -0
  57. package/dist/layout/structures/class-def.d.ts +15 -0
  58. package/dist/layout/structures/coverage.d.ts +17 -0
  59. package/dist/layout/structures/device.d.ts +58 -0
  60. package/dist/layout/structures/feature-variations.d.ts +82 -0
  61. package/dist/layout/structures/layout-common.d.ts +77 -0
  62. package/dist/render/path.d.ts +136 -0
  63. package/dist/shaper/complex/arabic.d.ts +60 -0
  64. package/dist/shaper/complex/ethiopic.d.ts +70 -0
  65. package/dist/shaper/complex/georgian.d.ts +69 -0
  66. package/dist/shaper/complex/hangul.d.ts +64 -0
  67. package/dist/shaper/complex/hebrew.d.ts +28 -0
  68. package/dist/shaper/complex/indic.d.ts +117 -0
  69. package/dist/shaper/complex/khmer.d.ts +48 -0
  70. package/dist/shaper/complex/mongolian.d.ts +89 -0
  71. package/dist/shaper/complex/myanmar.d.ts +47 -0
  72. package/dist/shaper/complex/syriac.d.ts +80 -0
  73. package/dist/shaper/complex/thai-lao.d.ts +42 -0
  74. package/dist/shaper/complex/tibetan.d.ts +57 -0
  75. package/dist/shaper/complex/use.d.ts +80 -0
  76. package/dist/shaper/fallback.d.ts +16 -0
  77. package/dist/shaper/features.d.ts +189 -0
  78. package/dist/shaper/shape-plan.d.ts +29 -0
  79. package/dist/shaper/shaper.d.ts +18 -0
  80. package/dist/types.d.ts +153 -0
  81. package/dist/typeshaper.js +7 -0
  82. package/dist/unicode/bidi/brackets.d.ts +7 -0
  83. package/dist/unicode/bidi/brackets.data.d.ts +5 -0
  84. package/dist/unicode/bidi/char-types.d.ts +19 -0
  85. package/dist/unicode/bidi/char-types.data.d.ts +25 -0
  86. package/dist/unicode/bidi/embedding-levels.d.ts +18 -0
  87. package/dist/unicode/bidi/index.d.ts +9 -0
  88. package/dist/unicode/bidi/mirroring.d.ts +10 -0
  89. package/dist/unicode/bidi/mirroring.data.d.ts +2 -0
  90. package/dist/unicode/bidi/parse-character-map.d.ts +8 -0
  91. package/dist/unicode/bidi/reordering.d.ts +18 -0
  92. package/dist/unicode/bidi.d.ts +93 -0
  93. package/dist/unicode/line-break.d.ts +113 -0
  94. package/dist/unicode/normalize.d.ts +36 -0
  95. package/dist/unicode/script.d.ts +215 -0
  96. package/dist/unicode/segmentation.d.ts +104 -0
  97. package/package.json +33 -0
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Unicode Text Segmentation (UAX #29)
3
+ * Grapheme cluster and word boundaries
4
+ */
5
+ import type { GlyphInfo } from "../types.ts";
6
+ /**
7
+ * Grapheme cluster break property
8
+ */
9
+ export declare enum GraphemeBreakProperty {
10
+ Other = 0,
11
+ CR = 1,
12
+ LF = 2,
13
+ Control = 3,
14
+ Extend = 4,
15
+ ZWJ = 5,
16
+ Regional_Indicator = 6,
17
+ Prepend = 7,
18
+ SpacingMark = 8,
19
+ L = 9,// Hangul L
20
+ V = 10,// Hangul V
21
+ T = 11,// Hangul T
22
+ LV = 12,// Hangul LV
23
+ LVT = 13,// Hangul LVT
24
+ Extended_Pictographic = 14
25
+ }
26
+ /**
27
+ * Word break property
28
+ */
29
+ export declare enum WordBreakProperty {
30
+ Other = 0,
31
+ CR = 1,
32
+ LF = 2,
33
+ Newline = 3,
34
+ Extend = 4,
35
+ ZWJ = 5,
36
+ Regional_Indicator = 6,
37
+ Format = 7,
38
+ Katakana = 8,
39
+ Hebrew_Letter = 9,
40
+ ALetter = 10,
41
+ Single_Quote = 11,
42
+ Double_Quote = 12,
43
+ MidNumLet = 13,
44
+ MidLetter = 14,
45
+ MidNum = 15,
46
+ Numeric = 16,
47
+ ExtendNumLet = 17,
48
+ WSegSpace = 18,
49
+ Extended_Pictographic = 19
50
+ }
51
+ /**
52
+ * Get grapheme break property for codepoint
53
+ */
54
+ export declare function getGraphemeBreakProperty(cp: number): GraphemeBreakProperty;
55
+ /**
56
+ * Get word break property for codepoint
57
+ */
58
+ export declare function getWordBreakProperty(cp: number): WordBreakProperty;
59
+ /**
60
+ * Grapheme cluster boundary result
61
+ */
62
+ export interface GraphemeBoundaries {
63
+ /** Boundary positions (indices where clusters end) */
64
+ boundaries: number[];
65
+ /** Grapheme break properties */
66
+ properties: GraphemeBreakProperty[];
67
+ }
68
+ /**
69
+ * Find grapheme cluster boundaries in codepoints
70
+ */
71
+ export declare function findGraphemeBoundaries(codepoints: number[]): GraphemeBoundaries;
72
+ /**
73
+ * Word boundary result
74
+ */
75
+ export interface WordBoundaries {
76
+ /** Boundary positions */
77
+ boundaries: number[];
78
+ /** Word break properties */
79
+ properties: WordBreakProperty[];
80
+ }
81
+ /**
82
+ * Find word boundaries in codepoints
83
+ */
84
+ export declare function findWordBoundaries(codepoints: number[]): WordBoundaries;
85
+ /**
86
+ * Split text into grapheme clusters
87
+ */
88
+ export declare function splitGraphemes(text: string): string[];
89
+ /**
90
+ * Split text into words
91
+ */
92
+ export declare function splitWords(text: string): string[];
93
+ /**
94
+ * Count grapheme clusters in text
95
+ */
96
+ export declare function countGraphemes(text: string): number;
97
+ /**
98
+ * Analyze grapheme boundaries for glyph infos
99
+ */
100
+ export declare function analyzeGraphemesForGlyphs(infos: GlyphInfo[]): GraphemeBoundaries;
101
+ /**
102
+ * Analyze word boundaries for glyph infos
103
+ */
104
+ export declare function analyzeWordsForGlyphs(infos: GlyphInfo[]): WordBoundaries;
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "text-shaper",
3
+ "version": "0.0.1",
4
+ "description": "Pure TypeScript text shaping engine",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": ["dist"],
16
+ "scripts": {
17
+ "build": "bun build ./src/index.ts --outdir ./dist --target browser --minify --sourcemap=linked",
18
+ "build:prod": "bun build ./src/index.ts --outdir ./dist --target browser --production --sourcemap=external",
19
+ "build:analyze": "bun build ./src/index.ts --outdir ./dist --target browser --minify --metafile=./dist/meta.json",
20
+ "build:dts": "tsc -p tsconfig.build.json",
21
+ "typecheck": "tsc --noEmit",
22
+ "lint": "biome check --write --unsafe --max-diagnostics 99999",
23
+ "check": "bun run typecheck && bun run lint",
24
+ "prepublishOnly": "bun run build:prod && bun run build:dts"
25
+ },
26
+ "devDependencies": {
27
+ "@biomejs/biome": "2.3.8",
28
+ "@types/bun": "latest"
29
+ },
30
+ "peerDependencies": {
31
+ "typescript": "^5"
32
+ }
33
+ }