Skip to content

Commit

Permalink
Add tests for 3-letter and private language tags
Browse files Browse the repository at this point in the history
See #108
  • Loading branch information
khaledhosny committed Nov 24, 2024
1 parent ca18f7e commit f86cdbe
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Binary file added test/fonts/noto/NotoSansDevanagari-Regular.otf
Binary file not shown.
44 changes: 44 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,50 @@ describe('shape', function () {
],
});
});

it('shape with 3-letter languae tag', function () {
this.blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSansDevanagari-Regular.otf')));
this.face = hb.createFace(this.blob);
this.font = hb.createFont(this.face);
this.buffer = hb.createBuffer();
this.buffer.addText('५ल');
this.buffer.guessSegmentProperties();
hb.shape(this.font, this.buffer)
var glyphs = this.buffer.json();
expect(glyphs).to.have.lengthOf(2);
expect(glyphs[0].g).to.equal(118);

this.buffer = hb.createBuffer();
this.buffer.addText('५ल');
this.buffer.setLanguage('dty');
this.buffer.guessSegmentProperties();
hb.shape(this.font, this.buffer)
var glyphs = this.buffer.json();
expect(glyphs).to.have.lengthOf(2);
expect(glyphs[0].g).to.equal(123);
});

it('shape with OpenType language tag', function () {
this.blob = hb.createBlob(fs.readFileSync(path.join(__dirname, 'fonts/noto/NotoSansDevanagari-Regular.otf')));
this.face = hb.createFace(this.blob);
this.font = hb.createFont(this.face);
this.buffer = hb.createBuffer();
this.buffer.addText('५ल');
this.buffer.guessSegmentProperties();
hb.shape(this.font, this.buffer)
var glyphs = this.buffer.json();
expect(glyphs).to.have.lengthOf(2);
expect(glyphs[0].g).to.equal(118);

this.buffer = hb.createBuffer();
this.buffer.addText('५ल');
this.buffer.setLanguage('x-hbot-4e455020'); // 'NEP '
this.buffer.guessSegmentProperties();
hb.shape(this.font, this.buffer)
var glyphs = this.buffer.json();
expect(glyphs).to.have.lengthOf(2);
expect(glyphs[0].g).to.equal(123);
});
});

describe('misc', function () {
Expand Down

0 comments on commit f86cdbe

Please sign in to comment.