summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2006-12-04 20:08:25 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2006-12-04 20:08:25 +0000
commitbbdae5e20e4592ea21b267e59571d1b2da486dd3 (patch)
treed31bc1300b8340f58b513a418dece38c0774b7d7
parent9e4393bf2a898a956e17449a53cd7b3849d46680 (diff)
downloadpango-bbdae5e20e4592ea21b267e59571d1b2da486dd3.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--ChangeLog18
-rw-r--r--pango/pangocairo-render.c75
2 files changed, 72 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index 3324448d..de2726be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
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>
+
+ * pango/pangocairo-render.c (_pango_cairo_renderer_draw_frame),
+ (_pango_cairo_renderer_draw_box_glyph),
+ (_pango_cairo_renderer_draw_unknown_glyph):
+
+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 45ff427e..e936f13a 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;