opentype.js icon indicating copy to clipboard operation
opentype.js copied to clipboard

Letter render on top of each other.

Open haszzam opened this issue 5 years ago • 2 comments
trafficstars

Hi i got this weird behavior for multiple fonts before and i have no idea what's wrong. for most fonts it works perfectly but for others, the letters just crumble on top pf each other like you can see here Capture

haszzam avatar Jan 26 '20 19:01 haszzam

Not 100% sure why but for some fonts Opentype mutates the glyph data after already calculated all metrics and overwrites the advance width with NaN. I use this snippet to avoid this:

Object.defineProperty(Glyph.prototype, 'advanceWidth', {
  get() {
    return this.storedAdvanceWidth;
  },
  set(value) {
    if (!Number.isNaN(value)) {
      this.storedAdvanceWidth = value;
    }
  },
});

swingerman avatar Sep 07 '21 08:09 swingerman

@Hassan-Azzam @swingerman could you please provide at least one font where this happens?

Connum avatar Nov 25 '23 16:11 Connum