Disable pango glyph position rounding

Chase 8c5b23e592

Pango rounds glyph position and widths to nearest integer, which leads to
font dimensions jumping around when rendering with a scale, causing text
geometry to jump around when changing scale.

Disable this rounding to make the geometry stable.
This commit is contained in:
Johan Malm 2024-07-14 08:55:30 +01:00 committed by Johan Malm
parent c20c3991c7
commit c3ea956837
3 changed files with 4 additions and 0 deletions

View file

@ -40,6 +40,7 @@ font_extents(struct font *font, const char *string)
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1);
c = cairo_create(surface);
layout = pango_cairo_create_layout(c);
pango_context_set_round_glyph_positions(pango_layout_get_context(layout), false);
PangoFontDescription *desc = font_to_pango_desc(font);
pango_layout_set_font_description(layout, desc);
@ -137,6 +138,7 @@ font_buffer_create(struct lab_data_buffer **buffer, int max_width,
cairo_move_to(cairo, 0, 0);
PangoLayout *layout = pango_cairo_create_layout(cairo);
pango_context_set_round_glyph_positions(pango_layout_get_context(layout), false);
pango_layout_set_width(layout, text_extents.width * PANGO_SCALE);
pango_layout_set_text(layout, text, -1);
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);

View file

@ -225,6 +225,7 @@ render_osd(struct server *server, cairo_t *cairo, int w, int h,
/* Set up text rendering */
set_cairo_color(cairo, theme->osd_label_text_color);
PangoLayout *layout = pango_cairo_create_layout(cairo);
pango_context_set_round_glyph_positions(pango_layout_get_context(layout), false);
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
PangoFontDescription *desc = font_to_pango_desc(&rc.font_osd);

View file

@ -124,6 +124,7 @@ _osd_update(struct server *server)
/* Text */
set_cairo_color(cairo, server->theme->osd_label_text_color);
PangoLayout *layout = pango_cairo_create_layout(cairo);
pango_context_set_round_glyph_positions(pango_layout_get_context(layout), false);
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
/* Center workspace indicator on the x axis */