@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cantoo/fontkit",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"description": "An advanced font engine for Node and the browser",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"opentype",
|
|
@@ -82,6 +82,7 @@
|
|
|
82
82
|
"@babel/eslint-parser": "^8.0.1",
|
|
83
83
|
"@babel/plugin-proposal-decorators": "^8.0.2",
|
|
84
84
|
"@eslint/js": "^10.0.1",
|
|
85
|
+
"@stylistic/eslint-plugin": "^5.10.0",
|
|
85
86
|
"@vitest/coverage-v8": "^5.0.0",
|
|
86
87
|
"codepoints": "^1.3.0",
|
|
87
88
|
"esbuild": "^0.28.2",
|
package/src/CmapProcessor.js
CHANGED
|
@@ -34,7 +34,7 @@ export default class CmapProcessor {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
if (!this.cmap) {
|
|
37
|
-
throw new Error(
|
|
37
|
+
throw new Error('Could not find a supported cmap table');
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
this.uvs = this.findSubtable(cmapTable, [[0, 5]]);
|
|
@@ -155,7 +155,7 @@ export default class CmapProcessor {
|
|
|
155
155
|
return 0;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
let {defaultUVS, nonDefaultUVS} = selectors[i];
|
|
158
|
+
let { defaultUVS, nonDefaultUVS } = selectors[i];
|
|
159
159
|
|
|
160
160
|
// Default UVS: fall back to the base character's normal cmap glyph.
|
|
161
161
|
if (defaultUVS && binarySearch(defaultUVS, x =>
|
package/src/DFont.js
CHANGED
|
@@ -86,11 +86,11 @@ export default class DFont {
|
|
|
86
86
|
let stream = new r.DecodeStream(this.stream.buffer.slice(pos));
|
|
87
87
|
let font = new TTFFont(stream);
|
|
88
88
|
if (
|
|
89
|
-
font.postscriptName === name
|
|
90
|
-
(
|
|
91
|
-
font.postscriptName instanceof Uint8Array
|
|
92
|
-
name instanceof Uint8Array
|
|
93
|
-
font.postscriptName.every((v, i) => name[i] === v)
|
|
89
|
+
font.postscriptName === name
|
|
90
|
+
|| (
|
|
91
|
+
font.postscriptName instanceof Uint8Array
|
|
92
|
+
&& name instanceof Uint8Array
|
|
93
|
+
&& font.postscriptName.every((v, i) => name[i] === v)
|
|
94
94
|
)
|
|
95
95
|
) {
|
|
96
96
|
return font;
|
package/src/TTFFont.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as r from 'restructure';
|
|
2
1
|
import { cache } from './decorators';
|
|
3
2
|
import * as fontkit from './base';
|
|
4
3
|
import Directory from './tables/directory';
|
|
@@ -82,7 +81,7 @@ export default class TTFFont {
|
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
_decodeDirectory() {
|
|
85
|
-
return this.directory = Directory.decode(this.stream, {_startOffset: 0});
|
|
84
|
+
return this.directory = Directory.decode(this.stream, { _startOffset: 0 });
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
_decodeTable(table) {
|
|
@@ -108,14 +107,14 @@ export default class TTFFont {
|
|
|
108
107
|
let ascent, descent, lineGap;
|
|
109
108
|
|
|
110
109
|
if (hasTypo && os2.fsSelection.useTypoMetrics) {
|
|
111
|
-
({typoAscender: ascent, typoDescender: descent, typoLineGap: lineGap} = os2);
|
|
110
|
+
({ typoAscender: ascent, typoDescender: descent, typoLineGap: lineGap } = os2);
|
|
112
111
|
} else {
|
|
113
|
-
({ascent, descent, lineGap} = this.hhea);
|
|
112
|
+
({ ascent, descent, lineGap } = this.hhea);
|
|
114
113
|
|
|
115
114
|
// Only when both hhea values are zero — FreeType uses !(ascender || descender)
|
|
116
115
|
if (!(ascent || descent) && hasTypo) {
|
|
117
116
|
if (os2.typoAscender || os2.typoDescender) {
|
|
118
|
-
({typoAscender: ascent, typoDescender: descent, typoLineGap: lineGap} = os2);
|
|
117
|
+
({ typoAscender: ascent, typoDescender: descent, typoLineGap: lineGap } = os2);
|
|
119
118
|
} else {
|
|
120
119
|
ascent = os2.winAscent;
|
|
121
120
|
descent = -os2.winDescent;
|
|
@@ -142,12 +141,12 @@ export default class TTFFont {
|
|
|
142
141
|
if (record) {
|
|
143
142
|
// Attempt to retrieve the entry, depending on which translation is available:
|
|
144
143
|
return (
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
144
|
+
record[lang]
|
|
145
|
+
|| record[this.defaultLanguage]
|
|
146
|
+
|| record[fontkit.defaultLanguage]
|
|
147
|
+
|| record['en']
|
|
148
|
+
|| record[Object.keys(record)[0]] // Seriously, ANY language would be fine
|
|
149
|
+
|| null
|
|
151
150
|
);
|
|
152
151
|
}
|
|
153
152
|
|
|
@@ -467,13 +466,10 @@ export default class TTFFont {
|
|
|
467
466
|
if (!this._glyphs[glyph]) {
|
|
468
467
|
if (this.directory.tables.sbix) {
|
|
469
468
|
this._glyphs[glyph] = new SBIXGlyph(glyph, characters, this);
|
|
470
|
-
|
|
471
469
|
} else if ((this.directory.tables.COLR) && (this.directory.tables.CPAL)) {
|
|
472
470
|
this._glyphs[glyph] = new COLRGlyph(glyph, characters, this);
|
|
473
|
-
|
|
474
471
|
} else if (this.directory.tables.CBLC || this.directory.tables.EBLC) {
|
|
475
472
|
this._glyphs[glyph] = new CBDTGlyph(glyph, characters, this);
|
|
476
|
-
|
|
477
473
|
} else {
|
|
478
474
|
this._getBaseGlyph(glyph, characters);
|
|
479
475
|
}
|
|
@@ -569,7 +565,7 @@ export default class TTFFont {
|
|
|
569
565
|
}
|
|
570
566
|
|
|
571
567
|
// normalize the coordinates
|
|
572
|
-
let coords = this.fvar.axis.map(axis => {
|
|
568
|
+
let coords = this.fvar.axis.map((axis) => {
|
|
573
569
|
let axisTag = axis.axisTag.trim();
|
|
574
570
|
if (axisTag in settings) {
|
|
575
571
|
return Math.max(axis.minValue, Math.min(axis.maxValue, settings[axisTag]));
|
|
@@ -4,13 +4,13 @@ import { asciiDecoder } from './utils';
|
|
|
4
4
|
|
|
5
5
|
let TTCHeader = new r.VersionedStruct(r.uint32, {
|
|
6
6
|
0x00010000: {
|
|
7
|
-
numFonts:
|
|
8
|
-
offsets:
|
|
7
|
+
numFonts: r.uint32,
|
|
8
|
+
offsets: new r.Array(r.uint32, 'numFonts')
|
|
9
9
|
},
|
|
10
10
|
0x00020000: {
|
|
11
|
-
numFonts:
|
|
12
|
-
offsets:
|
|
13
|
-
dsigTag:
|
|
11
|
+
numFonts: r.uint32,
|
|
12
|
+
offsets: new r.Array(r.uint32, 'numFonts'),
|
|
13
|
+
dsigTag: r.uint32,
|
|
14
14
|
dsigLength: r.uint32,
|
|
15
15
|
dsigOffset: r.uint32
|
|
16
16
|
}
|
|
@@ -38,11 +38,11 @@ export default class TrueTypeCollection {
|
|
|
38
38
|
stream.pos = offset;
|
|
39
39
|
let font = new TTFFont(stream);
|
|
40
40
|
if (
|
|
41
|
-
font.postscriptName === name
|
|
42
|
-
(
|
|
43
|
-
font.postscriptName instanceof Uint8Array
|
|
44
|
-
name instanceof Uint8Array
|
|
45
|
-
font.postscriptName.every((v, i) => name[i] === v)
|
|
41
|
+
font.postscriptName === name
|
|
42
|
+
|| (
|
|
43
|
+
font.postscriptName instanceof Uint8Array
|
|
44
|
+
&& name instanceof Uint8Array
|
|
45
|
+
&& font.postscriptName.every((v, i) => name[i] === v)
|
|
46
46
|
)
|
|
47
47
|
) {
|
|
48
48
|
return font;
|
package/src/WOFF2Font.js
CHANGED
|
@@ -97,7 +97,6 @@ export default class WOFF2Font extends TTFFont {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
read255UInt16(table.glyphs);
|
|
100
|
-
|
|
101
100
|
} else if (nContours < 0) { // composite glyph
|
|
102
101
|
let haveInstructions = TTFGlyph.prototype._decodeComposite.call({ _font: this }, glyph, table.composites);
|
|
103
102
|
if (haveInstructions) {
|
|
@@ -186,28 +185,23 @@ function decodeTriplet(flags, glyphs, nPoints) {
|
|
|
186
185
|
if (flag < 10) {
|
|
187
186
|
dx = 0;
|
|
188
187
|
dy = withSign(flag, ((flag & 14) << 7) + glyphs.readUInt8());
|
|
189
|
-
|
|
190
188
|
} else if (flag < 20) {
|
|
191
189
|
dx = withSign(flag, (((flag - 10) & 14) << 7) + glyphs.readUInt8());
|
|
192
190
|
dy = 0;
|
|
193
|
-
|
|
194
191
|
} else if (flag < 84) {
|
|
195
192
|
let b0 = flag - 20;
|
|
196
193
|
let b1 = glyphs.readUInt8();
|
|
197
194
|
dx = withSign(flag, 1 + (b0 & 0x30) + (b1 >> 4));
|
|
198
195
|
dy = withSign(flag >> 1, 1 + ((b0 & 0x0c) << 2) + (b1 & 0x0f));
|
|
199
|
-
|
|
200
196
|
} else if (flag < 120) {
|
|
201
197
|
let b0 = flag - 84;
|
|
202
198
|
dx = withSign(flag, 1 + ((b0 / 12) << 8) + glyphs.readUInt8());
|
|
203
199
|
dy = withSign(flag >> 1, 1 + (((b0 % 12) >> 2) << 8) + glyphs.readUInt8());
|
|
204
|
-
|
|
205
200
|
} else if (flag < 124) {
|
|
206
201
|
let b1 = glyphs.readUInt8();
|
|
207
202
|
let b2 = glyphs.readUInt8();
|
|
208
203
|
dx = withSign(flag, (b1 << 4) + (b2 >> 4));
|
|
209
204
|
dy = withSign(flag >> 1, ((b2 & 0x0f) << 8) + glyphs.readUInt8());
|
|
210
|
-
|
|
211
205
|
} else {
|
|
212
206
|
dx = withSign(flag, glyphs.readUInt16BE());
|
|
213
207
|
dy = withSign(flag >> 1, glyphs.readUInt16BE());
|
package/src/aat/AATFeatureMap.js
CHANGED
|
@@ -32,12 +32,12 @@ const features = {
|
|
|
32
32
|
code: 3,
|
|
33
33
|
exclusive: true
|
|
34
34
|
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
// upperAndLowerCase: 0 # deprecated
|
|
36
|
+
// allCaps: 1 # deprecated
|
|
37
|
+
// allLowerCase: 2 # deprecated
|
|
38
|
+
// smallCaps: 3 # deprecated
|
|
39
|
+
// initialCaps: 4 # deprecated
|
|
40
|
+
// initialCapsAndSmallCaps: 5 # deprecated
|
|
41
41
|
verticalSubstitution: {
|
|
42
42
|
code: 4,
|
|
43
43
|
exclusive: false,
|
|
@@ -100,9 +100,9 @@ const features = {
|
|
|
100
100
|
// hyphenToEnDash: 2
|
|
101
101
|
slashedZero: 4
|
|
102
102
|
},
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
// formInterrobang: 6
|
|
104
|
+
// smartQuotes: 8
|
|
105
|
+
// periodsToEllipsis: 10
|
|
106
106
|
mathematicalExtras: {
|
|
107
107
|
code: 15,
|
|
108
108
|
exclusive: false,
|
|
@@ -129,7 +129,7 @@ const features = {
|
|
|
129
129
|
exclusive: true,
|
|
130
130
|
noAlternates: 0
|
|
131
131
|
},
|
|
132
|
-
|
|
132
|
+
// user defined options
|
|
133
133
|
designComplexity: {
|
|
134
134
|
code: 18,
|
|
135
135
|
exclusive: true,
|
|
@@ -190,15 +190,15 @@ const features = {
|
|
|
190
190
|
exclusive: true,
|
|
191
191
|
noTransliteration: 0
|
|
192
192
|
},
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
193
|
+
// hanjaToHangul: 1
|
|
194
|
+
// hiraganaToKatakana: 2
|
|
195
|
+
// katakanaToHiragana: 3
|
|
196
|
+
// kanaToRomanization: 4
|
|
197
|
+
// romanizationToHiragana: 5
|
|
198
|
+
// romanizationToKatakana: 6
|
|
199
|
+
// hanjaToHangulAltOne: 7
|
|
200
|
+
// hanjaToHangulAltTwo: 8
|
|
201
|
+
// hanjaToHangulAltThree: 9
|
|
202
202
|
annotation: {
|
|
203
203
|
code: 24,
|
|
204
204
|
exclusive: true,
|
|
@@ -418,7 +418,7 @@ const OTMapping = {
|
|
|
418
418
|
hwid: feature('textSpacing', 'halfWidthText'),
|
|
419
419
|
qwid: feature('textSpacing', 'quarterWidthText'), // also QuarterWidthNumbers?
|
|
420
420
|
twid: feature('textSpacing', 'thirdWidthText'), // also ThirdWidthNumbers?
|
|
421
|
-
fwid: feature('textSpacing', 'proportionalText'),
|
|
421
|
+
fwid: feature('textSpacing', 'proportionalText'), // ??
|
|
422
422
|
palt: feature('textSpacing', 'altProportionalText'),
|
|
423
423
|
trad: feature('characterShape', 'traditionalCharacters'),
|
|
424
424
|
smpl: feature('characterShape', 'simplifiedCharacters'),
|
|
@@ -456,7 +456,7 @@ const OTMapping = {
|
|
|
456
456
|
ss20: feature('stylisticAlternatives', 'stylisticAltTwenty')
|
|
457
457
|
};
|
|
458
458
|
|
|
459
|
-
|
|
459
|
+
// salt: feature 'stylisticAlternatives', 'stylisticAltOne' # hmm, which one to choose
|
|
460
460
|
|
|
461
461
|
// Add cv01-cv99 features
|
|
462
462
|
for (let i = 1; i <= 99; i++) {
|
|
@@ -527,7 +527,6 @@ export function mapAATToOT(features) {
|
|
|
527
527
|
res[r] = true;
|
|
528
528
|
}
|
|
529
529
|
}
|
|
530
|
-
|
|
531
530
|
} else if (typeof features === 'object') {
|
|
532
531
|
for (let type in features) {
|
|
533
532
|
let feature = features[type];
|
|
@@ -24,7 +24,7 @@ export default class AATLayoutEngine {
|
|
|
24
24
|
|
|
25
25
|
stringsForGlyph(gid) {
|
|
26
26
|
let glyphStrings = this.morxProcessor.generateInputs(gid);
|
|
27
|
-
let result = new Set;
|
|
27
|
+
let result = new Set();
|
|
28
28
|
|
|
29
29
|
for (let glyphs of glyphStrings) {
|
|
30
30
|
this._addStrings(glyphs, 0, result, '');
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import AATStateMachine from './AATStateMachine';
|
|
2
2
|
import AATLookupTable from './AATLookupTable';
|
|
3
|
-
import {cache} from '../decorators';
|
|
3
|
+
import { cache } from '../decorators';
|
|
4
4
|
|
|
5
5
|
// indic replacement flags
|
|
6
6
|
const MARK_FIRST = 0x8000;
|
|
7
|
-
const MARK_LAST
|
|
8
|
-
const VERB
|
|
7
|
+
const MARK_LAST = 0x2000;
|
|
8
|
+
const VERB = 0x000F;
|
|
9
9
|
|
|
10
10
|
// contextual substitution and glyph insertion flag
|
|
11
11
|
const SET_MARK = 0x8000;
|
|
12
12
|
|
|
13
13
|
// ligature entry flags
|
|
14
|
-
const SET_COMPONENT
|
|
14
|
+
const SET_COMPONENT = 0x8000;
|
|
15
15
|
const PERFORM_ACTION = 0x2000;
|
|
16
16
|
|
|
17
17
|
// ligature action masks
|
|
18
|
-
const LAST_MASK
|
|
19
|
-
const STORE_MASK
|
|
18
|
+
const LAST_MASK = 0x80000000;
|
|
19
|
+
const STORE_MASK = 0x40000000;
|
|
20
20
|
const OFFSET_MASK = 0x3FFFFFFF;
|
|
21
21
|
|
|
22
|
-
const _VERTICAL_ONLY
|
|
23
|
-
const REVERSE_DIRECTION
|
|
22
|
+
const _VERTICAL_ONLY = 0x800000;
|
|
23
|
+
const REVERSE_DIRECTION = 0x400000;
|
|
24
24
|
const _HORIZONTAL_AND_VERTICAL = 0x200000;
|
|
25
25
|
|
|
26
26
|
// glyph insertion flags
|
|
27
27
|
const _CURRENT_IS_KASHIDA_LIKE = 0x2000;
|
|
28
|
-
const _MARKED_IS_KASHIDA_LIKE
|
|
29
|
-
const CURRENT_INSERT_BEFORE
|
|
30
|
-
const MARKED_INSERT_BEFORE
|
|
31
|
-
const CURRENT_INSERT_COUNT
|
|
32
|
-
const MARKED_INSERT_COUNT
|
|
28
|
+
const _MARKED_IS_KASHIDA_LIKE = 0x1000;
|
|
29
|
+
const CURRENT_INSERT_BEFORE = 0x0800;
|
|
30
|
+
const MARKED_INSERT_BEFORE = 0x0400;
|
|
31
|
+
const CURRENT_INSERT_COUNT = 0x03E0;
|
|
32
|
+
const MARKED_INSERT_COUNT = 0x001F;
|
|
33
33
|
|
|
34
34
|
export default class AATMorxProcessor {
|
|
35
35
|
constructor(font) {
|
|
@@ -348,7 +348,7 @@ export default class AATMorxProcessor {
|
|
|
348
348
|
},
|
|
349
349
|
|
|
350
350
|
exit: () => {
|
|
351
|
-
({glyphs: this.glyphs, ligatureStack: this.ligatureStack} = stack.pop());
|
|
351
|
+
({ glyphs: this.glyphs, ligatureStack: this.ligatureStack } = stack.pop());
|
|
352
352
|
input.pop();
|
|
353
353
|
}
|
|
354
354
|
});
|
|
@@ -44,7 +44,7 @@ export default class AATStateMachine {
|
|
|
44
44
|
let entryIndex = row[classCode];
|
|
45
45
|
let entry = this.stateTable.entryTable.getItem(entryIndex);
|
|
46
46
|
|
|
47
|
-
if (classCode !== END_OF_TEXT_CLASS && classCode !==
|
|
47
|
+
if (classCode !== END_OF_TEXT_CLASS && classCode !== DELETED_GLYPH_CLASS) {
|
|
48
48
|
processEntry(glyph, entry, index);
|
|
49
49
|
shouldAdvance = !(entry.flags & DONT_ADVANCE);
|
|
50
50
|
}
|
|
@@ -62,14 +62,14 @@ export default class AATStateMachine {
|
|
|
62
62
|
* Performs a depth-first traversal of the glyph strings
|
|
63
63
|
* represented by the state machine.
|
|
64
64
|
*/
|
|
65
|
-
traverse(opts, state = 0, visited = new Set) {
|
|
65
|
+
traverse(opts, state = 0, visited = new Set()) {
|
|
66
66
|
if (visited.has(state)) {
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
visited.add(state);
|
|
71
71
|
|
|
72
|
-
let {nClasses, stateArray, entryTable} = this.stateTable;
|
|
72
|
+
let { nClasses, stateArray, entryTable } = this.stateTable;
|
|
73
73
|
let row = stateArray.getItem(state);
|
|
74
74
|
|
|
75
75
|
// Skip predefined classes
|
package/src/base.js
CHANGED
package/src/cff/CFFDict.js
CHANGED
|
@@ -54,8 +54,8 @@ export default class CFFDict {
|
|
|
54
54
|
|
|
55
55
|
// define hidden properties
|
|
56
56
|
Object.defineProperties(ret, {
|
|
57
|
-
parent:
|
|
58
|
-
_startOffset:
|
|
57
|
+
parent: { value: parent },
|
|
58
|
+
_startOffset: { value: stream.pos }
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
// fill in defaults
|
package/src/cff/CFFFont.js
CHANGED
package/src/cff/CFFIndex.js
CHANGED
|
@@ -71,7 +71,7 @@ export default class CFFIndex {
|
|
|
71
71
|
return size;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
let type = this.type || new r.Buffer;
|
|
74
|
+
let type = this.type || new r.Buffer();
|
|
75
75
|
|
|
76
76
|
// find maximum offset to detminine offset type
|
|
77
77
|
let offset = 1;
|
|
@@ -90,7 +90,7 @@ export default class CFFIndex {
|
|
|
90
90
|
} else if (offset <= 0xffffffff) {
|
|
91
91
|
offsetType = r.uint32;
|
|
92
92
|
} else {
|
|
93
|
-
throw new Error(
|
|
93
|
+
throw new Error('Bad offset in CFFIndex');
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
size += 1 + offsetType.size() * (arr.length + 1);
|
|
@@ -105,7 +105,7 @@ export default class CFFIndex {
|
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
let type = this.type || new r.Buffer;
|
|
108
|
+
let type = this.type || new r.Buffer();
|
|
109
109
|
|
|
110
110
|
// find maximum offset to detminine offset type
|
|
111
111
|
let sizes = [];
|
|
@@ -126,7 +126,7 @@ export default class CFFIndex {
|
|
|
126
126
|
} else if (offset <= 0xffffffff) {
|
|
127
127
|
offsetType = r.uint32;
|
|
128
128
|
} else {
|
|
129
|
-
throw new Error(
|
|
129
|
+
throw new Error('Bad offset in CFFIndex');
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
// write offset size
|
package/src/cff/CFFOperand.js
CHANGED
|
@@ -6,7 +6,7 @@ const FLOAT_LOOKUP = [
|
|
|
6
6
|
|
|
7
7
|
const FLOAT_ENCODE_LOOKUP = {
|
|
8
8
|
'.': 10,
|
|
9
|
-
|
|
9
|
+
E: 11,
|
|
10
10
|
'E-': 12,
|
|
11
11
|
'-': 14
|
|
12
12
|
};
|
|
@@ -63,16 +63,12 @@ export default class CFFOperand {
|
|
|
63
63
|
if ((value | 0) !== value) { // floating point
|
|
64
64
|
let str = '' + value;
|
|
65
65
|
return 1 + Math.ceil((str.length + 1) / 2);
|
|
66
|
-
|
|
67
66
|
} else if (-107 <= value && value <= 107) {
|
|
68
67
|
return 1;
|
|
69
|
-
|
|
70
68
|
} else if (108 <= value && value <= 1131 || -1131 <= value && value <= -108) {
|
|
71
69
|
return 2;
|
|
72
|
-
|
|
73
70
|
} else if (-32768 <= value && value <= 32767) {
|
|
74
71
|
return 3;
|
|
75
|
-
|
|
76
72
|
} else {
|
|
77
73
|
return 5;
|
|
78
74
|
}
|
|
@@ -86,7 +82,6 @@ export default class CFFOperand {
|
|
|
86
82
|
if (value.forceLarge) {
|
|
87
83
|
stream.writeUInt8(29);
|
|
88
84
|
return stream.writeInt32BE(val);
|
|
89
|
-
|
|
90
85
|
} else if ((val | 0) !== val) { // floating point
|
|
91
86
|
stream.writeUInt8(30);
|
|
92
87
|
|
|
@@ -109,24 +104,19 @@ export default class CFFOperand {
|
|
|
109
104
|
if (n2 !== FLOAT_EOF) {
|
|
110
105
|
return stream.writeUInt8((FLOAT_EOF << 4));
|
|
111
106
|
}
|
|
112
|
-
|
|
113
107
|
} else if (-107 <= val && val <= 107) {
|
|
114
108
|
return stream.writeUInt8(val + 139);
|
|
115
|
-
|
|
116
109
|
} else if (108 <= val && val <= 1131) {
|
|
117
110
|
val -= 108;
|
|
118
111
|
stream.writeUInt8((val >> 8) + 247);
|
|
119
112
|
return stream.writeUInt8(val & 0xff);
|
|
120
|
-
|
|
121
113
|
} else if (-1131 <= val && val <= -108) {
|
|
122
114
|
val = -val - 108;
|
|
123
115
|
stream.writeUInt8((val >> 8) + 251);
|
|
124
116
|
return stream.writeUInt8(val & 0xff);
|
|
125
|
-
|
|
126
117
|
} else if (-32768 <= val && val <= 32767) {
|
|
127
118
|
stream.writeUInt8(28);
|
|
128
119
|
return stream.writeInt16BE(val);
|
|
129
|
-
|
|
130
120
|
} else {
|
|
131
121
|
stream.writeUInt8(29);
|
|
132
122
|
return stream.writeInt32BE(val);
|
|
@@ -16,24 +16,24 @@ class CFFBlendOp {
|
|
|
16
16
|
|
|
17
17
|
export default new CFFDict([
|
|
18
18
|
// key name type default
|
|
19
|
-
[6,
|
|
20
|
-
[7,
|
|
21
|
-
[8,
|
|
22
|
-
[9,
|
|
23
|
-
[[12, 9],
|
|
24
|
-
[[12, 10],
|
|
25
|
-
[[12, 11],
|
|
26
|
-
[10,
|
|
27
|
-
[11,
|
|
28
|
-
[[12, 12],
|
|
29
|
-
[[12, 13],
|
|
30
|
-
[[12, 14],
|
|
31
|
-
[[12, 17],
|
|
32
|
-
[[12, 18],
|
|
33
|
-
[[12, 19],
|
|
34
|
-
[20,
|
|
35
|
-
[21,
|
|
36
|
-
[22,
|
|
37
|
-
[23,
|
|
38
|
-
[19,
|
|
19
|
+
[6, 'BlueValues', 'delta', null],
|
|
20
|
+
[7, 'OtherBlues', 'delta', null],
|
|
21
|
+
[8, 'FamilyBlues', 'delta', null],
|
|
22
|
+
[9, 'FamilyOtherBlues', 'delta', null],
|
|
23
|
+
[[12, 9], 'BlueScale', 'number', 0.039625],
|
|
24
|
+
[[12, 10], 'BlueShift', 'number', 7],
|
|
25
|
+
[[12, 11], 'BlueFuzz', 'number', 1],
|
|
26
|
+
[10, 'StdHW', 'number', null],
|
|
27
|
+
[11, 'StdVW', 'number', null],
|
|
28
|
+
[[12, 12], 'StemSnapH', 'delta', null],
|
|
29
|
+
[[12, 13], 'StemSnapV', 'delta', null],
|
|
30
|
+
[[12, 14], 'ForceBold', 'boolean', false],
|
|
31
|
+
[[12, 17], 'LanguageGroup', 'number', 0],
|
|
32
|
+
[[12, 18], 'ExpansionFactor', 'number', 0.06],
|
|
33
|
+
[[12, 19], 'initialRandomSeed', 'number', 0],
|
|
34
|
+
[20, 'defaultWidthX', 'number', 0],
|
|
35
|
+
[21, 'nominalWidthX', 'number', 0],
|
|
36
|
+
[22, 'vsindex', 'number', 0],
|
|
37
|
+
[23, 'blend', CFFBlendOp, null],
|
|
38
|
+
[19, 'Subrs', new CFFPointer(new CFFIndex(), { type: 'local' }), null]
|
|
39
39
|
]);
|