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.
This commit is contained in:
Daniel Eklöf 2019-01-09 18:30:35 +01:00
parent b52bdf14b2
commit f6977417e0
7 changed files with 167 additions and 111 deletions

11
font.h
View file

@ -7,16 +7,9 @@
struct font;
struct font *font_new(
const char *face, int size, bool italic, bool bold, int y_offset);
struct font *font_new(const char *name);
struct font *font_clone(const struct font *font);
void font_destroy(struct font *font);
const char *font_face(const struct font *font);
int font_size(const struct font *font);
bool font_is_italic(const struct font *font);
bool font_is_bold(const struct font *font);
int font_y_offset(const struct font *font);
cairo_scaled_font_t *font_use_in_cairo(const struct font *font, cairo_t *cr);
cairo_scaled_font_t *font_scaled_font(const struct font *font);