Skip to content

Commit

Permalink
Enable pango font fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
bynect committed Oct 26, 2023
1 parent 19865c0 commit b0e2292
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ void draw_setup(void)

win = out->win_create();

LOG_D("Trying to load font: '%s'", settings.font);
pango_fdesc = pango_font_description_from_string(settings.font);
LOG_D("Loaded closest matching font: '%s'", pango_font_description_get_family(pango_fdesc));

if (settings.enable_recursive_icon_lookup)
load_icon_themes();
Expand Down Expand Up @@ -387,12 +389,14 @@ static struct colored_layout *layout_from_notification(cairo_t *c, struct notifi

if (!err) {
pango_layout_set_text(cl->l, cl->text, -1);
pango_attr_list_insert(cl->attr, pango_attr_fallback_new(true));
pango_layout_set_attributes(cl->l, cl->attr);
} else {
/* remove markup and display plain message instead */
n->text_to_render = markup_strip(n->text_to_render);
cl->text = NULL;
cl->attr = NULL;
cl->attr = pango_attr_list_new();
pango_attr_list_insert(cl->attr, pango_attr_fallback_new(true));
pango_layout_set_text(cl->l, n->text_to_render, -1);
if (n->first_render) {
LOG_W("Unable to parse markup: %s", err->message);
Expand Down Expand Up @@ -745,16 +749,16 @@ static void render_content(cairo_t *c, struct colored_layout *cl, int width, dou

/* Draw progress bar
* TODO: Modify draw_rounded_rect to fix blurry lines due to fractional scaling
* Note: the bar could be drawn a bit smaller, because the frame is drawn on top
* Note: the bar could be drawn a bit smaller, because the frame is drawn on top
*/
// left side (fill)
cairo_set_source_rgba(c, cl->highlight.r, cl->highlight.g, cl->highlight.b, cl->highlight.a);
draw_rounded_rect(c, x_bar_1, frame_y, progress_width_1, progress_height,
draw_rounded_rect(c, x_bar_1, frame_y, progress_width_1, progress_height,
settings.progress_bar_corner_radius, scale, true, true);
cairo_fill(c);
// right side (background)
cairo_set_source_rgba(c, cl->bg.r, cl->bg.g, cl->bg.b, cl->bg.a);
draw_rounded_rect(c, x_bar_2, frame_y, progress_width_2, progress_height,
draw_rounded_rect(c, x_bar_2, frame_y, progress_width_2, progress_height,
settings.progress_bar_corner_radius, scale, true, true);

cairo_fill(c);
Expand Down

0 comments on commit b0e2292

Please sign in to comment.