linebender / piet

An abstraction for 2D graphics.
Apache License 2.0
1.24k stars 93 forks source link

Cache CTFont handles on macOS #472

Closed jpochyla closed 2 years ago

jpochyla commented 2 years ago

This implements caching of CTFont handles, not unlike the current font-family cache. This solves a real bottleneck I have in Psst (where creating lot of labels used to be really slow). I've used the associative-cache crate, because it is used in the Direct2D backend already (for caching gradients), and also switched the font family cache to it, for consistency.

Thanks!

jpochyla commented 2 years ago

I've added the alias and decreased cache size to 64 for both font-families and ctfonts.

cmyr commented 2 years ago

great, thanks!