diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-06-08 16:11:25 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-06-08 16:11:25 +0000 |
commit | 8ba28ca9e91d7f5b2253a2399543f12caf25baa9 (patch) | |
tree | 5687f422667b336b8f11ccd9cb22d9a725a64ede /pango | |
parent | a9d4536fc514f5ddf38c6f37ec5198ca26271adb (diff) | |
parent | dd867f41cc653411e716212867537e72107429a9 (diff) | |
download | pango-8ba28ca9e91d7f5b2253a2399543f12caf25baa9.tar.gz |
Merge branch 'fix-error-underline' into 'master'
renderer: Fix a division-by-zero
See merge request GNOME/pango!189
Diffstat (limited to 'pango')
-rw-r--r-- | pango/pango-renderer.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/pango/pango-renderer.c b/pango/pango-renderer.c index 539df34a..07f81a88 100644 --- a/pango/pango-renderer.c +++ b/pango/pango-renderer.c @@ -1096,15 +1096,22 @@ pango_renderer_default_draw_error_underline (PangoRenderer *renderer, int width, int height) { - int square = height / HEIGHT_SQUARES; - int unit_width = (HEIGHT_SQUARES - 1) * square; - int width_units = (width + unit_width / 2) / unit_width; + int square; + int unit_width; + int width_units; const PangoMatrix identity = PANGO_MATRIX_INIT; const PangoMatrix *matrix; double dx, dx0, dy0; PangoMatrix total; int i; + if (width <= 0 || height <= 0) + return; + + square = height / HEIGHT_SQUARES; + unit_width = (HEIGHT_SQUARES - 1) * square; + width_units = (width + unit_width / 2) / unit_width; + x += (width - width_units * unit_width) / 2; if (renderer->matrix) |