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

advanceWidth of Glyph is set to NaN after calling getBoundingBox

Open adriaanmeuris opened this issue 5 years ago • 3 comments
trafficstars

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

  • Version used: 1.1.0
  • Font used: Sugardrop (see link above)
  • Browser Name and version: Node 10.17.0
  • Operating System and version (desktop or mobile): MacOS Catalina
  • Link to your project: see snippet above

adriaanmeuris avatar Dec 16 '19 17:12 adriaanmeuris

Is there any work around for this?

catmando avatar Jul 14 '20 23:07 catmando

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

Connum avatar Nov 25 '23 16:11 Connum