Commit graph

5 commits

Author SHA1 Message Date
Daniel Eklöf
41c53a7b2f font: ref-count font objects 2019-01-15 21:01:18 +01:00
Daniel Eklöf
7525ae99eb font: cache loaded fonts
Instantiating a new font is expensive, both in CPU and
memory. Mitigate by adding a cache. On a hit, instead of instantiating
a new font, clone the one from the cache.

Remember, cloning is basically just a ref counter bump.
2019-01-15 20:48:04 +01:00
Daniel Eklöf
770f2a0e7c font: allow font_destroy() to be called with a NULL pointer 2019-01-13 13:24:56 +01:00
Daniel Eklöf
f6977417e0 font: use font-config to load font
This allows us to a) move away from cairo's "toy" API, and b) let the
user specify font options in a single font "name" string:

  Serif:size=10:weight=bold:slant=italic

This also allows us to simplify the font code significantly (except
for the fontconfig parts...); the font no longer sets itself in a
cairo surface - font users do that; the font simply returns a
cairo_scaled_font_t.

Furthermore, font_clone() has now been simplified to basically just
refcount the scaled font. I.e. there's no need to run the full
constructor and lookup and instantiate the cairo scaled font again.
2019-01-09 18:50:16 +01:00
Daniel Eklöf
8bf8a398b9 initial commit: wip 2018-11-17 11:30:33 +01:00