opentype.js
Advanced tools
Comparing version 0.6.6 to 0.6.7
{ | ||
"name": "opentype.js", | ||
"version": "0.6.6", | ||
"version": "0.6.7", | ||
"main": "dist/opentype.js", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
{ | ||
"name": "opentype.js", | ||
"description": "OpenType font parser", | ||
"version": "0.6.6", | ||
"version": "0.6.7", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Frederik De Bleser", |
@@ -0,1 +1,5 @@ | ||
0.6.7 (Jan 5, 2017) | ||
========================= | ||
* Add basic support for Mac OS X format kern tables. | ||
0.6.6 (October 25, 2016) | ||
@@ -2,0 +6,0 @@ ========================= |
@@ -10,13 +10,9 @@ // The `kern` table contains kerning pairs. | ||
// Parse the `kern` table which contains kerning pairs. | ||
function parseKernTable(data, start) { | ||
function parseWindowsKernTable(p) { | ||
var pairs = {}; | ||
var p = new parse.Parser(data, start); | ||
var tableVersion = p.parseUShort(); | ||
check.argument(tableVersion === 0, 'Unsupported kern table version.'); | ||
// Skip nTables. | ||
p.skip('uShort', 1); | ||
var subTableVersion = p.parseUShort(); | ||
check.argument(subTableVersion === 0, 'Unsupported kern sub-table version.'); | ||
// Skip subTableLength, subTableCoverage | ||
p.skip('uShort'); | ||
var subtableVersion = p.parseUShort(); | ||
check.argument(subtableVersion === 0, 'Unsupported kern sub-table version.'); | ||
// Skip subtableLength, subtableCoverage | ||
p.skip('uShort', 2); | ||
@@ -32,6 +28,46 @@ var nPairs = p.parseUShort(); | ||
} | ||
return pairs; | ||
} | ||
function parseMacKernTable(p) { | ||
var pairs = {}; | ||
// The Mac kern table stores the version as a fixed (32 bits) but we only loaded the first 16 bits. | ||
// Skip the rest. | ||
p.skip('uShort'); | ||
var nTables = p.parseULong(); | ||
//check.argument(nTables === 1, 'Only 1 subtable is supported (got ' + nTables + ').'); | ||
if (nTables > 1) { | ||
console.warn('Only the first kern subtable is supported.'); | ||
} | ||
p.skip('uLong'); | ||
var coverage = p.parseUShort(); | ||
var subtableVersion = coverage & 0xFF; | ||
p.skip('uShort'); | ||
if (subtableVersion === 0) { | ||
var nPairs = p.parseUShort(); | ||
// Skip searchRange, entrySelector, rangeShift. | ||
p.skip('uShort', 3); | ||
for (var i = 0; i < nPairs; i += 1) { | ||
var leftIndex = p.parseUShort(); | ||
var rightIndex = p.parseUShort(); | ||
var value = p.parseShort(); | ||
pairs[leftIndex + ',' + rightIndex] = value; | ||
} | ||
} | ||
return pairs; | ||
} | ||
// Parse the `kern` table which contains kerning pairs. | ||
function parseKernTable(data, start) { | ||
var p = new parse.Parser(data, start); | ||
var tableVersion = p.parseUShort(); | ||
if (tableVersion === 0) { | ||
return parseWindowsKernTable(p); | ||
} else if (tableVersion === 1) { | ||
return parseMacKernTable(p); | ||
} else { | ||
throw new Error('Unsupported kern table version (' + tableVersion + ').'); | ||
} | ||
} | ||
exports.parse = parseKernTable; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
933028
73
18255