@cantoo/fontkit 2.0.4 → 2.0.5
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/dist/browser-module.mjs +28 -28
- package/dist/browser-module.mjs.map +1 -1
- package/dist/browser.cjs +28 -28
- package/dist/browser.cjs.map +1 -1
- package/dist/main.cjs +28 -28
- package/dist/main.cjs.map +1 -1
- package/dist/module.mjs +28 -28
- package/dist/module.mjs.map +1 -1
- package/package.json +2 -1
- package/src/CmapProcessor.js +2 -2
- package/src/DFont.js +5 -5
- package/src/TTFFont.js +11 -15
- package/src/TrueTypeCollection.js +10 -10
- package/src/WOFF2Font.js +0 -6
- package/src/aat/AATFeatureMap.js +21 -22
- package/src/aat/AATLayoutEngine.js +1 -1
- package/src/aat/AATLookupTable.js +2 -2
- package/src/aat/AATMorxProcessor.js +14 -14
- package/src/aat/AATStateMachine.js +3 -3
- package/src/base.js +1 -1
- package/src/cff/CFFDict.js +2 -2
- package/src/cff/CFFFont.js +1 -1
- package/src/cff/CFFIndex.js +4 -4
- package/src/cff/CFFOperand.js +1 -11
- package/src/cff/CFFPrivateDict.js +20 -20
- package/src/cff/CFFStandardStrings.js +67 -67
- package/src/cff/CFFTop.js +58 -58
- package/src/decorators.js +3 -3
- package/src/encodings.js +111 -111
- package/src/glyph/CFFGlyph.js +3 -4
- package/src/glyph/COLRGlyph.js +2 -2
- package/src/glyph/Glyph.js +4 -4
- package/src/glyph/GlyphVariationProcessor.js +23 -28
- package/src/glyph/Path.js +14 -14
- package/src/glyph/SBIXGlyph.js +2 -2
- package/src/glyph/TTFGlyph.js +31 -38
- package/src/glyph/TTFGlyphEncoder.js +26 -26
- package/src/glyph/WOFF2Glyph.js +2 -2
- package/src/layout/GlyphRun.js +3 -3
- package/src/layout/KernProcessor.js +1 -1
- package/src/layout/LayoutEngine.js +13 -14
- package/src/layout/Script.js +25 -25
- package/src/layout/UnicodeLayoutEngine.js +5 -6
- package/src/opentype/GlyphInfo.js +1 -1
- package/src/opentype/GlyphIterator.js +2 -2
- package/src/opentype/OTProcessor.js +8 -8
- package/src/opentype/ShapingPlan.js +1 -2
- package/src/opentype/shapers/ArabicShaper.js +8 -8
- package/src/opentype/shapers/DefaultShaper.js +3 -3
- package/src/opentype/shapers/HangulShaper.js +35 -35
- package/src/opentype/shapers/HebrewShaper.js +5 -5
- package/src/opentype/shapers/IndicShaper.js +20 -20
- package/src/opentype/shapers/ThaiShaper.js +15 -15
- package/src/opentype/shapers/UniversalShaper.js +2 -2
- package/src/opentype/shapers/index.js +33 -33
- package/src/opentype/shapers/indic-data.js +2 -2
- package/src/packages/unicode-properties/data-trie.js +1 -1
- package/src/packages/unicode-properties/data.js +1 -1
- package/src/packages/unicode-properties/dist/index.cjs +1 -1
- package/src/packages/unicode-properties/dist/index.cjs.map +2 -2
- package/src/packages/unicode-properties/dist/index.mjs +1 -1
- package/src/packages/unicode-properties/dist/index.mjs.map +2 -2
- package/src/packages/unicode-properties/generate.js +3 -4
- package/src/packages/unicode-properties/index.js +30 -30
- package/src/packages/unicode-properties/package.json +1 -1
- package/src/packages/unicode-trie/builder.js +18 -22
- package/src/packages/unicode-trie/dist/builder.cjs +6 -9
- package/src/packages/unicode-trie/dist/builder.cjs.map +2 -2
- package/src/packages/unicode-trie/dist/builder.mjs +6 -9
- package/src/packages/unicode-trie/dist/builder.mjs.map +2 -2
- package/src/packages/unicode-trie/dist/index.cjs.map +2 -2
- package/src/packages/unicode-trie/dist/index.mjs.map +2 -2
- package/src/packages/unicode-trie/index.js +1 -2
- package/src/packages/unicode-trie/package.json +1 -1
- package/src/packages/unicode-trie/swap.js +2 -2
- package/src/subset/Subset.js +2 -2
- package/src/subset/TTFSubset.js +5 -5
- package/src/tables/BASE.js +27 -27
- package/src/tables/COLR.js +9 -9
- package/src/tables/CPAL.js +1 -1
- package/src/tables/DSIG.js +7 -7
- package/src/tables/EBDT.js +0 -1
- package/src/tables/EBLC.js +3 -3
- package/src/tables/GDEF.js +17 -17
- package/src/tables/GPOS.js +74 -74
- package/src/tables/GSUB.js +37 -37
- package/src/tables/JSTF.js +16 -16
- package/src/tables/LTSH.js +3 -3
- package/src/tables/OS2.js +49 -49
- package/src/tables/PCLT.js +15 -15
- package/src/tables/VDMX.js +17 -17
- package/src/tables/VORG.js +7 -7
- package/src/tables/WOFF2Directory.js +2 -2
- package/src/tables/WOFFDirectory.js +18 -18
- package/src/tables/aat.js +2 -2
- package/src/tables/cmap.js +63 -63
- package/src/tables/directory.js +14 -14
- package/src/tables/gasp.js +5 -5
- package/src/tables/glyf.js +1 -1
- package/src/tables/hdmx.js +7 -7
- package/src/tables/head.js +16 -16
- package/src/tables/hhea.js +14 -14
- package/src/tables/hmtx.js +2 -2
- package/src/tables/index.js +0 -5
- package/src/tables/just.js +1 -1
- package/src/tables/kern.js +42 -42
- package/src/tables/loca.js +2 -2
- package/src/tables/maxp.js +15 -15
- package/src/tables/morx.js +16 -16
- package/src/tables/name.js +18 -18
- package/src/tables/opentype.js +91 -91
- package/src/tables/post.js +10 -10
- package/src/tables/variations.js +6 -6
- package/src/tables/vhea.js +14 -14
- package/src/tables/vmtx.js +3 -3
package/src/glyph/TTFGlyph.js
CHANGED
|
@@ -6,32 +6,32 @@ import * as r from 'restructure';
|
|
|
6
6
|
// The header for both simple and composite glyphs
|
|
7
7
|
let GlyfHeader = new r.Struct({
|
|
8
8
|
numberOfContours: r.int16, // if negative, this is a composite glyph
|
|
9
|
-
xMin:
|
|
10
|
-
yMin:
|
|
11
|
-
xMax:
|
|
12
|
-
yMax:
|
|
9
|
+
xMin: r.int16,
|
|
10
|
+
yMin: r.int16,
|
|
11
|
+
xMax: r.int16,
|
|
12
|
+
yMax: r.int16
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
// Flags for simple glyphs
|
|
16
|
-
const ON_CURVE
|
|
17
|
-
const X_SHORT_VECTOR
|
|
18
|
-
const Y_SHORT_VECTOR
|
|
19
|
-
const REPEAT
|
|
20
|
-
const SAME_X
|
|
21
|
-
const SAME_Y
|
|
16
|
+
const ON_CURVE = 1 << 0;
|
|
17
|
+
const X_SHORT_VECTOR = 1 << 1;
|
|
18
|
+
const Y_SHORT_VECTOR = 1 << 2;
|
|
19
|
+
const REPEAT = 1 << 3;
|
|
20
|
+
const SAME_X = 1 << 4;
|
|
21
|
+
const SAME_Y = 1 << 5;
|
|
22
22
|
|
|
23
23
|
// Flags for composite glyphs
|
|
24
|
-
const ARG_1_AND_2_ARE_WORDS
|
|
25
|
-
const _ARGS_ARE_XY_VALUES
|
|
26
|
-
const _ROUND_XY_TO_GRID
|
|
27
|
-
const WE_HAVE_A_SCALE
|
|
28
|
-
const MORE_COMPONENTS
|
|
29
|
-
const WE_HAVE_AN_X_AND_Y_SCALE
|
|
30
|
-
const WE_HAVE_A_TWO_BY_TWO
|
|
31
|
-
const WE_HAVE_INSTRUCTIONS
|
|
32
|
-
const _USE_MY_METRICS
|
|
33
|
-
const _OVERLAP_COMPOUND
|
|
34
|
-
const _SCALED_COMPONENT_OFFSET
|
|
24
|
+
const ARG_1_AND_2_ARE_WORDS = 1 << 0;
|
|
25
|
+
const _ARGS_ARE_XY_VALUES = 1 << 1;
|
|
26
|
+
const _ROUND_XY_TO_GRID = 1 << 2;
|
|
27
|
+
const WE_HAVE_A_SCALE = 1 << 3;
|
|
28
|
+
const MORE_COMPONENTS = 1 << 5;
|
|
29
|
+
const WE_HAVE_AN_X_AND_Y_SCALE = 1 << 6;
|
|
30
|
+
const WE_HAVE_A_TWO_BY_TWO = 1 << 7;
|
|
31
|
+
const WE_HAVE_INSTRUCTIONS = 1 << 8;
|
|
32
|
+
const _USE_MY_METRICS = 1 << 9;
|
|
33
|
+
const _OVERLAP_COMPOUND = 1 << 10;
|
|
34
|
+
const _SCALED_COMPONENT_OFFSET = 1 << 11;
|
|
35
35
|
const _UNSCALED_COMPONENT_OFFSET = 1 << 12;
|
|
36
36
|
|
|
37
37
|
// Represents a point in a simple glyph
|
|
@@ -124,7 +124,6 @@ export default class TTFGlyph extends Glyph {
|
|
|
124
124
|
|
|
125
125
|
if (glyph.numberOfContours > 0) {
|
|
126
126
|
this._decodeSimple(glyph, stream);
|
|
127
|
-
|
|
128
127
|
} else if (glyph.numberOfContours < 0) {
|
|
129
128
|
this._decodeComposite(glyph, stream, startPos);
|
|
130
129
|
}
|
|
@@ -212,18 +211,16 @@ export default class TTFGlyph extends Glyph {
|
|
|
212
211
|
|
|
213
212
|
if (flags & WE_HAVE_A_SCALE) {
|
|
214
213
|
// fixed number with 14 bits of fraction
|
|
215
|
-
component.scaleX
|
|
216
|
-
|
|
217
|
-
|
|
214
|
+
component.scaleX
|
|
215
|
+
= component.scaleY = ((stream.readUInt8() << 24) | (stream.readUInt8() << 16)) / 1073741824;
|
|
218
216
|
} else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) {
|
|
219
217
|
component.scaleX = ((stream.readUInt8() << 24) | (stream.readUInt8() << 16)) / 1073741824;
|
|
220
218
|
component.scaleY = ((stream.readUInt8() << 24) | (stream.readUInt8() << 16)) / 1073741824;
|
|
221
|
-
|
|
222
219
|
} else if (flags & WE_HAVE_A_TWO_BY_TWO) {
|
|
223
|
-
component.scaleX
|
|
220
|
+
component.scaleX = ((stream.readUInt8() << 24) | (stream.readUInt8() << 16)) / 1073741824;
|
|
224
221
|
component.scale01 = ((stream.readUInt8() << 24) | (stream.readUInt8() << 16)) / 1073741824;
|
|
225
222
|
component.scale10 = ((stream.readUInt8() << 24) | (stream.readUInt8() << 16)) / 1073741824;
|
|
226
|
-
component.scaleY
|
|
223
|
+
component.scaleY = ((stream.readUInt8() << 24) | (stream.readUInt8() << 16)) / 1073741824;
|
|
227
224
|
}
|
|
228
225
|
|
|
229
226
|
glyph.components.push(component);
|
|
@@ -302,11 +299,11 @@ export default class TTFGlyph extends Glyph {
|
|
|
302
299
|
// Recompute and cache metrics if we performed variation processing, and don't have an HVAR table
|
|
303
300
|
if (glyph.phantomPoints && !this._font.directory.tables.HVAR) {
|
|
304
301
|
let m = this._metrics;
|
|
305
|
-
m.advanceWidth
|
|
302
|
+
m.advanceWidth = glyph.phantomPoints[1].x - glyph.phantomPoints[0].x;
|
|
306
303
|
m.advanceHeight = glyph.phantomPoints[3].y - glyph.phantomPoints[2].y;
|
|
307
|
-
m.leftBearing
|
|
308
|
-
m.topBearing
|
|
309
|
-
m.rightBearing
|
|
304
|
+
m.leftBearing = glyph.xMin - glyph.phantomPoints[0].x;
|
|
305
|
+
m.topBearing = glyph.phantomPoints[2].y - glyph.yMax;
|
|
306
|
+
m.rightBearing = m.advanceWidth - m.leftBearing - m.width;
|
|
310
307
|
m.bottomBearing = m.advanceHeight - m.topBearing - m.height;
|
|
311
308
|
}
|
|
312
309
|
|
|
@@ -343,7 +340,7 @@ export default class TTFGlyph extends Glyph {
|
|
|
343
340
|
// Converts contours to a Path object that can be rendered
|
|
344
341
|
_getPath() {
|
|
345
342
|
let contours = this._getContours();
|
|
346
|
-
let path = new Path;
|
|
343
|
+
let path = new Path();
|
|
347
344
|
|
|
348
345
|
for (let i = 0; i < contours.length; i++) {
|
|
349
346
|
let contour = contours[i];
|
|
@@ -376,22 +373,18 @@ export default class TTFGlyph extends Glyph {
|
|
|
376
373
|
|
|
377
374
|
if (prevPt.onCurve && pt.onCurve) {
|
|
378
375
|
path.lineTo(pt.x, pt.y);
|
|
379
|
-
|
|
380
376
|
} else if (prevPt.onCurve && !pt.onCurve) {
|
|
381
377
|
curvePt = pt;
|
|
382
|
-
|
|
383
378
|
} else if (!prevPt.onCurve && !pt.onCurve) {
|
|
384
379
|
let midX = (prevPt.x + pt.x) / 2;
|
|
385
380
|
let midY = (prevPt.y + pt.y) / 2;
|
|
386
381
|
path.quadraticCurveTo(prevPt.x, prevPt.y, midX, midY);
|
|
387
382
|
curvePt = pt;
|
|
388
|
-
|
|
389
383
|
} else if (!prevPt.onCurve && pt.onCurve) {
|
|
390
384
|
path.quadraticCurveTo(curvePt.x, curvePt.y, pt.x, pt.y);
|
|
391
385
|
curvePt = null;
|
|
392
|
-
|
|
393
386
|
} else {
|
|
394
|
-
throw new Error(
|
|
387
|
+
throw new Error('Unknown TTF path state');
|
|
395
388
|
}
|
|
396
389
|
}
|
|
397
390
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import * as r from 'restructure';
|
|
2
2
|
|
|
3
3
|
// Flags for simple glyphs
|
|
4
|
-
const ON_CURVE
|
|
5
|
-
const X_SHORT_VECTOR
|
|
6
|
-
const Y_SHORT_VECTOR
|
|
7
|
-
const REPEAT
|
|
8
|
-
const SAME_X
|
|
9
|
-
const SAME_Y
|
|
4
|
+
const ON_CURVE = 1 << 0;
|
|
5
|
+
const X_SHORT_VECTOR = 1 << 1;
|
|
6
|
+
const Y_SHORT_VECTOR = 1 << 2;
|
|
7
|
+
const REPEAT = 1 << 3;
|
|
8
|
+
const SAME_X = 1 << 4;
|
|
9
|
+
const SAME_Y = 1 << 5;
|
|
10
10
|
|
|
11
11
|
class Point {
|
|
12
12
|
static size(val) {
|
|
13
13
|
return val >= 0 && val <= 255 ? 1 : 2;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
static encode(stream, value) {
|
|
17
17
|
if (value >= 0 && value <= 255) {
|
|
18
18
|
stream.writeUInt8(value);
|
|
@@ -47,15 +47,15 @@ export default class TTFGlyphEncoder {
|
|
|
47
47
|
let same = 0;
|
|
48
48
|
let lastX = 0, lastY = 0, lastFlag = 0;
|
|
49
49
|
let pointCount = 0;
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
for (let i = 0; i < path.commands.length; i++) {
|
|
52
52
|
let c = path.commands[i];
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
for (let j = 0; j < c.args.length; j += 2) {
|
|
55
55
|
let x = c.args[j];
|
|
56
56
|
let y = c.args[j + 1];
|
|
57
57
|
let flag = 0;
|
|
58
|
-
|
|
58
|
+
|
|
59
59
|
// If the ending point of a quadratic curve is the midpoint
|
|
60
60
|
// between the control point and the control point of the next
|
|
61
61
|
// quadratic curve, we can omit the ending point.
|
|
@@ -64,21 +64,21 @@ export default class TTFGlyphEncoder {
|
|
|
64
64
|
if (next && next.command === 'quadraticCurveTo') {
|
|
65
65
|
let midX = (lastX + next.args[0]) / 2;
|
|
66
66
|
let midY = (lastY + next.args[1]) / 2;
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
if (x === midX && y === midY) {
|
|
69
69
|
continue;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
// All points except control points are on curve.
|
|
75
75
|
if (!(c.command === 'quadraticCurveTo' && j === 0)) {
|
|
76
76
|
flag |= ON_CURVE;
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
|
|
79
79
|
flag = this._encodePoint(x, lastX, xPoints, flag, X_SHORT_VECTOR, SAME_X);
|
|
80
80
|
flag = this._encodePoint(y, lastY, yPoints, flag, Y_SHORT_VECTOR, SAME_Y);
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
if (flag === lastFlag && same < 255) {
|
|
83
83
|
flags[flags.length - 1] |= REPEAT;
|
|
84
84
|
same++;
|
|
@@ -87,16 +87,16 @@ export default class TTFGlyphEncoder {
|
|
|
87
87
|
flags.push(same);
|
|
88
88
|
same = 0;
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
|
|
91
91
|
flags.push(flag);
|
|
92
92
|
lastFlag = flag;
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
|
|
95
95
|
lastX = x;
|
|
96
96
|
lastY = y;
|
|
97
97
|
pointCount++;
|
|
98
98
|
}
|
|
99
|
-
|
|
99
|
+
|
|
100
100
|
if (c.command === 'closePath') {
|
|
101
101
|
endPtsOfContours.push(pointCount - 1);
|
|
102
102
|
}
|
|
@@ -106,7 +106,7 @@ export default class TTFGlyphEncoder {
|
|
|
106
106
|
if (path.commands.length > 1 && path.commands[path.commands.length - 1].command !== 'closePath') {
|
|
107
107
|
endPtsOfContours.push(pointCount - 1);
|
|
108
108
|
}
|
|
109
|
-
|
|
109
|
+
|
|
110
110
|
let bbox = path.bbox;
|
|
111
111
|
let glyf = {
|
|
112
112
|
numberOfContours: endPtsOfContours.length,
|
|
@@ -120,24 +120,24 @@ export default class TTFGlyphEncoder {
|
|
|
120
120
|
xPoints: xPoints,
|
|
121
121
|
yPoints: yPoints
|
|
122
122
|
};
|
|
123
|
-
|
|
123
|
+
|
|
124
124
|
let size = Glyf.size(glyf);
|
|
125
125
|
let tail = 4 - (size % 4);
|
|
126
|
-
|
|
126
|
+
|
|
127
127
|
let stream = new r.EncodeStream(size + tail);
|
|
128
128
|
Glyf.encode(stream, glyf);
|
|
129
|
-
|
|
129
|
+
|
|
130
130
|
// Align to 4-byte length
|
|
131
131
|
if (tail !== 0) {
|
|
132
132
|
stream.fill(0, tail);
|
|
133
133
|
}
|
|
134
|
-
|
|
134
|
+
|
|
135
135
|
return stream.buffer;
|
|
136
136
|
}
|
|
137
|
-
|
|
137
|
+
|
|
138
138
|
_encodePoint(value, last, points, flag, shortFlag, sameFlag) {
|
|
139
139
|
let diff = value - last;
|
|
140
|
-
|
|
140
|
+
|
|
141
141
|
if (value === last) {
|
|
142
142
|
flag |= sameFlag;
|
|
143
143
|
} else {
|
|
@@ -149,10 +149,10 @@ export default class TTFGlyphEncoder {
|
|
|
149
149
|
flag |= sameFlag;
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
|
|
152
|
+
|
|
153
153
|
points.push(diff);
|
|
154
154
|
}
|
|
155
|
-
|
|
155
|
+
|
|
156
156
|
return flag;
|
|
157
157
|
}
|
|
158
158
|
}
|
package/src/glyph/WOFF2Glyph.js
CHANGED
|
@@ -26,7 +26,7 @@ export default class WOFF2Glyph extends TTFGlyph {
|
|
|
26
26
|
xMin: 0,
|
|
27
27
|
yMin: 0,
|
|
28
28
|
xMax: 0,
|
|
29
|
-
yMax: 0
|
|
29
|
+
yMax: 0
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
if (cached.points) {
|
|
@@ -37,7 +37,7 @@ export default class WOFF2Glyph extends TTFGlyph {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
if (cached.components) {
|
|
40
|
-
glyph.components = cached.components.map(c => {
|
|
40
|
+
glyph.components = cached.components.map((c) => {
|
|
41
41
|
return Object.assign(Object.create(Object.getPrototypeOf(c)), c);
|
|
42
42
|
});
|
|
43
43
|
|
package/src/layout/GlyphRun.js
CHANGED
|
@@ -69,7 +69,7 @@ export default class GlyphRun {
|
|
|
69
69
|
return width;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
/**
|
|
73
73
|
* The total advance height of the run.
|
|
74
74
|
* @type {number}
|
|
75
75
|
*/
|
|
@@ -82,12 +82,12 @@ export default class GlyphRun {
|
|
|
82
82
|
return height;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
/**
|
|
86
86
|
* The bounding box containing all glyphs in the run.
|
|
87
87
|
* @type {BBox}
|
|
88
88
|
*/
|
|
89
89
|
get bbox() {
|
|
90
|
-
let bbox = new BBox;
|
|
90
|
+
let bbox = new BBox();
|
|
91
91
|
|
|
92
92
|
let x = 0;
|
|
93
93
|
let y = 0;
|
|
@@ -16,7 +16,6 @@ export default class LayoutEngine {
|
|
|
16
16
|
// scripts are currently supported because the shaping logic is built into the font.
|
|
17
17
|
if (this.font.morx) {
|
|
18
18
|
this.engine = new AATLayoutEngine(this.font);
|
|
19
|
-
|
|
20
19
|
} else if (this.font.GSUB || this.font.GPOS) {
|
|
21
20
|
this.engine = new OTLayoutEngine(this.font);
|
|
22
21
|
}
|
|
@@ -137,22 +136,22 @@ export default class LayoutEngine {
|
|
|
137
136
|
if (plane === 0) {
|
|
138
137
|
// BMP
|
|
139
138
|
switch (ch >> 8) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
139
|
+
case 0x00: return ch === 0x00AD;
|
|
140
|
+
case 0x03: return ch === 0x034F;
|
|
141
|
+
case 0x06: return ch === 0x061C;
|
|
142
|
+
case 0x17: return 0x17B4 <= ch && ch <= 0x17B5;
|
|
143
|
+
case 0x18: return 0x180B <= ch && ch <= 0x180E;
|
|
144
|
+
case 0x20: return (0x200B <= ch && ch <= 0x200F) || (0x202A <= ch && ch <= 0x202E) || (0x2060 <= ch && ch <= 0x206F);
|
|
145
|
+
case 0xFE: return (0xFE00 <= ch && ch <= 0xFE0F) || ch === 0xFEFF;
|
|
146
|
+
case 0xFF: return 0xFFF0 <= ch && ch <= 0xFFF8;
|
|
147
|
+
default: return false;
|
|
149
148
|
}
|
|
150
149
|
} else {
|
|
151
150
|
// Other planes
|
|
152
151
|
switch (plane) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
152
|
+
case 0x01: return (0x1BCA0 <= ch && ch <= 0x1BCA3) || (0x1D173 <= ch && ch <= 0x1D17A);
|
|
153
|
+
case 0x0E: return 0xE0000 <= ch && ch <= 0xE0FFF;
|
|
154
|
+
default: return false;
|
|
156
155
|
}
|
|
157
156
|
}
|
|
158
157
|
}
|
|
@@ -172,7 +171,7 @@ export default class LayoutEngine {
|
|
|
172
171
|
}
|
|
173
172
|
|
|
174
173
|
stringsForGlyph(gid) {
|
|
175
|
-
let result = new Set;
|
|
174
|
+
let result = new Set();
|
|
176
175
|
|
|
177
176
|
let codePoints = this.font._cmapProcessor.codePointsForGlyph(gid);
|
|
178
177
|
for (let codePoint of codePoints) {
|
package/src/layout/Script.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {getScript} from '../packages/unicode-properties/index.js';
|
|
1
|
+
import { getScript } from '../packages/unicode-properties/index.js';
|
|
2
2
|
|
|
3
3
|
// This maps the Unicode Script property to an OpenType script tag
|
|
4
4
|
// Data from http://www.microsoft.com/typography/otspec/scripttags.htm
|
|
@@ -193,33 +193,33 @@ export function forCodePoints(codePoints) {
|
|
|
193
193
|
|
|
194
194
|
// The scripts in this map are written from right to left
|
|
195
195
|
const RTL = {
|
|
196
|
-
arab: true,
|
|
197
|
-
hebr: true,
|
|
198
|
-
syrc: true,
|
|
199
|
-
thaa: true,
|
|
200
|
-
cprt: true,
|
|
201
|
-
khar: true,
|
|
202
|
-
phnx: true,
|
|
196
|
+
arab: true, // Arabic
|
|
197
|
+
hebr: true, // Hebrew
|
|
198
|
+
syrc: true, // Syriac
|
|
199
|
+
thaa: true, // Thaana
|
|
200
|
+
cprt: true, // Cypriot Syllabary
|
|
201
|
+
khar: true, // Kharosthi
|
|
202
|
+
phnx: true, // Phoenician
|
|
203
203
|
'nko ': true, // N'Ko
|
|
204
|
-
lydi: true,
|
|
205
|
-
avst: true,
|
|
206
|
-
armi: true,
|
|
207
|
-
phli: true,
|
|
208
|
-
prti: true,
|
|
209
|
-
sarb: true,
|
|
210
|
-
orkh: true,
|
|
211
|
-
samr: true,
|
|
212
|
-
mand: true,
|
|
213
|
-
merc: true,
|
|
214
|
-
mero: true,
|
|
204
|
+
lydi: true, // Lydian
|
|
205
|
+
avst: true, // Avestan
|
|
206
|
+
armi: true, // Imperial Aramaic
|
|
207
|
+
phli: true, // Inscriptional Pahlavi
|
|
208
|
+
prti: true, // Inscriptional Parthian
|
|
209
|
+
sarb: true, // Old South Arabian
|
|
210
|
+
orkh: true, // Old Turkic, Orkhon Runic
|
|
211
|
+
samr: true, // Samaritan
|
|
212
|
+
mand: true, // Mandaic, Mandaean
|
|
213
|
+
merc: true, // Meroitic Cursive
|
|
214
|
+
mero: true, // Meroitic Hieroglyphs
|
|
215
215
|
|
|
216
216
|
// Unicode 7.0 (not listed on http://www.microsoft.com/typography/otspec/scripttags.htm)
|
|
217
|
-
mani: true,
|
|
218
|
-
mend: true,
|
|
219
|
-
nbat: true,
|
|
220
|
-
narb: true,
|
|
221
|
-
palm: true,
|
|
222
|
-
phlp: true
|
|
217
|
+
mani: true, // Manichaean
|
|
218
|
+
mend: true, // Mende Kikakui
|
|
219
|
+
nbat: true, // Nabataean
|
|
220
|
+
narb: true, // Old North Arabian
|
|
221
|
+
palm: true, // Palmyrene
|
|
222
|
+
phlp: true // Psalter Pahlavi
|
|
223
223
|
};
|
|
224
224
|
|
|
225
225
|
export function direction(script) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {getCombiningClass} from '../packages/unicode-properties/index.js';
|
|
1
|
+
import { getCombiningClass } from '../packages/unicode-properties/index.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This class is used when GPOS does not define 'mark' or 'mkmk' features
|
|
@@ -125,7 +125,6 @@ export default class UnicodeLayoutEngine {
|
|
|
125
125
|
position.xAdvance = position.yAdvance = 0;
|
|
126
126
|
position.xOffset += xOffset;
|
|
127
127
|
position.yOffset += yOffset;
|
|
128
|
-
|
|
129
128
|
} else {
|
|
130
129
|
xOffset -= position.xAdvance;
|
|
131
130
|
yOffset -= position.yAdvance;
|
|
@@ -203,7 +202,7 @@ export default class UnicodeLayoutEngine {
|
|
|
203
202
|
case 'CCC21': // dagesh
|
|
204
203
|
break;
|
|
205
204
|
|
|
206
|
-
|
|
205
|
+
// Arabic and Syriac
|
|
207
206
|
|
|
208
207
|
case 'CCC27': // fathatan
|
|
209
208
|
case 'CCC28': // dammatan
|
|
@@ -219,7 +218,7 @@ export default class UnicodeLayoutEngine {
|
|
|
219
218
|
case 'CCC32': // kasra
|
|
220
219
|
return 'Below';
|
|
221
220
|
|
|
222
|
-
|
|
221
|
+
// Thai
|
|
223
222
|
|
|
224
223
|
case 'CCC103': // sara u / sara uu
|
|
225
224
|
return 'Below_Right';
|
|
@@ -227,7 +226,7 @@ export default class UnicodeLayoutEngine {
|
|
|
227
226
|
case 'CCC107': // mai
|
|
228
227
|
return 'Above_Right';
|
|
229
228
|
|
|
230
|
-
|
|
229
|
+
// Lao
|
|
231
230
|
|
|
232
231
|
case 'CCC118': // sign u / sign uu
|
|
233
232
|
return 'Below';
|
|
@@ -235,7 +234,7 @@ export default class UnicodeLayoutEngine {
|
|
|
235
234
|
case 'CCC122': // mai
|
|
236
235
|
return 'Above';
|
|
237
236
|
|
|
238
|
-
|
|
237
|
+
// Tibetan
|
|
239
238
|
|
|
240
239
|
case 'CCC129': // sign aa
|
|
241
240
|
case 'CCC132': // sign u
|
|
@@ -30,8 +30,8 @@ export default class GlyphIterator {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
return (this.flags.ignoreBaseGlyphs && glyph.isBase)
|
|
34
|
-
|
|
33
|
+
return (this.flags.ignoreBaseGlyphs && glyph.isBase)
|
|
34
|
+
|| (this.flags.ignoreLigatures && glyph.isLigature);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
move(dir) {
|
|
@@ -175,7 +175,7 @@ export default class OTProcessor {
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
variationConditionsMatch(conditions, coords) {
|
|
178
|
-
return conditions.every(condition => {
|
|
178
|
+
return conditions.every((condition) => {
|
|
179
179
|
let coord = condition.axisIndex < coords.length ? coords[condition.axisIndex] : 0;
|
|
180
180
|
return condition.filterRangeMinValue <= coord && coord <= condition.filterRangeMaxValue;
|
|
181
181
|
});
|
|
@@ -221,7 +221,7 @@ export default class OTProcessor {
|
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
applyLookup(_lookup, _table) {
|
|
224
|
-
throw new Error(
|
|
224
|
+
throw new Error('applyLookup must be implemented by subclasses');
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
applyLookupList(lookupRecords) {
|
|
@@ -447,9 +447,9 @@ export default class OTProcessor {
|
|
|
447
447
|
}
|
|
448
448
|
|
|
449
449
|
for (let rule of rules) {
|
|
450
|
-
if (this.classSequenceMatches(-rule.backtrack.length, [...rule.backtrack].reverse(), table.backtrackClassDef)
|
|
451
|
-
this.classSequenceMatches(1, rule.input, table.inputClassDef)
|
|
452
|
-
this.classSequenceMatches(1 + rule.input.length, rule.lookahead, table.lookaheadClassDef)) {
|
|
450
|
+
if (this.classSequenceMatches(-rule.backtrack.length, [...rule.backtrack].reverse(), table.backtrackClassDef)
|
|
451
|
+
&& this.classSequenceMatches(1, rule.input, table.inputClassDef)
|
|
452
|
+
&& this.classSequenceMatches(1 + rule.input.length, rule.lookahead, table.lookaheadClassDef)) {
|
|
453
453
|
return this.applyLookupList(rule.lookupRecords);
|
|
454
454
|
}
|
|
455
455
|
}
|
|
@@ -458,9 +458,9 @@ export default class OTProcessor {
|
|
|
458
458
|
}
|
|
459
459
|
|
|
460
460
|
case 3:
|
|
461
|
-
if (this.coverageSequenceMatches(-table.backtrackGlyphCount, [...table.backtrackCoverage].reverse())
|
|
462
|
-
this.coverageSequenceMatches(0, table.inputCoverage)
|
|
463
|
-
this.coverageSequenceMatches(table.inputGlyphCount, table.lookaheadCoverage)) {
|
|
461
|
+
if (this.coverageSequenceMatches(-table.backtrackGlyphCount, [...table.backtrackCoverage].reverse())
|
|
462
|
+
&& this.coverageSequenceMatches(0, table.inputCoverage)
|
|
463
|
+
&& this.coverageSequenceMatches(table.inputGlyphCount, table.lookaheadCoverage)) {
|
|
464
464
|
return this.applyLookupList(table.lookupRecords);
|
|
465
465
|
}
|
|
466
466
|
|
|
@@ -55,7 +55,7 @@ export default class ShapingPlan {
|
|
|
55
55
|
this._addFeatures(arg.global || [], true);
|
|
56
56
|
this._addFeatures(arg.local || [], false);
|
|
57
57
|
} else {
|
|
58
|
-
throw new Error(
|
|
58
|
+
throw new Error('Unsupported argument to ShapingPlan#add');
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -112,7 +112,6 @@ export default class ShapingPlan {
|
|
|
112
112
|
if (!positions) {
|
|
113
113
|
stage(this.font, glyphs, this);
|
|
114
114
|
}
|
|
115
|
-
|
|
116
115
|
} else if (stage.length > 0) {
|
|
117
116
|
processor.applyFeatures(stage, glyphs, positions);
|
|
118
117
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import DefaultShaper from './DefaultShaper';
|
|
2
|
-
import {getCategory} from '../../packages/unicode-properties/index.js';
|
|
2
|
+
import { getCategory } from '../../packages/unicode-properties/index.js';
|
|
3
3
|
import UnicodeTrie from '../../packages/unicode-trie/index.js';
|
|
4
4
|
import { decodeBase64 } from '../../utils';
|
|
5
5
|
import dataTrie from './data.trie';
|
|
@@ -31,25 +31,25 @@ const NONE = null;
|
|
|
31
31
|
const STATE_TABLE = [
|
|
32
32
|
// Non_Joining, Left_Joining, Right_Joining, Dual_Joining, ALAPH, DALATH RISH
|
|
33
33
|
// State 0: prev was U, not willing to join.
|
|
34
|
-
[
|
|
34
|
+
[[NONE, NONE, 0], [NONE, ISOL, 2], [NONE, ISOL, 1], [NONE, ISOL, 2], [NONE, ISOL, 1], [NONE, ISOL, 6]],
|
|
35
35
|
|
|
36
36
|
// State 1: prev was R or ISOL/ALAPH, not willing to join.
|
|
37
|
-
[
|
|
37
|
+
[[NONE, NONE, 0], [NONE, ISOL, 2], [NONE, ISOL, 1], [NONE, ISOL, 2], [NONE, FIN2, 5], [NONE, ISOL, 6]],
|
|
38
38
|
|
|
39
39
|
// State 2: prev was D/L in ISOL form, willing to join.
|
|
40
|
-
[
|
|
40
|
+
[[NONE, NONE, 0], [NONE, ISOL, 2], [INIT, FINA, 1], [INIT, FINA, 3], [INIT, FINA, 4], [INIT, FINA, 6]],
|
|
41
41
|
|
|
42
42
|
// State 3: prev was D in FINA form, willing to join.
|
|
43
|
-
[
|
|
43
|
+
[[NONE, NONE, 0], [NONE, ISOL, 2], [MEDI, FINA, 1], [MEDI, FINA, 3], [MEDI, FINA, 4], [MEDI, FINA, 6]],
|
|
44
44
|
|
|
45
45
|
// State 4: prev was FINA ALAPH, not willing to join.
|
|
46
|
-
[
|
|
46
|
+
[[NONE, NONE, 0], [NONE, ISOL, 2], [MED2, ISOL, 1], [MED2, ISOL, 2], [MED2, FIN2, 5], [MED2, ISOL, 6]],
|
|
47
47
|
|
|
48
48
|
// State 5: prev was FIN2/FIN3 ALAPH, not willing to join.
|
|
49
|
-
[
|
|
49
|
+
[[NONE, NONE, 0], [NONE, ISOL, 2], [ISOL, ISOL, 1], [ISOL, ISOL, 2], [ISOL, FIN2, 5], [ISOL, ISOL, 6]],
|
|
50
50
|
|
|
51
51
|
// State 6: prev was DALATH/RISH, not willing to join.
|
|
52
|
-
[
|
|
52
|
+
[[NONE, NONE, 0], [NONE, ISOL, 2], [NONE, ISOL, 1], [NONE, ISOL, 2], [NONE, FIN3, 5], [NONE, ISOL, 6]]
|
|
53
53
|
];
|
|
54
54
|
|
|
55
55
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {isDigit, isMark} from '../../packages/unicode-properties/index.js';
|
|
1
|
+
import { isDigit, isMark } from '../../packages/unicode-properties/index.js';
|
|
2
2
|
import GlyphInfo from '../GlyphInfo';
|
|
3
3
|
|
|
4
4
|
const VARIATION_FEATURES = ['rvrn'];
|
|
@@ -80,7 +80,7 @@ export default class DefaultShaper {
|
|
|
80
80
|
function composeGlyphs(font, glyphs) {
|
|
81
81
|
let singleMark = g => g.codePoints.length === 1 && isMark(g.codePoints[0]);
|
|
82
82
|
|
|
83
|
-
for (let i = 0; i < glyphs.length;
|
|
83
|
+
for (let i = 0; i < glyphs.length;) {
|
|
84
84
|
let base = glyphs[i];
|
|
85
85
|
if (base.codePoints.length !== 1 || isMark(base.codePoints[0])) {
|
|
86
86
|
i++;
|
|
@@ -95,7 +95,7 @@ function composeGlyphs(font, glyphs) {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
let input = glyphs.slice(i, end).map(g => g.codePoints[0]);
|
|
98
|
-
let composed = Array.from(String.fromCodePoint(...input).normalize('NFC')).flatMap(char => {
|
|
98
|
+
let composed = Array.from(String.fromCodePoint(...input).normalize('NFC')).flatMap((char) => {
|
|
99
99
|
let cp = char.codePointAt(0);
|
|
100
100
|
return font.hasGlyphForCodePoint(cp)
|
|
101
101
|
? [cp]
|