Commit 36b8cb26 authored by Caleb Michael Moore's avatar Caleb Michael Moore

huge structure change

parent 99fb4991
......@@ -39,6 +39,9 @@
#define MM_PER_INCH (25.4)
#define PICA_PER_INCH (6.0)
#define SETINHERIT {if (inherit != NULL) *inherit = 1;}
#define UNSETINHERIT {if (inherit != NULL) *inherit = 0;}
/**
* rsvg_css_parse_vbox
* @vbox: The CSS viewBox
......@@ -239,10 +242,10 @@ rsvg_css_color_compare (const void * a, const void * b)
* Parse a CSS2 color specifier, return RGB value
*/
guint32
rsvg_css_parse_color (const char *str, guint32 inherit)
rsvg_css_parse_color (const char *str, gboolean * inherit)
{
gint val = 0;
SETINHERIT
if (str[0] == '#')
{
int i;
......@@ -315,7 +318,7 @@ rsvg_css_parse_color (const char *str, guint32 inherit)
val = PACK_RGB (r,g,b);
}
else if (!strcmp (str, "inherit"))
val = inherit;
UNSETINHERIT
else
{
const static ColorPair color_list [] =
......@@ -592,8 +595,9 @@ rsvg_css_parse_time (const char * str)
}
PangoStyle
rsvg_css_parse_font_style (const char * str, PangoStyle inherit)
rsvg_css_parse_font_style (const char * str, gboolean * inherit)
{
SETINHERIT
if (str)
{
if (!strcmp(str, "oblique"))
......@@ -601,27 +605,35 @@ rsvg_css_parse_font_style (const char * str, PangoStyle inherit)
if (!strcmp(str, "italic"))
return PANGO_STYLE_ITALIC;
else if (!strcmp(str, "inherit"))
return inherit;
{
UNSETINHERIT
return PANGO_STYLE_NORMAL;
}
}
return PANGO_STYLE_NORMAL;
}
PangoVariant
rsvg_css_parse_font_variant (const char * str, PangoVariant inherit)
rsvg_css_parse_font_variant (const char * str, gboolean * inherit)
{
SETINHERIT
if (str)
{
if (!strcmp(str, "small-caps"))
return PANGO_VARIANT_SMALL_CAPS;
else if (!strcmp(str, "inherit"))
return inherit;
{
UNSETINHERIT
return PANGO_VARIANT_NORMAL;
}
}
return PANGO_VARIANT_NORMAL;
}
PangoWeight
rsvg_css_parse_font_weight (const char * str, PangoWeight inherit)
rsvg_css_parse_font_weight (const char * str, gboolean * inherit)
{
SETINHERIT
if (str)
{
if (!strcmp (str, "lighter"))
......@@ -649,15 +661,19 @@ rsvg_css_parse_font_weight (const char * str, PangoWeight inherit)
else if (!strcmp (str, "900"))
return (PangoWeight)900;
else if (!strcmp(str, "inherit"))
return inherit;
{
UNSETINHERIT
return PANGO_WEIGHT_NORMAL;
}
}
return PANGO_WEIGHT_NORMAL;
}
PangoStretch
rsvg_css_parse_font_stretch (const char * str, PangoStretch inherit)
rsvg_css_parse_font_stretch (const char * str, gboolean * inherit)
{
SETINHERIT
if (str)
{
if (!strcmp (str, "ultra-condensed"))
......@@ -677,18 +693,25 @@ rsvg_css_parse_font_stretch (const char * str, PangoStretch inherit)
else if (!strcmp (str, "ultra-expanded"))
return PANGO_STRETCH_ULTRA_EXPANDED;
else if (!strcmp(str, "inherit"))
return inherit;
{
inherit = 0;
return PANGO_STRETCH_NORMAL;
}
}
return PANGO_STRETCH_NORMAL;
}
const char *
rsvg_css_parse_font_family (const char * str, const char * inherit)
rsvg_css_parse_font_family (const char * str, gboolean * inherit)
{
SETINHERIT
if (!str)
return NULL;
else if (!strcmp (str, "inherit"))
return inherit;
{
UNSETINHERIT
return NULL;
}
else
return str;
}
......
......@@ -59,7 +59,7 @@ int
rsvg_css_param_arg_offset (const char *str);
guint32
rsvg_css_parse_color (const char *str, guint32 inherit);
rsvg_css_parse_color (const char *str, gboolean * inherit);
guint
rsvg_css_parse_opacity (const char *str);
......@@ -74,19 +74,19 @@ double
rsvg_css_parse_time (const char * str);
PangoStyle
rsvg_css_parse_font_style (const char * str, PangoStyle inherit);
rsvg_css_parse_font_style (const char * str, gboolean * inherit);
PangoVariant
rsvg_css_parse_font_variant (const char * str, PangoVariant inherit);
rsvg_css_parse_font_variant (const char * str, gboolean * inherit);
PangoWeight
rsvg_css_parse_font_weight (const char * str, PangoWeight inherit);
rsvg_css_parse_font_weight (const char * str, gboolean * inherit);
PangoStretch
rsvg_css_parse_font_stretch (const char * str, PangoStretch inherit);
rsvg_css_parse_font_stretch (const char * str, gboolean * inherit);
const char *
rsvg_css_parse_font_family (const char * str, const char * inherit);
rsvg_css_parse_font_family (const char * str, gboolean * inherit);
gboolean
rsvg_css_parse_vbox (const char * vbox, double * x, double * y,
......
......@@ -74,7 +74,7 @@ struct _RsvgFilterContext
RsvgFilterPrimitiveOutput lastresult;
double affine[6];
double paffine[6];
RsvgHandle * ctx;
DrawingCtx * ctx;
};
typedef struct _RsvgFilterPrimitive RsvgFilterPrimitive;
......@@ -400,7 +400,7 @@ rsvg_filter_free_pair (gpointer value)
**/
void
rsvg_filter_render (RsvgFilter * self, GdkPixbuf * source, GdkPixbuf * output,
GdkPixbuf * bg, RsvgHandle * context)
GdkPixbuf * bg, DrawingCtx * context)
{
RsvgFilterContext *ctx;
RsvgFilterPrimitive *current;
......@@ -745,7 +745,6 @@ rsvg_start_filter (RsvgHandle * ctx, RsvgPropertyBag * atts)
}
ctx->currentfilter = filter;
/* set up the defval stuff */
filter->super.type = RSVG_DEF_FILTER;
filter->super.free = &rsvg_filter_free;
......@@ -923,7 +922,7 @@ rsvg_filter_primitive_blend_render (RsvgFilterPrimitive * self,
g_object_unref (G_OBJECT (output));
}
void rsvg_filter_adobe_blend(gint modenum, GdkPixbuf *in, GdkPixbuf *bg, GdkPixbuf *output, RsvgHandle * ctx)
void rsvg_filter_adobe_blend(gint modenum, GdkPixbuf *in, GdkPixbuf *bg, GdkPixbuf *output, DrawingCtx * ctx)
{
FPBox boundarys;
RsvgFilterPrimitiveBlendMode mode;
......@@ -4027,7 +4026,7 @@ rsvg_filter_primitive_image_render_in (RsvgFilterPrimitive * self,
RsvgFilterContext * context)
{
FPBox boundarys;
RsvgHandle * ctx;
DrawingCtx * ctx;
RsvgFilterPrimitiveImage *oself;
int i;
RsvgDefVal * parent;
......
......@@ -43,7 +43,7 @@ struct _RsvgFilter {
};
void
rsvg_filter_render (RsvgFilter *self, GdkPixbuf *source, GdkPixbuf *output, GdkPixbuf *bg, RsvgHandle *context);
rsvg_filter_render (RsvgFilter *self, GdkPixbuf *source, GdkPixbuf *output, GdkPixbuf *bg, DrawingCtx *context);
void
rsvg_start_filter (RsvgHandle *ctx, RsvgPropertyBag *atts);
......@@ -118,7 +118,7 @@ rsvg_start_filter_primitive_tile (RsvgHandle * ctx, RsvgPropertyBag * atts);
void
rsvg_filter_adobe_blend(gint modenum, GdkPixbuf *in, GdkPixbuf *bg, GdkPixbuf *output,
RsvgHandle * ctx);
DrawingCtx * ctx);
void
rsvg_alpha_blt (GdkPixbuf * src, gint srcx, gint srcy, gint srcwidth,
......
......@@ -41,7 +41,7 @@ rsvg_mask_free (RsvgDefVal * self)
}
void
rsvg_mask_render (RsvgMask *self, GdkPixbuf *tos, GdkPixbuf *nos, RsvgHandle *ctx)
rsvg_mask_render (RsvgMask *self, GdkPixbuf *tos, GdkPixbuf *nos, DrawingCtx *ctx)
{
art_u8 *tos_pixels, *nos_pixels, *mask_pixels;
int width;
......@@ -124,7 +124,7 @@ rsvg_mask_render (RsvgMask *self, GdkPixbuf *tos, GdkPixbuf *nos, RsvgHandle *ct
}
static void
rsvg_defs_drawable_mask_draw (RsvgDefsDrawable * self, RsvgHandle *ctx,
rsvg_defs_drawable_mask_draw (RsvgDefsDrawable * self, DrawingCtx *ctx,
int dominate)
{
RsvgState *state = rsvg_state_current (ctx);
......@@ -225,13 +225,12 @@ rsvg_start_mask (RsvgHandle *ctx, RsvgPropertyBag *atts)
}
rsvg_parse_style_attrs (ctx, rsvg_state_current (ctx), "mask", klazz, id, atts);
rsvg_state_init(&mask->super.super.state);
rsvg_parse_style_attrs (ctx, &mask->super.super.state, "mask", klazz, id, atts);
mask->super.super.parent = (RsvgDefsDrawable *)ctx->current_defs_group;
ctx->current_defs_group = &mask->super;
rsvg_state_clone (&mask->super.super.state, rsvg_state_current (ctx));
/* set up the defval stuff */
mask->super.super.super.type = RSVG_DEF_MASK;
......@@ -291,7 +290,7 @@ rsvg_clip_path_free (RsvgDefVal * self)
}
ArtSVP *
rsvg_clip_path_render (RsvgClipPath * self, RsvgHandle *ctx)
rsvg_clip_path_render (RsvgClipPath * self, DrawingCtx *ctx)
{
RsvgState *state = rsvg_state_current (ctx);
RsvgDefsDrawableGroup *group = (RsvgDefsDrawableGroup*)self;
......@@ -376,9 +375,9 @@ rsvg_start_clip_path (RsvgHandle *ctx, RsvgPropertyBag *atts)
klazz = value;
}
rsvg_parse_style_attrs (ctx, rsvg_state_current (ctx), "clipPath", klazz, id, atts);
rsvg_state_init (&clip_path->super.super.state);
rsvg_state_clone (&clip_path->super.super.state, rsvg_state_current (ctx));
rsvg_parse_style_attrs (ctx, &clip_path->super.super.state, "clipPath", klazz, id, atts);
clip_path->super.super.parent = (RsvgDefsDrawable *)ctx->current_defs_group;
......@@ -431,7 +430,7 @@ rsvg_clip_path_parse (const RsvgDefs * defs, const char *str)
}
ArtSVP *
rsvg_rect_clip_path(double x, double y, double w, double h, RsvgHandle * ctx)
rsvg_rect_clip_path(double x, double y, double w, double h, DrawingCtx * ctx)
{
GString * d = NULL;
ArtSVP * output = NULL;
......
......@@ -46,7 +46,7 @@ struct _RsvgMask {
};
void
rsvg_mask_render (RsvgMask *self, GdkPixbuf *source, GdkPixbuf *output, RsvgHandle *ctx);
rsvg_mask_render (RsvgMask *self, GdkPixbuf *source, GdkPixbuf *output, DrawingCtx *ctx);
void
rsvg_start_mask (RsvgHandle *ctx, RsvgPropertyBag *atts);
......@@ -65,7 +65,7 @@ struct _RsvgClipPath {
};
ArtSVP *
rsvg_clip_path_render (RsvgClipPath *s, RsvgHandle *ctx);
rsvg_clip_path_render (RsvgClipPath *s, DrawingCtx *ctx);
void
rsvg_start_clip_path (RsvgHandle *ctx, RsvgPropertyBag *atts);
......@@ -77,7 +77,7 @@ RsvgDefsDrawable *
rsvg_clip_path_parse (const RsvgDefs * defs, const char *str);
ArtSVP *
rsvg_rect_clip_path(double x, double y, double w, double h, RsvgHandle * ctx);
rsvg_rect_clip_path(double x, double y, double w, double h, DrawingCtx * ctx);
ArtSVP *
rsvg_clip_path_merge(ArtSVP * first, ArtSVP * second, char operation);
......
......@@ -52,6 +52,7 @@ struct _RsvgPaintServer {
struct _RsvgPaintServerSolid {
RsvgPaintServer super;
gboolean currentcolour;
guint32 rgb;
};
......@@ -84,6 +85,8 @@ rsvg_paint_server_solid_render (RsvgPaintServer *self, ArtRender *ar,
{
RsvgPaintServerSolid *z = (RsvgPaintServerSolid *)self;
guint32 rgb = z->rgb;
if (z->currentcolour)
rgb = rsvg_state_current(ctx->ctx)->current_color;
ArtPixMaxDepth color[3];
color[0] = ART_PIX_MAX_FROM_8 (rgb >> 16);
......@@ -103,6 +106,21 @@ rsvg_paint_server_solid (guint32 rgb)
result->super.render = rsvg_paint_server_solid_render;
result->rgb = rgb;
result->currentcolour = FALSE;
return &result->super;
}
static RsvgPaintServer *
rsvg_paint_server_solid_current_colour ()
{
RsvgPaintServerSolid *result = g_new (RsvgPaintServerSolid, 1);
result->super.refcnt = 1;
result->super.free = rsvg_paint_server_solid_free;
result->super.render = rsvg_paint_server_solid_render;
result->currentcolour = TRUE;
return &result->super;
}
......@@ -482,7 +500,7 @@ rsvg_paint_server_pattern_render (RsvgPaintServer *self, ArtRender *ar,
RsvgPaintServerPattern *z = (RsvgPaintServerPattern *)self;
RsvgPattern *pattern = z->pattern;
RsvgDefsDrawable *drawable = (RsvgDefsDrawable *)pattern->g;
RsvgHandle *hctx = ctx->ctx;
DrawingCtx *hctx = ctx->ctx;
double affine[6];
double caffine[6];
int i, j;
......@@ -634,11 +652,12 @@ rsvg_paint_server_pattern (RsvgPattern *pattern)
* Return value: The newly created paint server, or NULL on error.
**/
RsvgPaintServer *
rsvg_paint_server_parse (RsvgPaintServer * current, const RsvgDefs *defs, const char *str,
rsvg_paint_server_parse (gboolean * inherit, const RsvgDefs *defs, const char *str,
guint32 current_color)
{
guint32 rgb;
if (inherit != NULL)
*inherit = 1;
if (!strcmp (str, "none"))
return NULL;
......@@ -674,20 +693,23 @@ rsvg_paint_server_parse (RsvgPaintServer * current, const RsvgDefs *defs, const
return NULL;
}
}
else if (current && !strcmp (str, "inherit"))
else if (!strcmp (str, "inherit"))
{
rsvg_paint_server_ref (current);
return current;
if (inherit != NULL)
*inherit = 0;
return NULL;
}
else if (!strcmp (str, "currentColor"))
{
RsvgPaintServer * ps;
ps = rsvg_paint_server_solid_current_colour (0);
return ps;
}
else
{
if (!strcmp (str, "currentColor"))
rgb = current_color;
else
rgb = rsvg_css_parse_color (str, 0);
return rsvg_paint_server_solid (rgb);
}
{
rgb = rsvg_css_parse_color (str, 0);
return rsvg_paint_server_solid (rgb);
}
}
/**
......
......@@ -50,7 +50,7 @@ struct _RsvgPSCtx {
guint32 color;
double affine[6];
RsvgHandle *ctx;
DrawingCtx *ctx;
};
struct _RsvgGradientStop {
......@@ -104,7 +104,7 @@ struct _RsvgPattern {
/* Create a new paint server based on a specification string. */
RsvgPaintServer *
rsvg_paint_server_parse (RsvgPaintServer * current, const RsvgDefs *defs, const char *str,
rsvg_paint_server_parse (gboolean * inherit, const RsvgDefs *defs, const char *str,
guint32 current_color);
void
......
......@@ -37,6 +37,8 @@
G_BEGIN_DECLS
typedef struct RsvgSaxHandler RsvgSaxHandler;
typedef struct DrawingCtx DrawingCtx;
typedef struct RsvgDimentionData RsvgDimentionData;
typedef struct _RsvgPropertyBag RsvgPropertyBag;
typedef struct _RsvgState RsvgState;
typedef struct _RsvgDefs RsvgDefs;
......@@ -63,19 +65,18 @@ struct RsvgHandle {
RsvgSizeFunc size_func;
gpointer user_data;
GDestroyNotify user_data_destroy;
GdkPixbuf *pixbuf;
ArtIRect bbox;
/* stack; there is a state for each element */
GSList * state;
RsvgDefs *defs;
guint nest_level;
void *current_defs_group;
/* this is the root level of the displayable tree, essentially what the
file is converted into at the end */
void *treebase;
guint in_switch;
GHashTable *css_props;
/* not a handler stack. each nested handler keeps
......@@ -92,8 +93,12 @@ struct RsvgHandle {
int width;
int height;
int new_width;
int new_height;
double dpi_x;
double dpi_y;
GSList * dimentions;
GString * title;
GString * desc;
......@@ -104,8 +109,6 @@ struct RsvgHandle {
void * currentfilter;
void * currentsubfilter;
GMemChunk * state_allocator;
/* virtual fns */
gboolean (* write) (RsvgHandle *handle,
const guchar *buf,
......@@ -118,6 +121,23 @@ struct RsvgHandle {
void (* free) (RsvgHandle * handle);
};
struct DrawingCtx {
GdkPixbuf *pixbuf;
ArtIRect bbox;
GSList * state;
GError **error;
RsvgDefs *defs;
gchar * base_uri;
GMemChunk * state_allocator;
};
struct RsvgDimentionData {
int width;
int height;
gdouble em, ex;
};
void rsvg_linear_gradient_free (RsvgDefVal *self);
void rsvg_radial_gradient_free (RsvgDefVal *self);
void rsvg_pattern_free (RsvgDefVal *self);
......
This diff is collapsed.
......@@ -33,9 +33,9 @@ G_BEGIN_DECLS
typedef struct _RsvgDefsDrawable RsvgDefsDrawable;
void rsvg_handle_path (RsvgHandle *ctx, const char * d, const char * id);
void rsvg_render_path (RsvgHandle *ctx, const char *d);
ArtSVP * rsvg_render_path_as_svp(RsvgHandle *ctx, const char *d);
void rsvg_handle_path (RsvgHandle *ctx, const char * d, const char * id, RsvgState);
void rsvg_render_path (DrawingCtx *ctx, const char *d);
ArtSVP * rsvg_render_path_as_svp(DrawingCtx *ctx, const char *d);
void rsvg_start_path (RsvgHandle *ctx, RsvgPropertyBag *atts);
void rsvg_start_polygon (RsvgHandle *ctx, RsvgPropertyBag *atts);
void rsvg_start_polyline (RsvgHandle *ctx, RsvgPropertyBag *atts);
......@@ -48,8 +48,8 @@ void rsvg_start_use (RsvgHandle *ctx, RsvgPropertyBag *atts);
void rsvg_start_symbol (RsvgHandle *ctx, RsvgPropertyBag *atts);
void rsvg_start_sub_svg (RsvgHandle *ctx, RsvgPropertyBag *atts);
RsvgDefsDrawable * rsvg_push_def_group (RsvgHandle *ctx, const char * id);
RsvgDefsDrawable * rsvg_push_part_def_group (RsvgHandle *ctx, const char * id);
RsvgDefsDrawable * rsvg_push_def_group (RsvgHandle *ctx, const char * id, RsvgState);
RsvgDefsDrawable * rsvg_push_part_def_group (RsvgHandle *ctx, const char * id, RsvgState);
void rsvg_pop_def_group (RsvgHandle *ctx);
typedef struct _RsvgDefsDrawablePath RsvgDefsDrawablePath;
......@@ -63,8 +63,8 @@ struct _RsvgDefsDrawable {
RsvgDefVal super;
RsvgState state;
RsvgDefsDrawable * parent;
void (*draw) (RsvgDefsDrawable * self, RsvgHandle *ctx, int dominate);
ArtSVP * (*draw_as_svp) (RsvgDefsDrawable * self, RsvgHandle *ctx, int dominate);
void (*draw) (RsvgDefsDrawable * self, DrawingCtx *ctx, int dominate);
ArtSVP * (*draw_as_svp) (RsvgDefsDrawable * self, DrawingCtx *ctx, int dominate);
};
struct _RsvgDefsDrawablePath {
......@@ -121,7 +121,7 @@ void
rsvg_start_marker (RsvgHandle *ctx, RsvgPropertyBag *atts);
void
rsvg_marker_render (RsvgMarker *self, gdouble x, gdouble y, gdouble orient, gdouble linewidth, RsvgHandle *ctx);
rsvg_marker_render (RsvgMarker *self, gdouble x, gdouble y, gdouble orient, gdouble linewidth, DrawingCtx *ctx);
RsvgDefVal *
rsvg_marker_parse (const RsvgDefs * defs, const char *str);
......@@ -131,9 +131,9 @@ rsvg_pixbuf_new_from_href (const char *href,
const char *base_uri,
GError **err);
void rsvg_defs_drawable_draw (RsvgDefsDrawable * self, RsvgHandle *ctx,
void rsvg_defs_drawable_draw (RsvgDefsDrawable * self, DrawingCtx *ctx,
int dominate);
ArtSVP * rsvg_defs_drawable_draw_as_svp (RsvgDefsDrawable * self, RsvgHandle *ctx,
ArtSVP * rsvg_defs_drawable_draw_as_svp (RsvgDefsDrawable * self, DrawingCtx *ctx,
int dominate);
void rsvg_preserve_aspect_ratio(unsigned int aspect_ratio, double width,
......
......@@ -39,6 +39,7 @@
#define RSVG_DEFAULT_FONT "Times New Roman"
/*
static guint32
rsvg_state_current_color (RsvgState * cur_state, RsvgState * parent_state)
{
......@@ -52,6 +53,7 @@ rsvg_state_current_color (RsvgState * cur_state, RsvgState * parent_state)
return 0;
}
*/
gdouble
rsvg_viewport_percentage (gdouble width, gdouble height)
......@@ -364,22 +366,13 @@ rsvg_state_finalize (RsvgState *state)
static void
rsvg_parse_style_arg (RsvgHandle *ctx, RsvgState *state, const char *str)
{
RsvgState * parent_state;
int arg_off;
parent_state = rsvg_state_parent (ctx);
arg_off = rsvg_css_param_arg_offset (str);
if (rsvg_css_param_match (str, "color"))
{
RsvgState * parent_state = rsvg_state_parent (ctx);
if (parent_state)
state->current_color = rsvg_css_parse_color (str + arg_off, parent_state->current_color);
else
state->current_color = rsvg_css_parse_color (str + arg_off, 0);
state->has_current_color = TRUE;
state->current_color = rsvg_css_parse_color (str + arg_off, &state->has_current_color);
}
else if (rsvg_css_param_match (str, "opacity"))
{
......@@ -452,15 +445,7 @@ rsvg_parse_style_arg (RsvgHandle *ctx, RsvgState *state, const char *str)
else if (rsvg_css_param_match (str, "fill"))
{
RsvgPaintServer * fill = state->fill;
guint32 current_color = rsvg_state_current_color (state, parent_state);
if (parent_state)
state->fill = rsvg_paint_server_parse (parent_state->fill, ctx->defs, str + arg_off, current_color);
else
state->fill = rsvg_paint_server_parse (NULL, ctx->defs, str + arg_off, current_color);
state->has_fill_server = TRUE;
state->fill = rsvg_paint_server_parse (&state->has_fill_server, ctx->defs, str + arg_off, 0);
rsvg_paint_server_unref (fill);
}
else if (rsvg_css_param_match (str, "fill-opacity"))
......@@ -491,14 +476,8 @@ rsvg_parse_style_arg (RsvgHandle *ctx, RsvgState *state, const char *str)
else if (rsvg_css_param_match (str, "stroke"))
{
RsvgPaintServer * stroke = state->stroke;
guint32 current_color = rsvg_state_current_color (state, parent_state);
if (parent_state)
state->stroke = rsvg_paint_server_parse (parent_state->stroke, ctx->defs, str + arg_off, current_color);
else
state->stroke = rsvg_paint_server_parse (NULL, ctx->defs, str + arg_off, current_color);
state->has_stroke_server = TRUE;
state->stroke = rsvg_paint_server_parse (&state->has_stroke_server, ctx->defs, str + arg_off, 0);
rsvg_paint_server_unref (stroke);
}
......@@ -542,14 +521,18 @@ rsvg_parse_style_arg (RsvgHandle *ctx, RsvgState *state, const char *str)
state->font_size = rsvg_css_parse_normalized_length (str + arg_off, ctx->dpi_y,
(gdouble)ctx->height, state->font_size);
state->has_font_size = TRUE;
if (ctx != NULL)
{
((RsvgDimentionData *)g_slist_nth(ctx->dimentions,
0)->data)->em
= state->font_size;
}
}
else if (rsvg_css_param_match (str, "font-family"))
{
char * save = g_strdup (rsvg_css_parse_font_family (str + arg_off,
(parent_state ? parent_state->font_family : RSVG_DEFAULT_FONT)));
char * save = g_strdup (rsvg_css_parse_font_family (str + arg_off, &state->has_font_family));
g_free (state->font_family);
state->font_family = save;
state->has_font_family = TRUE;
}
else if (rsvg_css_param_match (str, "xml:lang"))
{
......@@ -560,34 +543,26 @@ rsvg_parse_style_arg (RsvgHandle *ctx, RsvgState *state, const char *str)
}
else if (rsvg_css_param_match (str, "font-style"))
{
state->font_style = rsvg_css_parse_font_style (str + arg_off,
(parent_state ? parent_state->font_style : PANGO_STYLE_NORMAL));
state->has_font_style = TRUE;
state->font_style = rsvg_css_parse_font_style (str + arg_off, &state->has_font_style);
}
else if (rsvg_css_param_match (str, "font-variant"))
{
state->font_variant = rsvg_css_parse_font_variant (str + arg_off,
(parent_state ? parent_state->font_variant : PANGO_VARIANT_NORMAL));
state->has_font_variant = TRUE;
state->font_variant = rsvg_css_parse_font_variant (str + arg_off, &state->has_font_variant);
}
else if (rsvg_css_param_match (str, "font-weight"))
{
state->font_weight = rsvg_css_parse_font_weight (str + arg_off,
(parent_state ? parent_state->font_weight : PANGO_WEIGHT_NORMAL));
state->has_font_weight = TRUE;
state->font_weight = rsvg_css_parse_font_weight (str + arg_off, &state->has_font_weight);
}
else if (rsvg_css_param_match (str, "font-stretch"))
{
state->font_stretch = rsvg_css_parse_font_stretch (str + arg_off,
(parent_state ? parent_state->font_stretch : PANGO_STRETCH_NORMAL));
state->has_font_stretch = TRUE;
state->font_stretch = rsvg_css_parse_font_stretch (str + arg_off, &state->has_font_stretch);
}
else if (rsvg_css_param_match (str, "text-decoration"))
{
if (!strcmp (str + arg_off, "inherit"))
{
state->has_font_decor = FALSE;
state->font_decor = (parent_state ? parent_state->font_decor : TEXT_NORMAL);
state->font_decor = TEXT_NORMAL;
}
else
{
......@@ -605,7 +580,7 @@ rsvg_parse_style_arg (RsvgHandle *ctx, RsvgState *state, const char *str)
state->has_text_dir = TRUE;
if (!strcmp (str + arg_off, "inherit"))
{
state->text_dir = (parent_state ? parent_state->text_dir : PANGO_DIRECTION_LTR);
state->text_dir = PANGO_DIRECTION_LTR;
state->has_text_dir = FALSE;
}
else if (!strcmp (str + arg_off, "rtl"))
......@@ -618,7 +593,7 @@ rsvg_parse_style_arg (RsvgHandle *ctx, RsvgState *state, const char *str)
state->has_unicode_bidi = TRUE;
if (!strcmp (str + arg_off, "inherit"))
{
state->unicode_bidi = (parent_state ? parent_state->unicode_bidi : PANGO_DIRECTION_LTR);
state->unicode_bidi = PANGO_DIRECTION_LTR;
state->has_unicode_bidi = FALSE;
}
else if (!strcmp (str + arg_off, "embed"))
......@@ -634,7 +609,7 @@ rsvg_parse_style_arg (RsvgHandle *ctx, RsvgState *state, const char *str)
state->has_text_dir = TRUE;
if (!strcmp (str + arg_off, "inherit")) {
state->text_dir = parent_state->text_dir;
state->text_dir = PANGO_DIRECTION_LTR;
state->has_text_dir = FALSE;
}
else if (!strcmp (str + arg_off, "lr-tb") ||
......@@ -653,7 +628,7 @@ rsvg_parse_style_arg (RsvgHandle *ctx, RsvgState *state, const char *str)
state->has_text_anchor = TRUE;
if (!strcmp (str + arg_off, "inherit"))
{
state->text_anchor = (parent_state ? parent_state->text_anchor : TEXT_ANCHOR_START);
state->text_anchor = TEXT_ANCHOR_START;
state->has_text_anchor = FALSE;
}
else
......@@ -668,11 +643,9 @@ rsvg_parse_style_arg (RsvgHandle *ctx, RsvgState *state, const char *str)
}
else if (rsvg_css_param_match (str, "stop-color"))
{
guint32 current_color = rsvg_state_current_color (state, parent_state);
if (strcmp(str + arg_off, "inherit"))
{
state->has_stop_color = TRUE;
state->stop_color = rsvg_css_parse_color (str + arg_off, current_color);
state->stop_color = rsvg_css_parse_color (str + arg_off, &state->has_stop_color);
}
}
else if (rsvg_css_param_match (str, "stop-opacity"))
......@@ -1255,14 +1228,13 @@ rsvg_parse_transform_attr (RsvgHandle *ctx, RsvgState *state, const char *str)
}
static gboolean
rsvg_lookup_apply_css_style (RsvgHandle *ctx, const char * target)
rsvg_lookup_apply_css_style (RsvgHandle *ctx, const char * target, RsvgState *state)
{