opentypejs / opentype.js

Read and write OpenType fonts using JavaScript.
https://opentype.js.org/
MIT License
4.36k stars 467 forks source link

advanceWidth of Glyph is set to NaN after calling getBoundingBox #417

Open adriaanmeuris opened 4 years ago

adriaanmeuris commented 4 years ago

Expected Behavior

When calling the getBoundingBox method for a glyph, the advanceWidth property does not change

Current Behavior

For some fonts, the advanceWidth is set to NaN.

Steps to Reproduce (for bugs)

Use this font: Sugardrop.otf.zip

// Require modules
const assert = require('assert');
const opentype = require('./opentype.min.js');

// Load the font
opentype.load('./Sugardrop.otf', function(err, font) {
    if (err) {
        console.error('Font could not be loaded: ' + err);
    } else {
        // Get glyph for A
        const A = font.glyphs.glyphs[36];

        // Advance width is equal to 749
        assert.equal(A.advanceWidth, 749);

        // Get the bounding box
        A.getBoundingBox();

        // Advance width is not equal to 749 anymore but NaN
        assert.equal(A.advanceWidth, 749);
    }
});

Your Environment

catmando commented 3 years ago

Is there any work around for this?

Connum commented 7 months ago

Sounds like this is related to #397 and might have been fixed already, I'm going to check...

ILOVEPIE commented 1 month ago

@Connum has this been fixed?