swaybar, swaylock, & tree/container: Set cairo font options to render text and lines with subpixel hinting (if available).

This commit is contained in:
Geoff Greer 2018-09-20 20:37:08 -07:00
parent eae42606e2
commit c495164f60
9 changed files with 53 additions and 5 deletions

View file

@ -319,10 +319,14 @@ static bool bar_uses_output(struct swaybar *bar, const char *name) {
return false;
}
static void output_geometry(void *data, struct wl_output *output, int32_t x,
static void 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 swaybar_output *output = data;
output->subpixel = subpixel;
if (output->surface) {
render_frame(output->bar, output);
}
}
static void output_mode(void *data, struct wl_output *output, uint32_t flags,

View file

@ -495,6 +495,13 @@ void render_frame(struct swaybar *bar, struct swaybar_output *output) {
cairo_surface_t *recorder = cairo_recording_surface_create(
CAIRO_CONTENT_COLOR_ALPHA, NULL);
cairo_t *cairo = cairo_create(recorder);
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(output->subpixel));
cairo_set_font_options(cairo, fo);
cairo_font_options_destroy(fo);
cairo_save(cairo);
cairo_set_operator(cairo, CAIRO_OPERATOR_CLEAR);
cairo_paint(cairo);