Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/glyphset.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ if(typeof Symbol !== 'undefined' && Symbol.iterator) {
*/
GlyphSet.prototype.get = function(index) {
// this.glyphs[index] is 'undefined' when low memory mode is on. glyph is pushed on request only.
if (this.glyphs[index] === undefined) {
if (this.glyphs[index] === undefined && typeof index === 'number') {
this.font._push(index);
if (typeof this.glyphs[index] === 'function') {
this.glyphs[index] = this.glyphs[index]();
Expand Down
17 changes: 17 additions & 0 deletions test/opentype.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,23 @@ describe('opentype.js on low memory mode', function() {
assert.equal(ndGlyph.unicode, undefined);
});

it('should return .notdef when looking up non-existent glyph in user-created font', function() {
const nullGlyph = new Glyph({
name: '.notdef',
path: new Path()
});
const font = new Font({
familyName: 'TestFont',
styleName: 'Medium',
unitsPerEm: 1000,
ascender: 800,
descender: -200,
glyphs: [nullGlyph]
});
const ndGlyph = font.charToGlyph('B');
assert.equal(ndGlyph.name, '.notdef');
});

it('should correctly set unicode 0 for .null glyph', function() {
const nullGlyph = new Glyph({
name: '.null',
Expand Down