Skip to content

Commit

Permalink
test: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
yisibl committed May 21, 2021
1 parent ab793d3 commit 56b2736
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ttf/tables/os2.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function createOS2Table(font) {
// Spec: https://docs.microsoft.com/en-us/typography/opentype/spec/os2#uswinascent
// ufo2ft: https://github.com/googlefonts/ufo2ft/blob/a5267d135d5a8dba7e6a5d3ac44139afa6159429/Lib/ufo2ft/fontInfoData.py#L245-L246
buf.writeInt16(font.ascent + font.lineGap); // usWinAscent(Windows ascender), Fallback to ascender + typoLineGap.

// Spec: https://docs.microsoft.com/en-us/typography/opentype/spec/os2#uswindescent
// ufo2ft: https://github.com/googlefonts/ufo2ft/blob/a5267d135d5a8dba7e6a5d3ac44139afa6159429/Lib/ufo2ft/fontInfoData.py#L254
buf.writeInt16(Math.abs(font.descent)); // usWinDescent(Windows descender), Fallback to descender.
Expand Down
Binary file modified test/fixtures/arrow.ttf
Binary file not shown.
Binary file modified test/fixtures/shenheweitongguo.ttf
Binary file not shown.
29 changes: 29 additions & 0 deletions test/fixtures/yezi.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,29 @@ describe('test wuxushenhe.svg', function () {
assert.strictEqual(tables.head.xMax, 2045);
});
});

describe('test yezi.svg', function () {
var src = fs.readFileSync(path.join(__dirname, 'fixtures/yezi.svg'), 'utf-8');
var tables = parseFont(src).tables;

// Use font data generated by nanoemoji for comparison.
it('head.xMin', function () {
// 9235 is wrong
assert.strictEqual(tables.head.xMin, 481);
});

it('head.yMin', function () {
// -11936 is wrong
assert.strictEqual(tables.head.yMin, 458);
});

it('head.xMax', function () {
// 30060 is wrong
assert.strictEqual(tables.head.xMax, 993);
});

it('head.yMax', function () {
// -9161 is wrong
assert.strictEqual(tables.head.yMax, 745);
});
});

0 comments on commit 56b2736

Please sign in to comment.