diff options
author | Dom Lachowicz <cinamod@hotmail.com> | 2006-08-22 13:04:09 +0000 |
---|---|---|
committer | Dom Lachowicz <doml@src.gnome.org> | 2006-08-22 13:04:09 +0000 |
commit | 2c51aa877d68813a3495222c5cfdc4e8ba7ce536 (patch) | |
tree | 14495ea3df7e12fbc797cfcb5ab673715fe57ebc /rsvg-cairo-draw.c | |
parent | 678517bbbd5661baff116ff1a49c1746bfd5b7f4 (diff) | |
download | librsvg-2c51aa877d68813a3495222c5cfdc4e8ba7ce536.tar.gz |
Committed patch from Kouhei Sutou <kou@cozmixng.org> that makes librsvg
2006-08-22 Dom Lachowicz <cinamod@hotmail.com>
* Bug 344116: Committed patch from Kouhei Sutou <kou@cozmixng.org>
that makes librsvg use Pango-Cairo instead of PangoFT2+rendering
text as a path. This patch is disabled for now, as it crashes on
at least 5 known SVGs (see bug 344116)
Diffstat (limited to 'rsvg-cairo-draw.c')
-rw-r--r-- | rsvg-cairo-draw.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/rsvg-cairo-draw.c b/rsvg-cairo-draw.c index 156f4bcd..0ed4c99c 100644 --- a/rsvg-cairo-draw.c +++ b/rsvg-cairo-draw.c @@ -39,6 +39,8 @@ #include <math.h> #include <string.h> +#include <pango/pangocairo.h> + static void rsvg_pixmap_destroy (gchar *pixels, gpointer data) { @@ -396,6 +398,77 @@ _set_rsvg_affine (cairo_t *cr, const double affine[6]) cairo_transform (cr, &matrix); } +PangoContext * +rsvg_cairo_create_pango_context (RsvgDrawingCtx *ctx) +{ + PangoFontMap *fontmap; + PangoContext *context; + + fontmap = pango_cairo_font_map_get_default (); + context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (fontmap)); + pango_cairo_context_set_resolution (context, ctx->dpi_y); + return context; +} + +void +rsvg_cairo_render_pango_layout (RsvgDrawingCtx *ctx, + PangoLayout *layout, + double x, double y) +{ + RsvgCairoRender *render = (RsvgCairoRender *)ctx->render; + RsvgState *state = rsvg_state_current(ctx); + PangoRectangle logical; + RsvgBbox bbox; + + cairo_save (render->cr); + _set_rsvg_affine (render->cr, state->affine); + cairo_set_line_width (render->cr, + _rsvg_css_normalize_length(&state->stroke_width, + ctx, 'h')); + + pango_cairo_update_layout (render->cr, layout); + + pango_layout_get_pixel_extents(layout, NULL, &logical); + + rsvg_bbox_init(&bbox, state->affine); + bbox.x = x; + bbox.y = y; + bbox.w = logical.width; + bbox.h = logical.height; + bbox.virgin = 0; + + cairo_translate (render->cr, x, y); + + rsvg_bbox_insert(&render->bbox, &bbox); + + if (state->fill) + { + _set_source_rsvg_paint_server (ctx, + state->current_color, + state->fill, + state->fill_opacity, + bbox, + rsvg_state_current(ctx)->current_color); + + pango_cairo_show_layout (render->cr, layout); + } + + if (state->stroke) + { + pango_cairo_layout_path (render->cr, layout); + + _set_source_rsvg_paint_server (ctx, + state->current_color, + state->stroke, + state->stroke_opacity, + bbox, + rsvg_state_current(ctx)->current_color); + cairo_stroke (render->cr); + } + + cairo_restore (render->cr); +} + void rsvg_cairo_render_path (RsvgDrawingCtx *ctx, const RsvgBpathDef *bpath_def) { |