]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Disable pango glyph position rounding
authorJohan Malm <jgm323@gmail.com>
Sun, 14 Jul 2024 07:55:30 +0000 (08:55 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Fri, 19 Jul 2024 21:17:42 +0000 (22:17 +0100)
Chase https://github.com/swaywm/sway/commit/8c5b23e592d2334b3324227dd9d1311e46c5fd69

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.

src/common/font.c
src/osd.c
src/workspaces.c

index c9e6166c6a905ea6d4484022055e3149a8e0e25a..6e12e78012f70dfe845e4987a6afb9fa9cd23b52 100644 (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);
index 9555d913239be4f1c531e5a3d6f7a8ef60c0c796..91dbd27006ab7e65c14df9ac079307f74192a45a 100644 (file)
--- a/src/osd.c
+++ b/src/osd.c
@@ -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);
index 0fcef01a4f62de78e3551ad8fb26d8a473a7e32c..76dc93d643fbeb2a36031d9404ab0b3b8f279c20 100644 (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 */