Skip to content

Commit

Permalink
Updated tests for Panose and head table
Browse files Browse the repository at this point in the history
  • Loading branch information
mattlag committed Nov 6, 2023
1 parent 67ecfeb commit 81b2508
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions test/font.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,26 @@ describe('font.js', function() {
assert.equal(font.tables.os2.bMidline, 0);
assert.equal(font.tables.os2.bXHeight, 0);
});
it('panose values are set correctly', function () {
let panoseFont = new Font({
familyName: 'MyFont',
styleName: 'Medium',
unitsPerEm: 1000,
ascender: 800,
descender: 0,
panose: [0, 1,2,3,4,5,6,7,8,9],
});
assert.equal(panoseFont.tables.os2.bFamilyType, 0);
assert.equal(panoseFont.tables.os2.bSerifStyle, 1);
assert.equal(panoseFont.tables.os2.bWeight, 2);
assert.equal(panoseFont.tables.os2.bProportion, 3);
assert.equal(panoseFont.tables.os2.bContrast, 4);
assert.equal(panoseFont.tables.os2.bStrokeVariation, 5);
assert.equal(panoseFont.tables.os2.bArmStyle, 6);
assert.equal(panoseFont.tables.os2.bLetterform, 7);
assert.equal(panoseFont.tables.os2.bMidline, 8);
assert.equal(panoseFont.tables.os2.bXHeight, 9);
});
it('fsSelection and macStyle are calcluated if no fsSelection value is provided', function() {
let weightClassFont = new Font({
familyName: 'MyFont',
Expand All @@ -68,7 +88,8 @@ describe('font.js', function() {
fsSelection: false,
});
assert.equal(weightClassFont.tables.os2.fsSelection, 32);
assert.equal(weightClassFont.toTables().tables[0].macStyle, 32);
const weightClassHeadTable = weightClassFont.toTables().tables.find(table => table.tableName === 'head');
assert.equal(weightClassHeadTable.macStyle, 32);

let italicAngleFont = new Font({
familyName: 'MyFont',
Expand All @@ -80,7 +101,8 @@ describe('font.js', function() {
fsSelection: false,
});
assert.equal(italicAngleFont.tables.os2.fsSelection, 1);
assert.equal(italicAngleFont.toTables().tables[0].macStyle, 1);
const italicAngleHeadTable = italicAngleFont.toTables().tables.find(table => table.tableName === 'head');
assert.equal(italicAngleHeadTable.macStyle, 1);
});
it('tables definition shall be serialized', function() {
const os2 = font.toTables().tables.find(table => table.tableName === 'OS/2');
Expand Down

0 comments on commit 81b2508

Please sign in to comment.