Skip to content

Commit 74fe1f4

Browse files
authored
GlyphSet.prototype.get can return undefined (#755)
* GlyphSet.prototype.get can return undefined Calling `font.glyphs.get(9999)` should return `undefined` if the glyph doesn't exist. * Simplify low memory mode check
1 parent f8108ec commit 74fe1f4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/glyphset.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ if(typeof Symbol !== 'undefined' && Symbol.iterator) {
6262

6363
/**
6464
* @param {number} index
65-
* @return {opentype.Glyph}
65+
* @return {opentype.Glyph | undefined}
6666
*/
6767
GlyphSet.prototype.get = function(index) {
6868
// this.glyphs[index] is 'undefined' when low memory mode is on. glyph is pushed on request only.
69-
if (this.glyphs[index] === undefined) {
69+
if (this.font._push && this.glyphs[index] === undefined) {
7070
this.font._push(index);
7171
if (typeof this.glyphs[index] === 'function') {
7272
this.glyphs[index] = this.glyphs[index]();

0 commit comments

Comments
 (0)