summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2006-12-04 20:07:41 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2006-12-04 20:07:41 +0000
commit534267ee360b18a4999ee3b1af3dfa0c193f3cd9 (patch)
tree2b3246fc182d9808d853873fca432638681915ee
parent50b258082b18aefcf09d7ce6bade4deb081e7f52 (diff)
downloadpango-534267ee360b18a4999ee3b1af3dfa0c193f3cd9.tar.gz
Fix handling of boxes drawn in do_path mode. Previously we were doing one
2006-12-04 Behdad Esfahbod <behdad@gnome.org> * pango/pangocairo-render.c (_pango_cairo_renderer_draw_frame), (_pango_cairo_renderer_draw_box_glyph), (_pango_cairo_renderer_draw_unknown_glyph): Fix handling of boxes drawn in do_path mode. Previously we were doing one rectangle and stroke it if in show mode, and leave it alone if in path mode. That doesn't really work. Now we do two rectangles, for the outer and inner rects of the box border, but with different orientations, such that pango_cairo_layout_path(); cairo_fill(); works for hexboxes now.
-rw-r--r--ChangeLog12
-rw-r--r--pango/pangocairo-render.c75
2 files changed, 66 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index 31277ad6..7303cfc4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2006-12-04 Behdad Esfahbod <behdad@gnome.org>
+ * pango/pangocairo-render.c (_pango_cairo_renderer_draw_frame),
+ (_pango_cairo_renderer_draw_box_glyph),
+ (_pango_cairo_renderer_draw_unknown_glyph):
+ Fix handling of boxes drawn in do_path mode. Previously we were
+ doing one rectangle and stroke it if in show mode, and leave it alone
+ if in path mode. That doesn't really work. Now we do two rectangles,
+ for the outer and inner rects of the box border, but with different
+ orientations, such that pango_cairo_layout_path(); cairo_fill(); works
+ for hexboxes now.
+
+2006-12-04 Behdad Esfahbod <behdad@gnome.org>
+
Red Hat Bug 211964: [ta] Rendering issue with Tamil
Patch from LingNing Zhang
diff --git a/pango/pangocairo-render.c b/pango/pangocairo-render.c
index dec4077c..da145400 100644
--- a/pango/pangocairo-render.c
+++ b/pango/pangocairo-render.c
@@ -58,6 +58,48 @@ set_color (PangoCairoRenderer *crenderer,
color->blue / 65535.);
}
+/* modifies cairo_set_line_width() without doing cairo_save/restore() */
+static void
+_pango_cairo_renderer_draw_frame (PangoCairoRenderer *crenderer,
+ double x,
+ double y,
+ double width,
+ double height,
+ double line_width)
+{
+ if (crenderer->do_path)
+ {
+ cairo_t *cr = crenderer->cr;
+ double d2 = line_width * .5, d = line_width;
+
+ /* we draw an outer box in one winding direction and an inner one in the
+ * opposite direction. This works for both cairo windings rules.
+ *
+ * what we really want is cairo_stroke_to_path().
+ */
+
+ /* outer */
+ cairo_move_to (cr, x - d2, y - d2);
+ cairo_rel_line_to (cr, width + d, 0);
+ cairo_rel_line_to (cr, 0, height + d);
+ cairo_rel_line_to (cr, - (width + d), 0);
+ cairo_close_path (cr);
+
+ /* inner */
+ cairo_move_to (cr, x + d2, y + d2);
+ cairo_rel_line_to (cr, 0, height - d);
+ cairo_rel_line_to (cr, width - d, 0);
+ cairo_rel_line_to (cr, 0, - (height - d));
+ cairo_close_path (cr);
+ }
+ else
+ {
+ cairo_rectangle (crenderer->cr, x, y, width, height);
+ cairo_set_line_width (crenderer->cr, line_width);
+ cairo_stroke (crenderer->cr);
+ }
+}
+
static void
_pango_cairo_renderer_draw_box_glyph (PangoCairoRenderer *crenderer,
PangoGlyphInfo *gi,
@@ -69,17 +111,13 @@ _pango_cairo_renderer_draw_box_glyph (PangoCairoRenderer *crenderer,
cairo_save (crenderer->cr);
cairo_get_current_point (crenderer->cr, &temp_x, &temp_y);
- cairo_rectangle (crenderer->cr,
- cx + 1.5,
- cy + 1.5 - PANGO_UNKNOWN_GLYPH_HEIGHT,
- (double)gi->geometry.width / PANGO_SCALE - 3.0,
- PANGO_UNKNOWN_GLYPH_HEIGHT - 3.0);
- if (!crenderer->do_path)
- {
- cairo_set_line_width (crenderer->cr, 1.0);
- cairo_stroke (crenderer->cr);
- }
+ _pango_cairo_renderer_draw_frame (crenderer,
+ cx + 1.5,
+ cy + 1.5 - PANGO_UNKNOWN_GLYPH_HEIGHT,
+ (double)gi->geometry.width / PANGO_SCALE - 3.0,
+ PANGO_UNKNOWN_GLYPH_HEIGHT - 3.0,
+ 1.0);
cairo_move_to (crenderer->cr, temp_x, temp_y);
cairo_restore (crenderer->cr);
@@ -118,17 +156,12 @@ _pango_cairo_renderer_draw_unknown_glyph (PangoCairoRenderer *crenderer,
cols = (ch > 0xffff ? 6 : 4) / rows;
g_snprintf (buf, sizeof(buf), (ch > 0xffff) ? "%06X" : "%04X", ch);
- cairo_rectangle (crenderer->cr,
- cx + hbi->pad_x * 1.5,
- cy + hbi->box_descent - hbi->box_height + hbi->pad_y * 0.5,
- (double)gi->geometry.width / PANGO_SCALE - 3 * hbi->pad_x,
- (hbi->box_height - hbi->pad_y));
-
- if (!crenderer->do_path)
- {
- cairo_set_line_width (crenderer->cr, hbi->line_width);
- cairo_stroke (crenderer->cr);
- }
+ _pango_cairo_renderer_draw_frame (crenderer,
+ cx + hbi->pad_x * 1.5,
+ cy + hbi->box_descent - hbi->box_height + hbi->pad_y * 0.5,
+ (double)gi->geometry.width / PANGO_SCALE - 3 * hbi->pad_x,
+ (hbi->box_height - hbi->pad_y),
+ hbi->line_width);
x0 = cx + hbi->pad_x * 3.0;
y0 = cy + hbi->box_descent - hbi->pad_y * 2;