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

The example even not work,

Open orklann opened this issue 7 years ago • 3 comments

var notdefGlyph = new opentype.Glyph({
    name: '.notdef',
    unicode: 0,
    advanceWidth: 650,
    path: new opentype.Path()
});

var aPath = new opentype.Path();
aPath.moveTo(100, 0);
aPath.lineTo(100, 700);
// more drawing instructions...
var aGlyph = new opentype.Glyph({
    name: 'A',
    unicode: 65,
    advanceWidth: 650,
    path: aPath
});

var glyphs = [notdefGlyph, aGlyph];

// Log out `A` path, which result NaN
console.log(aGlyph.getPath());

var font = new opentype.Font({
    familyName: 'OpenTypeSans',
    styleName: 'Medium',
    unitsPerEm: 1000,
    ascender: 800,
    descender: -200,
    glyphs: glyphs
    });
font.download();

And the A glyph's path are all NaN

Output

[Log] Path (index.html, line 28)

commands: [{type: "M", x: NaN, y: NaN}, {type: "L", x: NaN, y: NaN}] (2)

fill: "black"

stroke: null

strokeWidth: 1

Path Prototype

What am I doing wrong?

orklann avatar May 18 '18 07:05 orklann

Hi!

Are you using the latest version on npm or the master branch maybe? In the browser or with Node.js (Which version?)

Also if you could join a full example as a gist it would help ;-)

Jolg42 avatar Jun 12 '18 14:06 Jolg42

@Jolg42 Sorry for the long waiting, I am busy these few days.

I make a repo which is very simple demo for showing this issue, please have a check.

Opentype.js Demo

Open the html, and check the console.

orklann avatar Jun 18 '18 08:06 orklann

You are not loading any font.

axkibe avatar Feb 22 '19 12:02 axkibe

Closing this stale issue.

Connum avatar Apr 21 '24 09:04 Connum