Skip to content

Commit

Permalink
support hinting GPOS kern
Browse files Browse the repository at this point in the history
  • Loading branch information
kekee000 committed Nov 9, 2019
1 parent 6f614bc commit 2a493d3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ttf/ttfreader.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ export default class TTFReader {
delete ttf.fpgm;
delete ttf.cvt;
delete ttf.prep;

delete ttf.GPOS;
delete ttf.kern;
ttf.glyf.forEach(function (glyf) {
delete glyf.instructions;
});
Expand Down
Binary file added test/data/SFNSDisplayCondensed-Black.otf
Binary file not shown.
8 changes: 8 additions & 0 deletions test/spec/ttf/otfreader.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ describe('读otf数据', function () {

});

describe('读otf hinting GPOS kern', function () {
let fontObject = new OTFReader().read(readData('SFNSDisplayCondensed-Black.otf'));

it('test read hinting', function () {
assert.equal(fontObject.GPOS.length, 57290);
});

});

describe('读错误otf数据', function () {

Expand Down
17 changes: 17 additions & 0 deletions test/spec/ttf/ttfreader.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,23 @@ describe('读ttf hinting数据', function () {
assert.equal(fontObject.fpgm.length, 371);
assert.equal(fontObject.prep.length, 204);
assert.equal(fontObject.gasp.length, 8);
assert.equal(fontObject.GPOS.length, 18);
fontObject.kern && assert.equal(fontObject.kern.length, 8);
});

});

describe('读ttf hinting GPOS kern', function () {
let fontObject = new TTFReader({
hinting: true
}).read(readData('baiduHealth-hinting.ttf'));

it('test read hinting', function () {
assert.equal(fontObject.cvt.length, 24);
assert.equal(fontObject.fpgm.length, 371);
assert.equal(fontObject.prep.length, 204);
assert.equal(fontObject.gasp.length, 8);
assert.equal(fontObject.GPOS.length, 18);
});

});
Expand Down
1 change: 1 addition & 0 deletions test/spec/ttf/ttfwriter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,6 @@ describe('写ttf hinting数据', function () {
assert.equal(fontObject.fpgm.length, 371);
assert.equal(fontObject.prep.length, 204);
assert.equal(fontObject.gasp.length, 8);
assert.equal(fontObject.GPOS.length, 18);
});
});

0 comments on commit 2a493d3

Please sign in to comment.