diff options
author | 2024-07-11 00:33:19 +0200 | |
---|---|---|
committer | 2024-07-10 18:49:42 -0400 | |
commit | 8c5b23e592d2334b3324227dd9d1311e46c5fd69 (patch) | |
tree | b660ca9f5e6bc83c27265f28b5e7ec6ba5a983c8 | |
parent | xdg-activation: launcher tokens are activation requests (diff) | |
download | sway-8c5b23e592d2334b3324227dd9d1311e46c5fd69.tar.gz sway-8c5b23e592d2334b3324227dd9d1311e46c5fd69.tar.zst sway-8c5b23e592d2334b3324227dd9d1311e46c5fd69.zip |
common/pango: Disable glyph position rounding
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. This is disturbing
when text buffers change scale, and also mean that the text geometry
calculations in sway_text_node are incorrect.
Disable this rounding to make the geometry stable.
-rw-r--r-- | common/pango.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/common/pango.c b/common/pango.c index 288569b3..e52b52b9 100644 --- a/common/pango.c +++ b/common/pango.c | |||
@@ -53,6 +53,8 @@ size_t escape_markup_text(const char *src, char *dest) { | |||
53 | PangoLayout *get_pango_layout(cairo_t *cairo, const PangoFontDescription *desc, | 53 | PangoLayout *get_pango_layout(cairo_t *cairo, const PangoFontDescription *desc, |
54 | const char *text, double scale, bool markup) { | 54 | const char *text, double scale, bool markup) { |
55 | PangoLayout *layout = pango_cairo_create_layout(cairo); | 55 | PangoLayout *layout = pango_cairo_create_layout(cairo); |
56 | pango_context_set_round_glyph_positions(pango_layout_get_context(layout), false); | ||
57 | |||
56 | PangoAttrList *attrs; | 58 | PangoAttrList *attrs; |
57 | if (markup) { | 59 | if (markup) { |
58 | char *buf; | 60 | char *buf; |
@@ -104,6 +106,7 @@ void get_text_size(cairo_t *cairo, const PangoFontDescription *desc, int *width, | |||
104 | void get_text_metrics(const PangoFontDescription *description, int *height, int *baseline) { | 106 | void get_text_metrics(const PangoFontDescription *description, int *height, int *baseline) { |
105 | cairo_t *cairo = cairo_create(NULL); | 107 | cairo_t *cairo = cairo_create(NULL); |
106 | PangoContext *pango = pango_cairo_create_context(cairo); | 108 | PangoContext *pango = pango_cairo_create_context(cairo); |
109 | pango_context_set_round_glyph_positions(pango, false); | ||
107 | // When passing NULL as a language, pango uses the current locale. | 110 | // When passing NULL as a language, pango uses the current locale. |
108 | PangoFontMetrics *metrics = pango_context_get_metrics(pango, description, NULL); | 111 | PangoFontMetrics *metrics = pango_context_get_metrics(pango, description, NULL); |
109 | 112 | ||