diff --git a/src/tables/os2.mjs b/src/tables/os2.mjs index 8392a8df..72d2f9af 100644 --- a/src/tables/os2.mjs +++ b/src/tables/os2.mjs @@ -165,6 +165,16 @@ function parseOS2Table(data, start) { for (let i = 0; i < 10; i++) { os2.panose[i] = p.parseByte(); } + os2.bFamilyType = os2.panose[0]; + os2.bSerifStyle = os2.panose[1]; + os2.bWeight = os2.panose[2]; + os2.bProportion = os2.panose[3]; + os2.bContrast = os2.panose[4]; + os2.bStrokeVariation = os2.panose[5]; + os2.bArmStyle = os2.panose[6]; + os2.bLetterform = os2.panose[7]; + os2.bMidline = os2.panose[8]; + os2.bXHeight = os2.panose[9]; os2.ulUnicodeRange1 = p.parseULong(); os2.ulUnicodeRange2 = p.parseULong(); diff --git a/test/tables/os2.spec.mjs b/test/tables/os2.spec.mjs new file mode 100644 index 00000000..d763f47a --- /dev/null +++ b/test/tables/os2.spec.mjs @@ -0,0 +1,33 @@ +import assert from 'assert'; +import { parse } from '../../dist/opentype.mjs'; +import { readFileSync } from 'fs'; +const loadSync = (url, opt) => parse(readFileSync(url), opt); + +describe('tables/os2.mjs', function () { + const font = loadSync('./test/fonts/AbrilFatface-Regular.otf'); + const testData = { + achVendID: 'TT\x00\x00', + usWeightClass: 400, + bFamilyType: 2, + bSerifStyle: 0, + bWeight: 5, + bProportion: 3, + bContrast: 0, + bStrokeVariation: 0, + bArmStyle: 0, + bLetterform: 2, + bMidline: 0, + bXHeight: 3, + }; + it('can read some OS2 table entries from file', function () { + for (const k in testData) { + assert.equal(font.tables.os2[k], testData[k]); + } + }); + const font2 = parse(font.toArrayBuffer()); + it('can write some OS2 table entries', function () { + for (const k in testData) { + assert.equal(font2.tables.os2[k], testData[k]); + } + }); +});