From 0a89d471d5b4172e8dd7ff43c92af600b6f1342f Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Wed, 24 Aug 2005 18:48:11 +0000 Subject: convert from Pango units to doubles, fix some coordinate space problems 2005-08-24 Owen Taylor * pango/pangocairo-render.c (draw_error_underline): convert from Pango units to doubles, fix some coordinate space problems that had previously been fixed in GTK+. (#313015, Luis Villa) --- ChangeLog | 4 +++ pango/pangocairo-render.c | 77 +++++++++++++++++++++++++++-------------------- 2 files changed, 48 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8b137891..cfdee6f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1 +1,5 @@ +2005-08-24 Owen Taylor + * pango/pangocairo-render.c (draw_error_underline): convert + from Pango units to doubles, fix some coordinate space problems + that had previously been fixed in GTK+. (#313015, Luis Villa) diff --git a/pango/pangocairo-render.c b/pango/pangocairo-render.c index 68ae4981..59121f11 100644 --- a/pango/pangocairo-render.c +++ b/pango/pangocairo-render.c @@ -166,52 +166,41 @@ pango_cairo_renderer_draw_rectangle (PangoRenderer *renderer, */ #define HEIGHT_SQUARES 2.5 +/* This code is cut-and-pasted between here and gtk+/gdk/gdkpango.c */ static void -pango_cairo_renderer_draw_error_underline (PangoRenderer *renderer, - int x, - int y, - int width, - int height) +draw_error_underline (cairo_t *cr, + double x, + double y, + double width, + double height) { - PangoCairoRenderer *crenderer = PANGO_CAIRO_RENDERER (renderer); - cairo_t *cr = crenderer->cr; - double square = height / HEIGHT_SQUARES; double unit_width = (HEIGHT_SQUARES - 1) * square; int width_units = (width + unit_width / 2) / unit_width; double y_top, y_bottom; int i; - if (!crenderer->do_path) - { - cairo_save (cr); - - set_color (crenderer, PANGO_RENDER_PART_UNDERLINE); - - cairo_new_path (cr); - } - x += (width - width_units * unit_width); width = width_units * unit_width; - y_top = y + height; - y_bottom = y; + y_top = y; + y_bottom = y + height; /* Bottom of squiggle */ - cairo_move_to (cr, x - square / 2, y_top - square / 2); /* A */ + cairo_move_to (cr, x - square / 2, y_top + square / 2); /* A */ for (i = 0; i < width_units; i += 2) { double x_middle = x + (i + 1) * unit_width; double x_right = x + (i + 2) * unit_width; - + cairo_line_to (cr, x_middle, y_bottom); /* B */ if (i + 1 == width_units) /* Nothing */; else if (i + 2 == width_units) - cairo_line_to (cr, x_right + square / 2, y_top - square / 2); /* D */ + cairo_line_to (cr, x_right + square / 2, y_top + square / 2); /* D */ else - cairo_line_to (cr, x_right, y_top - square); /* C */ + cairo_line_to (cr, x_right, y_top + square); /* C */ } /* Top of squiggle */ @@ -222,18 +211,40 @@ pango_cairo_renderer_draw_error_underline (PangoRenderer *renderer, double x_right = x + (i + 2) * unit_width; if (i + 1 == width_units) - cairo_line_to (cr, x_middle + square / 2, y_bottom + square / 2); /* G */ - else - { - if (i + 2 == width_units) - cairo_line_to (cr, x_right, y_top); /* E */ - cairo_line_to (cr, x_middle, y_bottom + square); /* F */ - } - + cairo_line_to (cr, x_middle + square / 2, y_bottom - square / 2); /* G */ + else { + if (i + 2 == width_units) + cairo_line_to (cr, x_right, y_top); /* E */ + cairo_line_to (cr, x_middle, y_bottom - square); /* F */ + } + cairo_line_to (cr, x_left, y_top); /* H */ } - - cairo_close_path (cr); +} + +static void +pango_cairo_renderer_draw_error_underline (PangoRenderer *renderer, + int x, + int y, + int width, + int height) +{ + PangoCairoRenderer *crenderer = PANGO_CAIRO_RENDERER (renderer); + cairo_t *cr = crenderer->cr; + + if (!crenderer->do_path) + { + cairo_save (cr); + + set_color (crenderer, PANGO_RENDER_PART_UNDERLINE); + + cairo_new_path (cr); + } + + draw_error_underline (cr, + crenderer->x_offset + (double)x / PANGO_SCALE, + crenderer->y_offset + (double)y / PANGO_SCALE, + (double)width / PANGO_SCALE, (double)height / PANGO_SCALE); if (!crenderer->do_path) { -- cgit v1.2.1