svg_status_t _svg_style_init_empty (svg_style_t *style, svg_t *svg) { style->svg = svg; style->flags = SVG_STYLE_FLAG_NONE; style->font_family = NULL; _svg_length_init_from_str (&style->font_size, "10px"); style->num_dashes = 0; style->stroke_dash_array = NULL; style->stroke_dash_offset.value = 0; /* initialize unused elements so copies are predictable */ style->stroke_line_cap = SVG_STROKE_LINE_CAP_BUTT; style->stroke_line_join = SVG_STROKE_LINE_JOIN_MITER; style->stroke_miter_limit = 4.0; style->stroke_opacity = 1.0; style->fill_opacity = 1.0; /* opacity is not inherited */ style->flags |= SVG_STYLE_FLAG_OPACITY; style->opacity = 1.0; style->flags |= SVG_STYLE_FLAG_VISIBILITY; style->flags |= SVG_STYLE_FLAG_DISPLAY; return SVG_STATUS_SUCCESS; }
static svg_status_t _svg_style_parse_stroke_width (svg_style_t *style, const char *str) { svg_status_t status; status = _svg_length_init_from_str (&style->stroke_width, str); if (status) return status; style->flags |= SVG_STYLE_FLAG_STROKE_WIDTH; return SVG_STATUS_SUCCESS; }
static svg_status_t _svg_style_parse_stroke_dash_offset (svg_style_t *style, const char *str) { svg_status_t status; status = _svg_length_init_from_str (&style->stroke_dash_offset, str); if (status) return status; style->flags |= SVG_STYLE_FLAG_STROKE_DASH_OFFSET; return SVG_STATUS_SUCCESS; }
static svg_status_t _svg_style_parse_font_size (svg_style_t *style, const char *str) { svg_status_t status; status = _svg_length_init_from_str (&style->font_size, str); if (status) return status; style->flags |= SVG_STYLE_FLAG_FONT_SIZE; return SVG_STATUS_SUCCESS; }
svgint_status_t _svg_attribute_get_length (const char **attributes, const char *name, svg_length_t *value, const char *default_value) { int i; _svg_length_init_from_str (value, default_value); if (attributes == NULL) return SVGINT_STATUS_ATTRIBUTE_NOT_FOUND; for (i=0; attributes[i]; i += 2) { if (strcmp (attributes[i], name) == 0) { _svg_length_init_from_str (value, attributes[i+1]); return SVG_STATUS_SUCCESS; } } return SVGINT_STATUS_ATTRIBUTE_NOT_FOUND; }