You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, if you load a variable font (e.g. test/manual-test-examples/type/font/BricolageGrotesque-Variable.ttf) in WebGL mode, word wrapping and measurement is currently broken because the parameters that Typr seems to read are different than the variables picked by default by the 2D canvas, which is what is used for measurement.
Typr now supports reading variable font data (photopea/Typr.js#56) so it seems like after updating Typr, we should be able to make these match!
One other complication: We currently associate one FontInfo (containing font bezier cache data for WebGL) with one font:
However, we will need a new FontInfo whenever any variable changes for the font, as that will change all the bezier data. So we likely will also need to have a cache by variable value in the font (possibly using a lot of memory if these change a lot? maybe needing an LRU cache to evict old ones?), or just invalidate the existing font info whenever variables change (possibly slow if this is animating every frame.)
The text was updated successfully, but these errors were encountered:
davepagurek
changed the title
[2.0] Make Typr p5.Fonts use the same variables as the 2D canvas
[2.0] Make variable Typr p5.Fonts use the same variables as the 2D canvas
Dec 24, 2024
Most appropriate sub-area of p5.js?
p5.js version
dev-2.0
Web browser and version
Firefox
Operating system
MacOS
Steps to reproduce this
Currently, if you load a variable font (e.g.
test/manual-test-examples/type/font/BricolageGrotesque-Variable.ttf
) in WebGL mode, word wrapping and measurement is currently broken because the parameters that Typr seems to read are different than the variables picked by default by the 2D canvas, which is what is used for measurement.Typr now supports reading variable font data (photopea/Typr.js#56) so it seems like after updating Typr, we should be able to make these match!
One other complication: We currently associate one
FontInfo
(containing font bezier cache data for WebGL) with one font:p5.js/src/webgl/text.js
Lines 687 to 690 in 05e35cb
However, we will need a new
FontInfo
whenever any variable changes for the font, as that will change all the bezier data. So we likely will also need to have a cache by variable value in the font (possibly using a lot of memory if these change a lot? maybe needing an LRU cache to evict old ones?), or just invalidate the existing font info whenever variables change (possibly slow if this is animating every frame.)The text was updated successfully, but these errors were encountered: