Index: image/svg.c =================================================================== --- image/svg.c (revision 4221) +++ image/svg.c (working copy) @@ -103,13 +103,15 @@ transform[4] = x; transform[5] = y; +#define BGR(c) ((c) == svgtiny_TRANSPARENT ? svgtiny_TRANSPARENT : ((svgtiny_RED((c))) | (svgtiny_GREEN((c)) << 8) | (svgtiny_BLUE((c)) << 16))) + for (unsigned int i = 0; i != diagram->shape_count; i++) { if (diagram->shape[i].path) { ok = plot.path(diagram->shape[i].path, diagram->shape[i].path_length, - diagram->shape[i].fill, + BGR(diagram->shape[i].fill), diagram->shape[i].stroke_width, - diagram->shape[i].stroke, + BGR(diagram->shape[i].stroke), transform); if (!ok) return false; @@ -129,6 +131,8 @@ } } +#undef BGR + return true; } Index: gtk/gtk_plotters.c =================================================================== --- gtk/gtk_plotters.c (revision 4221) +++ gtk/gtk_plotters.c (working copy) @@ -380,11 +380,88 @@ bool nsgtk_plot_path(float *p, unsigned int n, colour fill, float width, colour c, float *transform) { - /* Only the internal SVG renderer uses this plot call currently, - * and the GTK version uses librsvg. Thus, we ignore this complexity, - * and just return true obliviously. - */ + unsigned int i; + if (n == 0) + return true; + + if (p[0] != PLOTTER_PATH_MOVE) { + LOG(("Path does not start with move")); + return false; + } + +#ifdef CAIRO_VERSION + if (option_render_cairo) { + cairo_matrix_t old_ctm, n_ctm; + + /* Save CTM */ + cairo_get_matrix(current_cr, &old_ctm); + + /* Set up line style and width */ + cairo_set_line_width(current_cr, 1); + nsgtk_set_solid(); + + /* Load new CTM */ + n_ctm.xx = transform[0]; + n_ctm.yx = transform[1]; + n_ctm.xy = transform[2]; + n_ctm.yy = transform[3]; + n_ctm.x0 = transform[4]; + n_ctm.y0 = transform[5]; + + cairo_set_matrix(current_cr, &n_ctm); + + /* Construct path */ + for (i = 0; i < n; ) { + if (p[i] == PLOTTER_PATH_MOVE) { + cairo_move_to(current_cr, p[i+1], p[i+2]); + i += 3; + } else if (p[i] == PLOTTER_PATH_CLOSE) { + cairo_close_path(current_cr); + i++; + } else if (p[i] == PLOTTER_PATH_LINE) { + cairo_line_to(current_cr, p[i+1], p[i+2]); + i += 3; + } else if (p[i] == PLOTTER_PATH_BEZIER) { + cairo_curve_to(current_cr, p[i+1], p[i+2], + p[i+3], p[i+4], + p[i+5], p[i+6]); + i += 7; + } else { + LOG(("bad path command %f", p[i])); + /* Reset matrix for safety */ + cairo_set_matrix(current_cr, &old_ctm); + return false; + } + } + + /* Restore original CTM */ + cairo_set_matrix(current_cr, &old_ctm); + + /* Now draw path */ + if (fill != TRANSPARENT) { + nsgtk_set_colour(fill); + + if (c != TRANSPARENT) { + /* Fill & Stroke */ + cairo_fill_preserve(current_cr); + nsgtk_set_colour(c); + cairo_stroke(current_cr); + } else { + /* Fill only */ + cairo_fill(current_cr); + } + } else if (c != TRANSPARENT) { + /* Stroke only */ + nsgtk_set_colour(c); + cairo_stroke(current_cr); + } + } else +#endif + { + /** \todo Make a decision about vanilla gdk -- its API fails */ + } + return true; }