From 1ba79a159e1808630dcd2541fee4772e525725ed Mon Sep 17 00:00:00 2001 From: Geoff Greer Date: Thu, 20 Sep 2018 20:37:08 -0700 Subject: [PATCH] swaybar, swaylock, & tree/container: Set cairo font options to render text and lines with subpixel hinting (if available). --- main.c | 8 ++++++-- render.c | 7 +++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 668a874..c25c8ee 100644 --- a/main.c +++ b/main.c @@ -195,11 +195,15 @@ void damage_state(struct swaylock_state *state) { } } -static void handle_wl_output_geometry(void *data, struct wl_output *output, +static void handle_wl_output_geometry(void *data, struct wl_output *wl_output, int32_t x, int32_t y, int32_t width_mm, int32_t height_mm, int32_t subpixel, const char *make, const char *model, int32_t transform) { - // Who cares + struct swaylock_surface *surface = data; + surface->subpixel = subpixel; + if (surface->state->run_display) { + damage_surface(surface); + } } static void handle_wl_output_mode(void *data, struct wl_output *output, diff --git a/render.c b/render.c index 66c5596..fa8832b 100644 --- a/render.c +++ b/render.c @@ -39,6 +39,13 @@ void render_frame(struct swaylock_surface *surface) { } cairo_t *cairo = surface->current_buffer->cairo; + cairo_set_antialias(cairo, CAIRO_ANTIALIAS_BEST); + cairo_font_options_t *fo = cairo_font_options_create(); + cairo_font_options_set_hint_style(fo, CAIRO_HINT_STYLE_FULL); + cairo_font_options_set_antialias(fo, CAIRO_ANTIALIAS_SUBPIXEL); + cairo_font_options_set_subpixel_order(fo, to_cairo_subpixel_order(surface->subpixel)); + cairo_set_font_options(cairo, fo); + cairo_font_options_destroy(fo); cairo_identity_matrix(cairo); cairo_save(cairo);