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

draw(ctx, x, y, size) broken

Open achmurzy opened this issue 8 years ago • 5 comments

It would appear that the 'stroke' field on a path is not transferred when a container Glyph tries to draw it using Glyph.draw() of Glyph.getPath.draw(). Manually accessing the property with Glyph.path.draw() works fine because the 'stroke' field is preserved.

achmurzy avatar Feb 12 '17 20:02 achmurzy

Hi @achmurzy Could you provide a font / code to replicate that issue?

Jolg42 avatar Mar 29 '17 12:03 Jolg42

All fonts. Glyph.prototype.draw() calls Glyph.prototype.getPath() everytime, and a new Path object gets built every time. The consequence is not only loss of fill & stroke style, but also poor performance when rendering text with multiple occurrences of the same glyph.

fpirsch avatar Feb 26 '18 11:02 fpirsch

However, one could argue that caching glyphs is task of the next layer. I don't think opentype (the binary version) caches glyphs either, but that is left to pango. I'm for example caching rendered glyphs up to a certain size in canvases...

axkibe avatar Feb 26 '18 11:02 axkibe

You're right, so maybe the problem here is to store stroke and fill style in the path object. Also note that the next layer Font.prototype.draw(ctx, text, ...) doesn't cache paths either.

fpirsch avatar Feb 26 '18 15:02 fpirsch

Related to #509

Connum avatar Oct 30 '23 11:10 Connum