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
This commit is contained in:
Daniel Eklöf 2020-04-22 11:49:22 +02:00
parent b9e7417137
commit 03a5c8746f
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
5 changed files with 23 additions and 20 deletions

View file

@ -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) 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 * struct deco *
@ -113,7 +113,7 @@ particle_simple_list_from_config(const struct yml_node *node,
} }
struct particle *common = particle_common_new( 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); 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 * clone the font, since each particle takes ownership of its own
* font. * font.
*/ */
struct font *font = font_node != NULL struct fcft_font *font = font_node != NULL
? conf_to_font(font_node) : font_clone(inherited.font); ? conf_to_font(font_node) : fcft_clone(inherited.font);
pixman_color_t foreground = foreground_node != NULL pixman_color_t foreground = foreground_node != NULL
? conf_to_color(foreground_node) : inherited.foreground; ? 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 * and particles. This allows us to specify a default font and
* foreground color at top-level. * 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 */ pixman_color_t foreground = {0xffff, 0xffff, 0xffff, 0xffff}; /* White */
const struct yml_node *font_node = yml_get_value(bar, "font"); const struct yml_node *font_node = yml_get_value(bar, "font");
if (font_node != NULL) { if (font_node != NULL) {
font_destroy(font); fcft_destroy(font);
font = conf_to_font(font_node); 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.left.mods);
free(conf.center.mods); free(conf.center.mods);
free(conf.right.mods); free(conf.right.mods);
font_destroy(font); fcft_destroy(font);
return ret; return ret;
} }

View file

@ -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); 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 { struct conf_inherit {
const struct font *font; const struct fcft_font *font;
pixman_color_t foreground; pixman_color_t foreground;
}; };

View file

@ -21,7 +21,7 @@ particle_default_destroy(struct particle *particle)
{ {
if (particle->deco != NULL) if (particle->deco != NULL)
particle->deco->destroy(particle->deco); particle->deco->destroy(particle->deco);
font_destroy(particle->font); fcft_destroy(particle->font);
free(particle->on_click_template); free(particle->on_click_template);
free(particle); free(particle);
} }
@ -29,7 +29,7 @@ particle_default_destroy(struct particle *particle)
struct particle * struct particle *
particle_common_new(int left_margin, int right_margin, particle_common_new(int left_margin, int right_margin,
const char *on_click_template, const char *on_click_template,
struct font *font, pixman_color_t foreground, struct fcft_font *font, pixman_color_t foreground,
struct deco *deco) struct deco *deco)
{ {
struct particle *p = calloc(1, sizeof(*p)); struct particle *p = calloc(1, sizeof(*p));

View file

@ -16,7 +16,7 @@ struct particle {
char *on_click_template; char *on_click_template;
pixman_color_t foreground; pixman_color_t foreground;
struct font *font; struct fcft_font *font;
struct deco *deco; struct deco *deco;
void (*destroy)(struct particle *particle); void (*destroy)(struct particle *particle);
@ -47,7 +47,7 @@ struct exposable {
struct particle *particle_common_new( struct particle *particle_common_new(
int left_margin, int right_margin, const char *on_click_template, 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); void particle_default_destroy(struct particle *particle);

View file

@ -19,7 +19,7 @@ struct eprivate {
/* Set when instantiating */ /* Set when instantiating */
char *text; char *text;
const struct glyph **glyphs; const struct fcft_glyph **glyphs;
long *kern_x; long *kern_x;
int num_glyphs; int num_glyphs;
}; };
@ -40,7 +40,7 @@ static int
begin_expose(struct exposable *exposable) begin_expose(struct exposable *exposable)
{ {
struct eprivate *e = exposable->private; struct eprivate *e = exposable->private;
struct font *font = exposable->particle->font; struct fcft_font *font = exposable->particle->font;
e->glyphs = NULL; e->glyphs = NULL;
e->num_glyphs = 0; e->num_glyphs = 0;
@ -55,15 +55,18 @@ begin_expose(struct exposable *exposable)
/* Convert text to glyph masks/images. */ /* Convert text to glyph masks/images. */
for (size_t i = 0; i < chars; i++) { 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) if (glyph == NULL)
continue; continue;
e->glyphs[e->num_glyphs++] = glyph; e->glyphs[e->num_glyphs++] = glyph;
if (i == 0) if (i == 0)
continue; 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); exposable_render_deco(exposable, pix, x, y, height);
const struct eprivate *e = exposable->private; 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) if (e->num_glyphs == 0)
return; 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 */ /* Loop glyphs and render them, one by one */
for (int i = 0; i < e->num_glyphs; i++) { 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); assert(glyph != NULL);
x += e->kern_x[i]; x += e->kern_x[i];