@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/tables/OS2.js
CHANGED
|
@@ -2,76 +2,76 @@ import * as r from 'restructure';
|
|
|
2
2
|
|
|
3
3
|
var OS2 = new r.VersionedStruct(r.uint16, {
|
|
4
4
|
header: {
|
|
5
|
-
xAvgCharWidth:
|
|
6
|
-
usWeightClass:
|
|
7
|
-
usWidthClass:
|
|
8
|
-
fsType:
|
|
5
|
+
xAvgCharWidth: r.int16, // average weighted advance width of lower case letters and space
|
|
6
|
+
usWeightClass: r.uint16, // visual weight of stroke in glyphs
|
|
7
|
+
usWidthClass: r.uint16, // relative change from the normal aspect ratio (width to height ratio)
|
|
8
|
+
fsType: new r.Bitfield(r.uint16, [ // Indicates font embedding licensing rights
|
|
9
9
|
null, 'noEmbedding', 'viewOnly', 'editable', null,
|
|
10
10
|
null, null, null, 'noSubsetting', 'bitmapOnly'
|
|
11
11
|
]),
|
|
12
|
-
ySubscriptXSize:
|
|
13
|
-
ySubscriptYSize:
|
|
14
|
-
ySubscriptXOffset:
|
|
15
|
-
ySubscriptYOffset:
|
|
16
|
-
ySuperscriptXSize:
|
|
17
|
-
ySuperscriptYSize:
|
|
18
|
-
ySuperscriptXOffset:
|
|
19
|
-
ySuperscriptYOffset:
|
|
20
|
-
yStrikeoutSize:
|
|
21
|
-
yStrikeoutPosition:
|
|
22
|
-
sFamilyClass:
|
|
23
|
-
panose:
|
|
24
|
-
ulCharRange:
|
|
25
|
-
vendorID:
|
|
26
|
-
fsSelection:
|
|
12
|
+
ySubscriptXSize: r.int16, // recommended horizontal size in pixels for subscripts
|
|
13
|
+
ySubscriptYSize: r.int16, // recommended vertical size in pixels for subscripts
|
|
14
|
+
ySubscriptXOffset: r.int16, // recommended horizontal offset for subscripts
|
|
15
|
+
ySubscriptYOffset: r.int16, // recommended vertical offset form the baseline for subscripts
|
|
16
|
+
ySuperscriptXSize: r.int16, // recommended horizontal size in pixels for superscripts
|
|
17
|
+
ySuperscriptYSize: r.int16, // recommended vertical size in pixels for superscripts
|
|
18
|
+
ySuperscriptXOffset: r.int16, // recommended horizontal offset for superscripts
|
|
19
|
+
ySuperscriptYOffset: r.int16, // recommended vertical offset from the baseline for superscripts
|
|
20
|
+
yStrikeoutSize: r.int16, // width of the strikeout stroke
|
|
21
|
+
yStrikeoutPosition: r.int16, // position of the strikeout stroke relative to the baseline
|
|
22
|
+
sFamilyClass: r.int16, // classification of font-family design
|
|
23
|
+
panose: new r.Array(r.uint8, 10), // describe the visual characteristics of a given typeface
|
|
24
|
+
ulCharRange: new r.Array(r.uint32, 4),
|
|
25
|
+
vendorID: new r.String(4), // four character identifier for the font vendor
|
|
26
|
+
fsSelection: new r.Bitfield(r.uint16, [ // bit field containing information about the font
|
|
27
27
|
'italic', 'underscore', 'negative', 'outlined', 'strikeout',
|
|
28
28
|
'bold', 'regular', 'useTypoMetrics', 'wws', 'oblique'
|
|
29
29
|
]),
|
|
30
|
-
usFirstCharIndex:
|
|
31
|
-
usLastCharIndex:
|
|
30
|
+
usFirstCharIndex: r.uint16, // The minimum Unicode index in this font
|
|
31
|
+
usLastCharIndex: r.uint16 // The maximum Unicode index in this font
|
|
32
32
|
},
|
|
33
33
|
|
|
34
34
|
// The Apple version of this table ends here, but the Microsoft one continues on...
|
|
35
35
|
0: {},
|
|
36
36
|
|
|
37
37
|
1: {
|
|
38
|
-
typoAscender:
|
|
39
|
-
typoDescender:
|
|
40
|
-
typoLineGap:
|
|
41
|
-
winAscent:
|
|
42
|
-
winDescent:
|
|
43
|
-
codePageRange:
|
|
38
|
+
typoAscender: r.int16,
|
|
39
|
+
typoDescender: r.int16,
|
|
40
|
+
typoLineGap: r.int16,
|
|
41
|
+
winAscent: r.uint16,
|
|
42
|
+
winDescent: r.uint16,
|
|
43
|
+
codePageRange: new r.Array(r.uint32, 2)
|
|
44
44
|
},
|
|
45
45
|
|
|
46
46
|
2: {
|
|
47
47
|
// these should be common with version 1 somehow
|
|
48
|
-
typoAscender:
|
|
49
|
-
typoDescender:
|
|
50
|
-
typoLineGap:
|
|
51
|
-
winAscent:
|
|
52
|
-
winDescent:
|
|
53
|
-
codePageRange:
|
|
48
|
+
typoAscender: r.int16,
|
|
49
|
+
typoDescender: r.int16,
|
|
50
|
+
typoLineGap: r.int16,
|
|
51
|
+
winAscent: r.uint16,
|
|
52
|
+
winDescent: r.uint16,
|
|
53
|
+
codePageRange: new r.Array(r.uint32, 2),
|
|
54
54
|
|
|
55
|
-
xHeight:
|
|
56
|
-
capHeight:
|
|
57
|
-
defaultChar:
|
|
58
|
-
breakChar:
|
|
59
|
-
maxContent:
|
|
55
|
+
xHeight: r.int16,
|
|
56
|
+
capHeight: r.int16,
|
|
57
|
+
defaultChar: r.uint16,
|
|
58
|
+
breakChar: r.uint16,
|
|
59
|
+
maxContent: r.uint16
|
|
60
60
|
},
|
|
61
61
|
|
|
62
62
|
5: {
|
|
63
|
-
typoAscender:
|
|
64
|
-
typoDescender:
|
|
65
|
-
typoLineGap:
|
|
66
|
-
winAscent:
|
|
67
|
-
winDescent:
|
|
68
|
-
codePageRange:
|
|
63
|
+
typoAscender: r.int16,
|
|
64
|
+
typoDescender: r.int16,
|
|
65
|
+
typoLineGap: r.int16,
|
|
66
|
+
winAscent: r.uint16,
|
|
67
|
+
winDescent: r.uint16,
|
|
68
|
+
codePageRange: new r.Array(r.uint32, 2),
|
|
69
69
|
|
|
70
|
-
xHeight:
|
|
71
|
-
capHeight:
|
|
72
|
-
defaultChar:
|
|
73
|
-
breakChar:
|
|
74
|
-
maxContent:
|
|
70
|
+
xHeight: r.int16,
|
|
71
|
+
capHeight: r.int16,
|
|
72
|
+
defaultChar: r.uint16,
|
|
73
|
+
breakChar: r.uint16,
|
|
74
|
+
maxContent: r.uint16,
|
|
75
75
|
|
|
76
76
|
usLowerOpticalPointSize: r.uint16,
|
|
77
77
|
usUpperOpticalPointSize: r.uint16
|
package/src/tables/PCLT.js
CHANGED
|
@@ -3,19 +3,19 @@ import * as r from 'restructure';
|
|
|
3
3
|
// PCL 5 Table
|
|
4
4
|
// NOTE: The PCLT table is strongly discouraged for OpenType fonts with TrueType outlines
|
|
5
5
|
export default new r.Struct({
|
|
6
|
-
version:
|
|
7
|
-
fontNumber:
|
|
8
|
-
pitch:
|
|
9
|
-
xHeight:
|
|
10
|
-
style:
|
|
11
|
-
typeFamily:
|
|
12
|
-
capHeight:
|
|
13
|
-
symbolSet:
|
|
14
|
-
typeface:
|
|
15
|
-
characterComplement:
|
|
16
|
-
fileName:
|
|
17
|
-
strokeWeight:
|
|
18
|
-
widthType:
|
|
19
|
-
serifStyle:
|
|
20
|
-
reserved:
|
|
6
|
+
version: r.uint16,
|
|
7
|
+
fontNumber: r.uint32,
|
|
8
|
+
pitch: r.uint16,
|
|
9
|
+
xHeight: r.uint16,
|
|
10
|
+
style: r.uint16,
|
|
11
|
+
typeFamily: r.uint16,
|
|
12
|
+
capHeight: r.uint16,
|
|
13
|
+
symbolSet: r.uint16,
|
|
14
|
+
typeface: new r.String(16),
|
|
15
|
+
characterComplement: new r.String(8),
|
|
16
|
+
fileName: new r.String(6),
|
|
17
|
+
strokeWeight: new r.String(1),
|
|
18
|
+
widthType: new r.String(1),
|
|
19
|
+
serifStyle: r.uint8,
|
|
20
|
+
reserved: new r.Reserved(r.uint8)
|
|
21
21
|
});
|
package/src/tables/VDMX.js
CHANGED
|
@@ -4,30 +4,30 @@ import * as r from 'restructure';
|
|
|
4
4
|
// sizes. This is needed in order to match font metrics on Windows.
|
|
5
5
|
|
|
6
6
|
let Ratio = new r.Struct({
|
|
7
|
-
bCharSet:
|
|
8
|
-
xRatio:
|
|
9
|
-
yStartRatio:
|
|
10
|
-
yEndRatio:
|
|
7
|
+
bCharSet: r.uint8, // Character set
|
|
8
|
+
xRatio: r.uint8, // Value to use for x-Ratio
|
|
9
|
+
yStartRatio: r.uint8, // Starting y-Ratio value
|
|
10
|
+
yEndRatio: r.uint8 // Ending y-Ratio value
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
let vTable = new r.Struct({
|
|
14
|
-
yPelHeight:
|
|
15
|
-
yMax:
|
|
16
|
-
yMin:
|
|
14
|
+
yPelHeight: r.uint16, // yPelHeight to which values apply
|
|
15
|
+
yMax: r.int16, // Maximum value (in pels) for this yPelHeight
|
|
16
|
+
yMin: r.int16 // Minimum value (in pels) for this yPelHeight
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
let VdmxGroup = new r.Struct({
|
|
20
|
-
recs:
|
|
21
|
-
startsz:
|
|
22
|
-
endsz:
|
|
23
|
-
entries:
|
|
20
|
+
recs: r.uint16, // Number of height records in this group
|
|
21
|
+
startsz: r.uint8, // Starting yPelHeight
|
|
22
|
+
endsz: r.uint8, // Ending yPelHeight
|
|
23
|
+
entries: new r.Array(vTable, 'recs') // The VDMX records
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
export default new r.Struct({
|
|
27
|
-
version:
|
|
28
|
-
numRecs:
|
|
29
|
-
numRatios:
|
|
30
|
-
ratioRanges:
|
|
31
|
-
offsets:
|
|
32
|
-
groups:
|
|
27
|
+
version: r.uint16, // Version number (0 or 1)
|
|
28
|
+
numRecs: r.uint16, // Number of VDMX groups present
|
|
29
|
+
numRatios: r.uint16, // Number of aspect ratio groupings
|
|
30
|
+
ratioRanges: new r.Array(Ratio, 'numRatios'), // Ratio ranges
|
|
31
|
+
offsets: new r.Array(r.uint16, 'numRatios'), // Offset to the VDMX group for this ratio range
|
|
32
|
+
groups: new r.Array(VdmxGroup, 'numRecs') // The actual VDMX groupings
|
|
33
33
|
});
|
package/src/tables/VORG.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as r from 'restructure';
|
|
2
2
|
|
|
3
3
|
let VerticalOrigin = new r.Struct({
|
|
4
|
-
glyphIndex:
|
|
5
|
-
vertOriginY:
|
|
4
|
+
glyphIndex: r.uint16,
|
|
5
|
+
vertOriginY: r.int16
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
export default new r.Struct({
|
|
9
|
-
majorVersion:
|
|
10
|
-
minorVersion:
|
|
11
|
-
defaultVertOriginY:
|
|
12
|
-
numVertOriginYMetrics:
|
|
13
|
-
metrics:
|
|
9
|
+
majorVersion: r.uint16,
|
|
10
|
+
minorVersion: r.uint16,
|
|
11
|
+
defaultVertOriginY: r.int16,
|
|
12
|
+
numVertOriginYMetrics: r.uint16,
|
|
13
|
+
metrics: new r.Array(VerticalOrigin, 'numVertOriginYMetrics')
|
|
14
14
|
});
|
|
@@ -35,7 +35,7 @@ let knownTags = [
|
|
|
35
35
|
let WOFF2DirectoryEntry = new r.Struct({
|
|
36
36
|
flags: r.uint8,
|
|
37
37
|
customTag: new r.Optional(new r.String(4), t => (t.flags & 0x3f) === 0x3f),
|
|
38
|
-
tag: t => t.customTag || knownTags[t.flags & 0x3f]
|
|
38
|
+
tag: t => t.customTag || knownTags[t.flags & 0x3f], // || (() => { throw new Error(`Bad tag: ${flags & 0x3f}`); })(); },
|
|
39
39
|
length: Base128,
|
|
40
40
|
transformVersion: t => (t.flags >>> 6) & 0x03,
|
|
41
41
|
transformed: t => (t.tag === 'glyf' || t.tag === 'loca') ? t.transformVersion === 0 : t.transformVersion !== 0,
|
|
@@ -60,7 +60,7 @@ let WOFF2Directory = new r.Struct({
|
|
|
60
60
|
tables: new r.Array(WOFF2DirectoryEntry, 'numTables')
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
WOFF2Directory.process = function() {
|
|
63
|
+
WOFF2Directory.process = function () {
|
|
64
64
|
let tables = {};
|
|
65
65
|
for (let i = 0; i < this.tables.length; i++) {
|
|
66
66
|
let table = this.tables[i];
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import * as r from 'restructure';
|
|
2
2
|
|
|
3
3
|
let WOFFDirectoryEntry = new r.Struct({
|
|
4
|
-
tag:
|
|
5
|
-
offset:
|
|
6
|
-
compLength:
|
|
7
|
-
length:
|
|
4
|
+
tag: new r.String(4),
|
|
5
|
+
offset: new r.Pointer(r.uint32, 'void', { type: 'global' }),
|
|
6
|
+
compLength: r.uint32,
|
|
7
|
+
length: r.uint32,
|
|
8
8
|
origChecksum: r.uint32
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
let WOFFDirectory = new r.Struct({
|
|
12
|
-
tag:
|
|
13
|
-
flavor:
|
|
14
|
-
length:
|
|
15
|
-
numTables:
|
|
16
|
-
reserved:
|
|
17
|
-
totalSfntSize:
|
|
18
|
-
majorVersion:
|
|
19
|
-
minorVersion:
|
|
20
|
-
metaOffset:
|
|
21
|
-
metaLength:
|
|
12
|
+
tag: new r.String(4), // should be 'wOFF'
|
|
13
|
+
flavor: r.uint32,
|
|
14
|
+
length: r.uint32,
|
|
15
|
+
numTables: r.uint16,
|
|
16
|
+
reserved: new r.Reserved(r.uint16),
|
|
17
|
+
totalSfntSize: r.uint32,
|
|
18
|
+
majorVersion: r.uint16,
|
|
19
|
+
minorVersion: r.uint16,
|
|
20
|
+
metaOffset: r.uint32,
|
|
21
|
+
metaLength: r.uint32,
|
|
22
22
|
metaOrigLength: r.uint32,
|
|
23
|
-
privOffset:
|
|
24
|
-
privLength:
|
|
25
|
-
tables:
|
|
23
|
+
privOffset: r.uint32,
|
|
24
|
+
privLength: r.uint32,
|
|
25
|
+
tables: new r.Array(WOFFDirectoryEntry, 'numTables')
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
WOFFDirectory.process = function() {
|
|
28
|
+
WOFFDirectory.process = function () {
|
|
29
29
|
let tables = {};
|
|
30
30
|
for (let table of this.tables) {
|
|
31
31
|
tables[table.tag] = table;
|
package/src/tables/aat.js
CHANGED
|
@@ -35,7 +35,7 @@ export class UnboundedArray extends r.Array {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export let LookupTable = function(ValueType = r.uint16) {
|
|
38
|
+
export let LookupTable = function (ValueType = r.uint16) {
|
|
39
39
|
// Helper class that makes internal structures invisible to pointers
|
|
40
40
|
class Shadow {
|
|
41
41
|
constructor(type) {
|
|
@@ -77,7 +77,7 @@ export let LookupTable = function(ValueType = r.uint16) {
|
|
|
77
77
|
let LookupSegmentArray = new r.Struct({
|
|
78
78
|
lastGlyph: r.uint16,
|
|
79
79
|
firstGlyph: r.uint16,
|
|
80
|
-
values: new r.Pointer(r.uint16, new r.Array(ValueType, t => t.lastGlyph - t.firstGlyph + 1), {type: 'parent'})
|
|
80
|
+
values: new r.Pointer(r.uint16, new r.Array(ValueType, t => t.lastGlyph - t.firstGlyph + 1), { type: 'parent' })
|
|
81
81
|
});
|
|
82
82
|
|
|
83
83
|
let LookupSingle = new r.Struct({
|
package/src/tables/cmap.js
CHANGED
|
@@ -1,127 +1,127 @@
|
|
|
1
1
|
import * as r from 'restructure';
|
|
2
2
|
|
|
3
3
|
let SubHeader = new r.Struct({
|
|
4
|
-
firstCode:
|
|
5
|
-
entryCount:
|
|
6
|
-
idDelta:
|
|
7
|
-
idRangeOffset:
|
|
4
|
+
firstCode: r.uint16,
|
|
5
|
+
entryCount: r.uint16,
|
|
6
|
+
idDelta: r.int16,
|
|
7
|
+
idRangeOffset: r.uint16
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
let CmapGroup = new r.Struct({
|
|
11
|
-
startCharCode:
|
|
12
|
-
endCharCode:
|
|
13
|
-
glyphID:
|
|
11
|
+
startCharCode: r.uint32,
|
|
12
|
+
endCharCode: r.uint32,
|
|
13
|
+
glyphID: r.uint32
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
let UnicodeValueRange = new r.Struct({
|
|
17
|
-
startUnicodeValue:
|
|
18
|
-
additionalCount:
|
|
17
|
+
startUnicodeValue: r.uint24,
|
|
18
|
+
additionalCount: r.uint8
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
let UVSMapping = new r.Struct({
|
|
22
22
|
unicodeValue: r.uint24,
|
|
23
|
-
glyphID:
|
|
23
|
+
glyphID: r.uint16
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
let DefaultUVS = new r.Array(UnicodeValueRange, r.uint32);
|
|
27
27
|
let NonDefaultUVS = new r.Array(UVSMapping, r.uint32);
|
|
28
28
|
|
|
29
29
|
let VarSelectorRecord = new r.Struct({
|
|
30
|
-
varSelector:
|
|
31
|
-
defaultUVS:
|
|
32
|
-
nonDefaultUVS:
|
|
30
|
+
varSelector: r.uint24,
|
|
31
|
+
defaultUVS: new r.Pointer(r.uint32, DefaultUVS, { type: 'parent' }),
|
|
32
|
+
nonDefaultUVS: new r.Pointer(r.uint32, NonDefaultUVS, { type: 'parent' })
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
let CmapSubtable = new r.VersionedStruct(r.uint16, {
|
|
36
36
|
0: { // Byte encoding
|
|
37
|
-
length:
|
|
38
|
-
language:
|
|
39
|
-
codeMap:
|
|
37
|
+
length: r.uint16, // Total table length in bytes (set to 262 for format 0)
|
|
38
|
+
language: r.uint16, // Language code for this encoding subtable, or zero if language-independent
|
|
39
|
+
codeMap: new r.LazyArray(r.uint8, 256)
|
|
40
40
|
},
|
|
41
41
|
|
|
42
42
|
2: { // High-byte mapping (CJK)
|
|
43
|
-
length:
|
|
44
|
-
language:
|
|
45
|
-
subHeaderKeys:
|
|
46
|
-
subHeaderCount:
|
|
47
|
-
subHeaders:
|
|
48
|
-
glyphIndexArray:
|
|
43
|
+
length: r.uint16,
|
|
44
|
+
language: r.uint16,
|
|
45
|
+
subHeaderKeys: new r.Array(r.uint16, 256),
|
|
46
|
+
subHeaderCount: t => Math.max.apply(Math, t.subHeaderKeys),
|
|
47
|
+
subHeaders: new r.LazyArray(SubHeader, 'subHeaderCount'),
|
|
48
|
+
glyphIndexArray: new r.LazyArray(r.uint16, 'subHeaderCount')
|
|
49
49
|
},
|
|
50
50
|
|
|
51
51
|
4: { // Segment mapping to delta values
|
|
52
|
-
length:
|
|
53
|
-
language:
|
|
54
|
-
segCountX2:
|
|
55
|
-
segCount:
|
|
56
|
-
searchRange:
|
|
57
|
-
entrySelector:
|
|
58
|
-
rangeShift:
|
|
59
|
-
endCode:
|
|
60
|
-
reservedPad:
|
|
61
|
-
startCode:
|
|
62
|
-
idDelta:
|
|
63
|
-
idRangeOffset:
|
|
64
|
-
glyphIndexArray:
|
|
52
|
+
length: r.uint16, // Total table length in bytes
|
|
53
|
+
language: r.uint16, // Language code
|
|
54
|
+
segCountX2: r.uint16,
|
|
55
|
+
segCount: t => t.segCountX2 >> 1,
|
|
56
|
+
searchRange: r.uint16,
|
|
57
|
+
entrySelector: r.uint16,
|
|
58
|
+
rangeShift: r.uint16,
|
|
59
|
+
endCode: new r.LazyArray(r.uint16, 'segCount'),
|
|
60
|
+
reservedPad: new r.Reserved(r.uint16), // This value should be zero
|
|
61
|
+
startCode: new r.LazyArray(r.uint16, 'segCount'),
|
|
62
|
+
idDelta: new r.LazyArray(r.int16, 'segCount'),
|
|
63
|
+
idRangeOffset: new r.LazyArray(r.uint16, 'segCount'),
|
|
64
|
+
glyphIndexArray: new r.LazyArray(r.uint16, t => (t.length - t._currentOffset) / 2)
|
|
65
65
|
},
|
|
66
66
|
|
|
67
67
|
6: { // Trimmed table
|
|
68
|
-
length:
|
|
69
|
-
language:
|
|
70
|
-
firstCode:
|
|
71
|
-
entryCount:
|
|
72
|
-
glyphIndices:
|
|
68
|
+
length: r.uint16,
|
|
69
|
+
language: r.uint16,
|
|
70
|
+
firstCode: r.uint16,
|
|
71
|
+
entryCount: r.uint16,
|
|
72
|
+
glyphIndices: new r.LazyArray(r.uint16, 'entryCount')
|
|
73
73
|
},
|
|
74
74
|
|
|
75
75
|
8: { // mixed 16-bit and 32-bit coverage
|
|
76
76
|
reserved: new r.Reserved(r.uint16),
|
|
77
|
-
length:
|
|
77
|
+
length: r.uint32,
|
|
78
78
|
language: r.uint16,
|
|
79
|
-
is32:
|
|
80
|
-
nGroups:
|
|
81
|
-
groups:
|
|
79
|
+
is32: new r.LazyArray(r.uint8, 8192),
|
|
80
|
+
nGroups: r.uint32,
|
|
81
|
+
groups: new r.LazyArray(CmapGroup, 'nGroups')
|
|
82
82
|
},
|
|
83
83
|
|
|
84
84
|
10: { // Trimmed Array
|
|
85
|
-
reserved:
|
|
86
|
-
length:
|
|
87
|
-
language:
|
|
88
|
-
firstCode:
|
|
89
|
-
entryCount:
|
|
90
|
-
glyphIndices:
|
|
85
|
+
reserved: new r.Reserved(r.uint16),
|
|
86
|
+
length: r.uint32,
|
|
87
|
+
language: r.uint32,
|
|
88
|
+
firstCode: r.uint32,
|
|
89
|
+
entryCount: r.uint32,
|
|
90
|
+
glyphIndices: new r.LazyArray(r.uint16, 'numChars')
|
|
91
91
|
},
|
|
92
92
|
|
|
93
93
|
12: { // Segmented coverage
|
|
94
94
|
reserved: new r.Reserved(r.uint16),
|
|
95
|
-
length:
|
|
95
|
+
length: r.uint32,
|
|
96
96
|
language: r.uint32,
|
|
97
|
-
nGroups:
|
|
98
|
-
groups:
|
|
97
|
+
nGroups: r.uint32,
|
|
98
|
+
groups: new r.LazyArray(CmapGroup, 'nGroups')
|
|
99
99
|
},
|
|
100
100
|
|
|
101
101
|
13: { // Many-to-one range mappings (same as 12 except for group.startGlyphID)
|
|
102
102
|
reserved: new r.Reserved(r.uint16),
|
|
103
|
-
length:
|
|
103
|
+
length: r.uint32,
|
|
104
104
|
language: r.uint32,
|
|
105
|
-
nGroups:
|
|
106
|
-
groups:
|
|
105
|
+
nGroups: r.uint32,
|
|
106
|
+
groups: new r.LazyArray(CmapGroup, 'nGroups')
|
|
107
107
|
},
|
|
108
108
|
|
|
109
109
|
14: { // Unicode Variation Sequences
|
|
110
|
-
length:
|
|
111
|
-
numRecords:
|
|
110
|
+
length: r.uint32,
|
|
111
|
+
numRecords: r.uint32,
|
|
112
112
|
varSelectors: new r.LazyArray(VarSelectorRecord, 'numRecords')
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
115
|
|
|
116
116
|
let CmapEntry = new r.Struct({
|
|
117
|
-
platformID:
|
|
118
|
-
encodingID:
|
|
119
|
-
table:
|
|
117
|
+
platformID: r.uint16, // Platform identifier
|
|
118
|
+
encodingID: r.uint16, // Platform-specific encoding identifier
|
|
119
|
+
table: new r.Pointer(r.uint32, CmapSubtable, { type: 'parent', lazy: true })
|
|
120
120
|
});
|
|
121
121
|
|
|
122
122
|
// character to glyph mapping
|
|
123
123
|
export default new r.Struct({
|
|
124
|
-
version:
|
|
124
|
+
version: r.uint16,
|
|
125
125
|
numSubtables: r.uint16,
|
|
126
|
-
tables:
|
|
126
|
+
tables: new r.Array(CmapEntry, 'numSubtables')
|
|
127
127
|
});
|
package/src/tables/directory.js
CHANGED
|
@@ -2,22 +2,22 @@ import * as r from 'restructure';
|
|
|
2
2
|
import Tables from './';
|
|
3
3
|
|
|
4
4
|
let TableEntry = new r.Struct({
|
|
5
|
-
tag:
|
|
6
|
-
checkSum:
|
|
7
|
-
offset:
|
|
8
|
-
length:
|
|
5
|
+
tag: new r.String(4),
|
|
6
|
+
checkSum: r.uint32,
|
|
7
|
+
offset: new r.Pointer(r.uint32, 'void', { type: 'global' }),
|
|
8
|
+
length: r.uint32
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
let Directory = new r.Struct({
|
|
12
|
-
tag:
|
|
13
|
-
numTables:
|
|
14
|
-
searchRange:
|
|
15
|
-
entrySelector:
|
|
16
|
-
rangeShift:
|
|
17
|
-
tables:
|
|
12
|
+
tag: new r.String(4),
|
|
13
|
+
numTables: r.uint16,
|
|
14
|
+
searchRange: r.uint16,
|
|
15
|
+
entrySelector: r.uint16,
|
|
16
|
+
rangeShift: r.uint16,
|
|
17
|
+
tables: new r.Array(TableEntry, 'numTables')
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
Directory.process = function() {
|
|
20
|
+
Directory.process = function () {
|
|
21
21
|
let tables = {};
|
|
22
22
|
for (let table of this.tables) {
|
|
23
23
|
tables[table.tag] = table;
|
|
@@ -26,7 +26,7 @@ Directory.process = function() {
|
|
|
26
26
|
this.tables = tables;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
Directory.preEncode = function() {
|
|
29
|
+
Directory.preEncode = function () {
|
|
30
30
|
if (!Array.isArray(this.tables)) {
|
|
31
31
|
let tables = [];
|
|
32
32
|
for (let tag in this.tables) {
|
|
@@ -40,7 +40,7 @@ Directory.preEncode = function() {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
this.tables = tables;
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -50,7 +50,7 @@ Directory.preEncode = function() {
|
|
|
50
50
|
let maxExponentFor2 = Math.floor((Math.log(this.numTables) / Math.LN2));
|
|
51
51
|
let maxPowerOf2 = Math.pow(2, maxExponentFor2);
|
|
52
52
|
|
|
53
|
-
this.searchRange =
|
|
53
|
+
this.searchRange = maxPowerOf2 * 16;
|
|
54
54
|
this.entrySelector = Math.log(maxPowerOf2) / Math.LN2;
|
|
55
55
|
this.rangeShift = this.numTables * 16 - this.searchRange;
|
|
56
56
|
};
|
package/src/tables/gasp.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as r from 'restructure';
|
|
2
2
|
|
|
3
3
|
let GaspRange = new r.Struct({
|
|
4
|
-
rangeMaxPPEM:
|
|
5
|
-
rangeGaspBehavior:
|
|
4
|
+
rangeMaxPPEM: r.uint16, // Upper limit of range, in ppem
|
|
5
|
+
rangeGaspBehavior: new r.Bitfield(r.uint16, [ // Flags describing desired rasterizer behavior
|
|
6
6
|
'grayscale', 'gridfit',
|
|
7
|
-
'symmetricSmoothing', 'symmetricGridfit'
|
|
7
|
+
'symmetricSmoothing', 'symmetricGridfit' // only in version 1, for ClearType
|
|
8
8
|
])
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
export default new r.Struct({
|
|
12
|
-
version:
|
|
13
|
-
numRanges:
|
|
12
|
+
version: r.uint16, // set to 0
|
|
13
|
+
numRanges: r.uint16,
|
|
14
14
|
gaspRanges: new r.Array(GaspRange, 'numRanges') // Sorted by ppem
|
|
15
15
|
});
|
package/src/tables/glyf.js
CHANGED
package/src/tables/hdmx.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as r from 'restructure';
|
|
2
2
|
|
|
3
3
|
let DeviceRecord = new r.Struct({
|
|
4
|
-
pixelSize:
|
|
5
|
-
maximumWidth:
|
|
6
|
-
widths:
|
|
4
|
+
pixelSize: r.uint8,
|
|
5
|
+
maximumWidth: r.uint8,
|
|
6
|
+
widths: new r.Array(r.uint8, t => t.parent.parent.maxp.numGlyphs)
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
// The Horizontal Device Metrics table stores integer advance widths scaled to particular pixel sizes
|
|
10
10
|
export default new r.Struct({
|
|
11
|
-
version:
|
|
12
|
-
numRecords:
|
|
13
|
-
sizeDeviceRecord:
|
|
14
|
-
records:
|
|
11
|
+
version: r.uint16,
|
|
12
|
+
numRecords: r.int16,
|
|
13
|
+
sizeDeviceRecord: r.int32,
|
|
14
|
+
records: new r.Array(DeviceRecord, 'numRecords')
|
|
15
15
|
});
|