opentype.js
opentype.js copied to clipboard
draw(ctx, x, y, size) broken
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.
Hi @achmurzy Could you provide a font / code to replicate that issue?
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.
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...
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.
Related to #509