From 03a5c8746fb525775ee8f2702e6c74a779bd66ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 22 Apr 2020 11:49:22 +0200 Subject: [PATCH] fcft: adjust to fcft-2.0 API changes * font_*() -> fcft_*() * struct font -> struct fcft_font * struct glyph -> struct fcft_glyph * enum subpixel_order -> enum fcft_subpixel --- config.c | 16 ++++++++-------- config.h | 4 ++-- particle.c | 4 ++-- particle.h | 4 ++-- particles/string.c | 15 +++++++++------ 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/config.c b/config.c index d10ce04..556891c 100644 --- a/config.c +++ b/config.c @@ -64,10 +64,10 @@ conf_to_color(const struct yml_node *node) }; } -struct font * +struct fcft_font * conf_to_font(const struct yml_node *node) { - return font_from_name(1, &(const char *){yml_value_as_string(node)}, NULL); + return fcft_from_name(1, &(const char *){yml_value_as_string(node)}, NULL); } struct deco * @@ -113,7 +113,7 @@ particle_simple_list_from_config(const struct yml_node *node, } struct particle *common = particle_common_new( - 0, 0, NULL, font_clone(inherited.font), inherited.foreground, NULL); + 0, 0, NULL, fcft_clone(inherited.font), inherited.foreground, NULL); return particle_list_new(common, parts, count, 0, 2); } @@ -153,8 +153,8 @@ conf_to_particle(const struct yml_node *node, struct conf_inherit inherited) * clone the font, since each particle takes ownership of its own * font. */ - struct font *font = font_node != NULL - ? conf_to_font(font_node) : font_clone(inherited.font); + struct fcft_font *font = font_node != NULL + ? conf_to_font(font_node) : fcft_clone(inherited.font); pixman_color_t foreground = foreground_node != NULL ? conf_to_color(foreground_node) : inherited.foreground; @@ -263,12 +263,12 @@ conf_to_bar(const struct yml_node *bar, enum bar_backend backend) * and particles. This allows us to specify a default font and * foreground color at top-level. */ - struct font *font = font_from_name(1, &(const char *){"sans"}, NULL); + struct fcft_font *font = fcft_from_name(1, &(const char *){"sans"}, NULL); pixman_color_t foreground = {0xffff, 0xffff, 0xffff, 0xffff}; /* White */ const struct yml_node *font_node = yml_get_value(bar, "font"); if (font_node != NULL) { - font_destroy(font); + fcft_destroy(font); font = conf_to_font(font_node); } @@ -339,7 +339,7 @@ conf_to_bar(const struct yml_node *bar, enum bar_backend backend) free(conf.left.mods); free(conf.center.mods); free(conf.right.mods); - font_destroy(font); + fcft_destroy(font); return ret; } diff --git a/config.h b/config.h index 3610c1f..56f5b2e 100644 --- a/config.h +++ b/config.h @@ -15,10 +15,10 @@ struct bar *conf_to_bar(const struct yml_node *bar, enum bar_backend backend); */ pixman_color_t conf_to_color(const struct yml_node *node); -struct font *conf_to_font(const struct yml_node *node); +struct fcft_font *conf_to_font(const struct yml_node *node); struct conf_inherit { - const struct font *font; + const struct fcft_font *font; pixman_color_t foreground; }; diff --git a/particle.c b/particle.c index 5508f16..be98e0e 100644 --- a/particle.c +++ b/particle.c @@ -21,7 +21,7 @@ particle_default_destroy(struct particle *particle) { if (particle->deco != NULL) particle->deco->destroy(particle->deco); - font_destroy(particle->font); + fcft_destroy(particle->font); free(particle->on_click_template); free(particle); } @@ -29,7 +29,7 @@ particle_default_destroy(struct particle *particle) struct particle * particle_common_new(int left_margin, int right_margin, const char *on_click_template, - struct font *font, pixman_color_t foreground, + struct fcft_font *font, pixman_color_t foreground, struct deco *deco) { struct particle *p = calloc(1, sizeof(*p)); diff --git a/particle.h b/particle.h index 9bd417e..e89b9c4 100644 --- a/particle.h +++ b/particle.h @@ -16,7 +16,7 @@ struct particle { char *on_click_template; pixman_color_t foreground; - struct font *font; + struct fcft_font *font; struct deco *deco; void (*destroy)(struct particle *particle); @@ -47,7 +47,7 @@ struct exposable { struct particle *particle_common_new( int left_margin, int right_margin, const char *on_click_template, - struct font *font, pixman_color_t foreground, struct deco *deco); + struct fcft_font *font, pixman_color_t foreground, struct deco *deco); void particle_default_destroy(struct particle *particle); diff --git a/particles/string.c b/particles/string.c index eda125f..9bfb5b5 100644 --- a/particles/string.c +++ b/particles/string.c @@ -19,7 +19,7 @@ struct eprivate { /* Set when instantiating */ char *text; - const struct glyph **glyphs; + const struct fcft_glyph **glyphs; long *kern_x; int num_glyphs; }; @@ -40,7 +40,7 @@ static int begin_expose(struct exposable *exposable) { struct eprivate *e = exposable->private; - struct font *font = exposable->particle->font; + struct fcft_font *font = exposable->particle->font; e->glyphs = NULL; e->num_glyphs = 0; @@ -55,15 +55,18 @@ begin_expose(struct exposable *exposable) /* Convert text to glyph masks/images. */ for (size_t i = 0; i < chars; i++) { - const struct glyph *glyph = font_glyph_for_wc(font, wtext[i], false); + const struct fcft_glyph *glyph = fcft_glyph_for_wc( + font, wtext[i], FCFT_SUBPIXEL_NONE); + if (glyph == NULL) continue; + e->glyphs[e->num_glyphs++] = glyph; if (i == 0) continue; - font_kerning(font, wtext[i - 1], wtext[i], &e->kern_x[i], NULL); + fcft_kerning(font, wtext[i - 1], wtext[i], &e->kern_x[i], NULL); } } @@ -83,7 +86,7 @@ expose(const struct exposable *exposable, pixman_image_t *pix, int x, int y, int exposable_render_deco(exposable, pix, x, y, height); const struct eprivate *e = exposable->private; - const struct font *font = exposable->particle->font; + const struct fcft_font *font = exposable->particle->font; if (e->num_glyphs == 0) return; @@ -111,7 +114,7 @@ expose(const struct exposable *exposable, pixman_image_t *pix, int x, int y, int /* Loop glyphs and render them, one by one */ for (int i = 0; i < e->num_glyphs; i++) { - const struct glyph *glyph = e->glyphs[i]; + const struct fcft_glyph *glyph = e->glyphs[i]; assert(glyph != NULL); x += e->kern_x[i];