Merge branch 'fcft-2'

This commit is contained in:
Daniel Eklöf 2020-04-24 20:22:12 +02:00
commit 6de185c242
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
8 changed files with 32 additions and 29 deletions

View file

@ -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=()

View file

@ -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() {

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)
{
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;
}

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);
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;
};

View file

@ -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',
@ -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: ['>=1.1.0', '<1.2.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'] +

View file

@ -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));

View file

@ -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);

View file

@ -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_rasterize(
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);
}
}
@ -72,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;
}
@ -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];
@ -132,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;
}
}