Skip to content

Commit

Permalink
Fix loading non-existent data from glyf table
Browse files Browse the repository at this point in the history
Signed-off-by: Vsevolod Volkov <[email protected]>
  • Loading branch information
Vsevolod Volkov committed Apr 7, 2023
1 parent c4a8820 commit 7c7e6ac
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/glyph/TTFGlyph.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,16 @@ export default class TTFGlyph extends Glyph {
return this.path.cbox;
}

let glyfPos = this._font.loca.offsets[this.id];
let nextPos = this._font.loca.offsets[this.id + 1];

// No data for this glyph (space?)
if (glyfPos === nextPos) {
return super._getCBox();
}

let stream = this._font._getTableStream('glyf');
stream.pos += this._font.loca.offsets[this.id];
stream.pos += glyfPos;
let glyph = GlyfHeader.decode(stream);

let cbox = new BBox(glyph.xMin, glyph.yMin, glyph.xMax, glyph.yMax);
Expand Down

0 comments on commit 7c7e6ac

Please sign in to comment.