Commit a759d44f authored by Dom Lachowicz's avatar Dom Lachowicz Committed by Dom Lachowicz

Basic support for SVG 1.1's text-rendering and shape-rendering properties

2007-08-20  Dom Lachowicz <domlachowicz@gmail.com>

        * rsvg-styles.c: Basic support for SVG 1.1's text-rendering and shape-rendering properties (#464599)
        http://www.w3.org/TR/SVG/painting.html#ShapeRenderingProperty
        * rsvg-styles.h: Ditto
        * rsvg-cairo-draw.c: Ditto

svn path=/trunk/; revision=1131
parent 731dc4d5
2007-08-20 Dom Lachowicz <domlachowicz@gmail.com>
* rsvg-styles.c: Basic support for SVG 1.1's text-rendering and shape-rendering properties (#464599)
http://www.w3.org/TR/SVG/painting.html#ShapeRenderingProperty
* rsvg-styles.h: Ditto
* rsvg-cairo-draw.c: Ditto
2007-07-24 Dom Lachowicz <domlachowicz@gmail.com>
* configure.in: Bump version to 2.18.0
......
......@@ -41,6 +41,32 @@
#include <pango/pangocairo.h>
static void
_rsvg_cairo_set_shape_antialias (cairo_t * cr, ShapeRenderingProperty aa)
{
if (SHAPE_RENDERING_AUTO == aa)
cairo_set_antialias (cr, CAIRO_ANTIALIAS_DEFAULT);
else if (SHAPE_RENDERING_OPTIMIZE_SPEED == aa)
cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
else if (SHAPE_RENDERING_CRISP_EDGES == aa)
cairo_set_antialias (cr, CAIRO_ANTIALIAS_DEFAULT);
else if (SHAPE_RENDERING_GEOMETRIC_PRECISION == aa)
cairo_set_antialias (cr, CAIRO_ANTIALIAS_DEFAULT);
}
static void
_rsvg_cairo_set_text_antialias (cairo_t * cr, TextRenderingProperty aa)
{
if (TEXT_RENDERING_AUTO == aa)
cairo_set_antialias (cr, CAIRO_ANTIALIAS_DEFAULT);
else if (TEXT_RENDERING_OPTIMIZE_SPEED == aa)
cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
else if (TEXT_RENDERING_OPTIMIZE_LEGIBILITY == aa)
cairo_set_antialias (cr, CAIRO_ANTIALIAS_DEFAULT);
else if (TEXT_RENDERING_GEOMETRIC_PRECISION == aa)
cairo_set_antialias (cr, CAIRO_ANTIALIAS_DEFAULT);
}
static void
_rsvg_cairo_set_operator (cairo_t * cr, RsvgCompOpType comp_op)
{
......@@ -446,6 +472,9 @@ rsvg_cairo_render_pango_layout (RsvgDrawingCtx * ctx, PangoLayout * layout, doub
RsvgBbox bbox;
cairo_save (render->cr);
_rsvg_cairo_set_text_antialias (render->cr, state->text_rendering_type);
_set_rsvg_affine (render->cr, state->affine);
cairo_set_line_width (render->cr, _rsvg_css_normalize_length (&state->stroke_width, ctx, 'h'));
......@@ -513,6 +542,8 @@ rsvg_cairo_render_path (RsvgDrawingCtx * ctx, const RsvgBpathDef * bpath_def)
cairo_save (cr);
_rsvg_cairo_set_shape_antialias (cr, state->shape_rendering_type);
_set_rsvg_affine (cr, state->affine);
cairo_set_line_width (cr, _rsvg_css_normalize_length (&state->stroke_width, ctx, 'h'));
......@@ -710,7 +741,7 @@ rsvg_cairo_render_image (RsvgDrawingCtx * ctx, const GdkPixbuf * pixbuf,
_rsvg_cairo_set_operator (render->cr, state->comp_op);
#if 0
#if 1
cairo_set_source_surface (render->cr, surface, pixbuf_x, pixbuf_y);
#else
{
......
......@@ -126,6 +126,11 @@ rsvg_state_init (RsvgState * state)
state->has_middleMarker = FALSE;
state->has_endMarker = FALSE;
state->has_overflow = FALSE;
state->shape_rendering_type = SHAPE_RENDERING_AUTO;
state->has_shape_rendering_type = FALSE;
state->text_rendering_type = TEXT_RENDERING_AUTO;
state->has_text_rendering_type = FALSE;
}
typedef int (*InheritanceFunction) (int dst, int src);
......@@ -231,6 +236,10 @@ rsvg_state_inherit_run (RsvgState * dst, const RsvgState * src,
dst->middleMarker = src->middleMarker;
if (function (dst->has_endMarker, src->has_endMarker))
dst->endMarker = src->endMarker;
if (function (dst->has_shape_rendering_type, src->has_shape_rendering_type))
dst->shape_rendering_type = src->shape_rendering_type;
if (function (dst->has_text_rendering_type, src->has_text_rendering_type))
dst->text_rendering_type = src->text_rendering_type;
if (function (dst->has_font_family, src->has_font_family)) {
g_free (dst->font_family); /* font_family is always set to something */
......@@ -645,6 +654,30 @@ rsvg_parse_style_arg (RsvgHandle * ctx, RsvgState * state, const char *str)
state->dash.offset = _rsvg_css_parse_length (str + arg_off);
if (state->dash.offset.length < 0.)
state->dash.offset.length = 0.;
} else if (rsvg_css_param_match (str, "shape-rendering")) {
state->has_shape_rendering_type = TRUE;
if (!strcmp (str + arg_off, "auto") || !strcmp (str + arg_off, "default"))
state->shape_rendering_type = SHAPE_RENDERING_AUTO;
else if (!strcmp (str + arg_off, "optimizeSpeed"))
state->shape_rendering_type = SHAPE_RENDERING_OPTIMIZE_SPEED;
else if (!strcmp (str + arg_off, "crispEdges"))
state->shape_rendering_type = SHAPE_RENDERING_CRISP_EDGES;
else if (!strcmp (str + arg_off, "geometricPrecision"))
state->shape_rendering_type = SHAPE_RENDERING_GEOMETRIC_PRECISION;
} else if (rsvg_css_param_match (str, "text-rendering")) {
state->has_text_rendering_type = TRUE;
if (!strcmp (str + arg_off, "auto" || !strcmp (str + arg_off, "default")))
state->text_rendering_type = TEXT_RENDERING_AUTO;
else if (!strcmp (str + arg_off, "optimizeSpeed"))
state->text_rendering_type = TEXT_RENDERING_OPTIMIZE_SPEED;
else if (!strcmp (str + arg_off, "optimizeLegibility"))
state->text_rendering_type = TEXT_RENDERING_OPTIMIZE_LEGIBILITY;
else if (!strcmp (str + arg_off, "geometricPrecision"))
state->text_rendering_type = TEXT_RENDERING_GEOMETRIC_PRECISION;
} else if (rsvg_css_param_match (str, "stroke-dasharray")) {
state->has_dash = TRUE;
if (!strcmp (str + arg_off, "none")) {
......
......@@ -60,6 +60,20 @@ typedef enum {
UNICODE_BIDI_OVERRIDE = 2
} UnicodeBidi;
typedef enum {
SHAPE_RENDERING_AUTO = 0,
SHAPE_RENDERING_OPTIMIZE_SPEED,
SHAPE_RENDERING_CRISP_EDGES,
SHAPE_RENDERING_GEOMETRIC_PRECISION
} ShapeRenderingProperty;
typedef enum {
TEXT_RENDERING_AUTO = 0,
TEXT_RENDERING_OPTIMIZE_SPEED,
TEXT_RENDERING_OPTIMIZE_LEGIBILITY,
TEXT_RENDERING_GEOMETRIC_PRECISION
} TextRenderingProperty;
typedef enum {
RSVG_COMP_OP_CLEAR,
RSVG_COMP_OP_SRC,
......@@ -211,6 +225,12 @@ struct _RsvgState {
RsvgCompOpType comp_op;
RsvgEnableBackgroundType enable_background;
ShapeRenderingProperty shape_rendering_type;
gboolean has_shape_rendering_type;
TextRenderingProperty text_rendering_type;
gboolean has_text_rendering_type;
};
RsvgState *rsvg_state_new ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment