Skip to content

Commit

Permalink
cff: test: Roundtrip check of private DICT
Browse files Browse the repository at this point in the history
[why]
Writing of the private DICT has been added together with the translation
of delta values from transport encoding to readable and back. But there
is no automated test to see if something breaks.

[how]
Take one of the fonts in test/fonts/ and run in through ttx to see its
private DICT data analyzed by someone else.

Add a test that also reads that fond and checks some of the private DICT
values.

Write the font into a buffer and read it back in; repeat the check on
the read back font. This also checks if writing is correct.

Signed-off-by: Fini Jastrow <[email protected]>
  • Loading branch information
Finii committed Sep 9, 2024
1 parent 392a6b7 commit dad7f74
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/tables/cff.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,32 @@ describe('tables/cff.mjs', function () {
transformedPoints
);
});

it('does round trip CFF private DICT', function() {
const font = loadSync('./test/fonts/AbrilFatface-Regular.otf');
const checkerFunktion = function(inputFont) {
// from ttx:
// <Private>
// <BlueValues value="-10 0 476 486 700 711"/>
// <OtherBlues value="-250 -238"/>
// <BlueScale value="0.039625"/>
// <BlueShift value="7"/>
// <BlueFuzz value="1"/>
// <StdHW value="18"/>
// <StdVW value="186"/>
// <StemSnapH value="16 18 21"/>
// <StemSnapV value="120 186 205"/>
// <ForceBold value="0"/>
const privateDict = inputFont.tables.cff.topDict._privateDict;
assert.deepEqual(privateDict.blueValues, [-10, 0, 476, 486, 700, 711]);
assert.deepEqual(privateDict.otherBlues, [-250, -238]);
assert.equal(privateDict.stdHW, 18);
assert.deepEqual(privateDict.stemSnapH, [16, 18, 21]);
assert.equal(privateDict.nominalWidthX, 590);
};
checkerFunktion(font);
let buffer = font.toArrayBuffer()
let font2 = parse(buffer);
checkerFunktion(font2);
});
});

0 comments on commit dad7f74

Please sign in to comment.