Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/tables/os2.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
33 changes: 33 additions & 0 deletions test/tables/os2.spec.mjs
Original file line number Diff line number Diff line change
@@ -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]);
}
});
});