Skip to content

Commit

Permalink
GlyphSet.prototype.get can return undefined (#755)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
forresto authored Sep 9, 2024
1 parent f8108ec commit 74fe1f4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/glyphset.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ if(typeof Symbol !== 'undefined' && Symbol.iterator) {

/**
* @param {number} index
* @return {opentype.Glyph}
* @return {opentype.Glyph | undefined}
*/
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.font._push && this.glyphs[index] === undefined) {
this.font._push(index);
if (typeof this.glyphs[index] === 'function') {
this.glyphs[index] = this.glyphs[index]();
Expand Down

0 comments on commit 74fe1f4

Please sign in to comment.