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 1/6] 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]; From 60a8bc7fb0fb95b4d650c5ffdabfb54b17d51f7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 23 Apr 2020 11:25:58 +0200 Subject: [PATCH 2/6] meson: we now require fcft 2.0.x --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 543aeab..5fa4aec 100644 --- a/meson.build +++ b/meson.build @@ -65,7 +65,7 @@ backend_wayland = wayland_client.found() and wayland_cursor.found() and wlroots. # "My" dependencies, fallback to subproject tllist = dependency('tllist', version: '>=1.0.0', fallback: ['tllist', 'tllist']) -fcft = dependency('fcft', version: ['>=1.1.0', '<1.2.0'], fallback: ['fcft', 'fcft']) +fcft = dependency('fcft', version: ['>=2.0.0', '<2.1.0'], fallback: ['fcft', 'fcft']) add_project_arguments( ['-D_GNU_SOURCE'] + From e5ef81a064797a7aba042ec5ed7c7ed548b3345e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 23 Apr 2020 11:57:50 +0200 Subject: [PATCH 3/6] fcft: max/space advance fields have been renamed --- particles/string.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/particles/string.c b/particles/string.c index 9bfb5b5..07679b5 100644 --- a/particles/string.c +++ b/particles/string.c @@ -75,7 +75,7 @@ begin_expose(struct exposable *exposable) /* Calculate the size we need to render the glyphs */ for (int i = 0; i < e->num_glyphs; i++) - exposable->width += e->kern_x[i] + e->glyphs[i]->x_advance; + exposable->width += e->kern_x[i] + e->glyphs[i]->advance.x; return exposable->width; } @@ -135,7 +135,7 @@ expose(const struct exposable *exposable, pixman_image_t *pix, int x, int y, int pixman_image_unref(src); } - x += glyph->x_advance; + x += glyph->advance.x; } } From 234a7878598c73ea42d69af6e1ddb58c71f1a07c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 24 Apr 2020 10:54:15 +0200 Subject: [PATCH 4/6] fcft: fcft_glyph_for_wc() has been renamed to fcft_glyph_rasterize() --- particles/string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/particles/string.c b/particles/string.c index 07679b5..5e98132 100644 --- a/particles/string.c +++ b/particles/string.c @@ -55,7 +55,7 @@ begin_expose(struct exposable *exposable) /* Convert text to glyph masks/images. */ for (size_t i = 0; i < chars; i++) { - const struct fcft_glyph *glyph = fcft_glyph_for_wc( + const struct fcft_glyph *glyph = fcft_glyph_rasterize( font, wtext[i], FCFT_SUBPIXEL_NONE); if (glyph == NULL) From badf9b7622322446680b24158b8dad6d9a58374c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 24 Apr 2020 20:19:16 +0200 Subject: [PATCH 5/6] meson: use simpler variant of dependency fallback for tllist+fcft we now require tllist>=1.0.1 and fcft>=2.0.0, which both use meson.override_dependency(). Thus, we can use the simpler form of fallback in our dependency() call.s This also updates the PKGBUILD files to require tllist>=1.0.1 and fcft>=2.0.0 --- PKGBUILD | 4 ++-- PKGBUILD.wayland-only | 4 ++-- meson.build | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index 2d3686c..3f278df 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -5,7 +5,7 @@ pkgdesc="Simplistic and highly configurable status panel for X and Wayland" arch=('x86_64') url=https://codeberg.org/dnkl/yambar license=(mit) -makedepends=('meson' 'ninja' 'scdoc' 'tllist>=1.0.0') +makedepends=('meson' 'ninja' 'scdoc' 'tllist>=1.0.1') depends=( 'libxcb' 'xcb-util' 'xcb-util-cursor' 'xcb-util-wm' 'wayland' 'wlroots' @@ -15,7 +15,7 @@ depends=( 'libudev.so' 'json-c' 'libmpdclient' - 'fcft>=1.1.0') + 'fcft>=2.0.0') optdepends=('xcb-util-errors: better X error messages') source=() diff --git a/PKGBUILD.wayland-only b/PKGBUILD.wayland-only index 7414fda..f68f9eb 100644 --- a/PKGBUILD.wayland-only +++ b/PKGBUILD.wayland-only @@ -7,7 +7,7 @@ url=https://codeberg.org/dnkl/yambar license=(mit) conflicts=('yambar') provides=('yambar') -makedepends=('meson' 'ninja' 'scdoc' 'tllist>=1.0.0') +makedepends=('meson' 'ninja' 'scdoc' 'tllist>=1.0.1') depends=( 'wayland' 'wlroots' 'pixman' @@ -16,7 +16,7 @@ depends=( 'libudev.so' 'json-c' 'libmpdclient' - 'fcft>=1.0.0') + 'fcft>=2.0.0') source=() pkgver() { diff --git a/meson.build b/meson.build index 5fa4aec..22f363c 100644 --- a/meson.build +++ b/meson.build @@ -64,8 +64,8 @@ wlroots = dependency('wlroots', required: get_option('backend-wayland')) backend_wayland = wayland_client.found() and wayland_cursor.found() and wlroots.found() # "My" dependencies, fallback to subproject -tllist = dependency('tllist', version: '>=1.0.0', fallback: ['tllist', 'tllist']) -fcft = dependency('fcft', version: ['>=2.0.0', '<2.1.0'], fallback: ['fcft', 'fcft']) +tllist = dependency('tllist', version: '>=1.0.1', fallback: 'tllist') +fcft = dependency('fcft', version: ['>=2.0.0', '<2.1.0'], fallback: 'fcft') add_project_arguments( ['-D_GNU_SOURCE'] + From bf7cd9a6179a2f6c63d2ea2749301fbfceea1c79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 24 Apr 2020 20:21:37 +0200 Subject: [PATCH 6/6] meson: using a fallback without a variable name requires meson >= 0.53 --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 22f363c..3dd95b8 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project('yambar', 'c', version: '1.4.0', license: 'MIT', - meson_version: '>=0.48.0', + meson_version: '>=0.53.0', default_options: ['c_std=c11', 'warning_level=1', 'werror=true',