librsvg r1156 - trunk
- From: doml svn gnome org
- To: svn-commits-list gnome org
- Subject: librsvg r1156 - trunk
- Date: Sun, 24 Feb 2008 16:14:25 +0000 (GMT)
Author: doml
Date: Sun Feb 24 16:14:25 2008
New Revision: 1156
URL: http://svn.gnome.org/viewvc/librsvg?rev=1156&view=rev
Log:
2008-02-24 Dominic Lachowicz <domlachowicz gmail com>
* rsvg-text.c:
* rsvg-styles.h:
* rsvg-styles.c: Handle xml:space="prserve" (#353609)
Modified:
trunk/ChangeLog
trunk/rsvg-styles.c
trunk/rsvg-styles.h
trunk/rsvg-text.c
Modified: trunk/rsvg-styles.c
==============================================================================
--- trunk/rsvg-styles.c (original)
+++ trunk/rsvg-styles.c Sun Feb 24 16:14:25 2008
@@ -246,6 +246,12 @@
dst->font_family = g_strdup (src->font_family);
}
+ if (function (dst->has_space_preserve, src->has_space_preserve))
+ dst->space_preserve = src->space_preserve;
+
+ if (function (dst->has_visible, src->has_visible))
+ dst->visible = src->visible;
+
if (function (dst->has_lang, src->has_lang)) {
if (dst->has_lang)
g_free (dst->lang);
@@ -479,6 +485,14 @@
state->visible = TRUE;
else
state->has_visible = FALSE;
+ } else if (rsvg_css_param_match (str, "xml:space")) {
+ state->has_space_preserve = TRUE;
+ if (!strcmp (str + arg_off, "default"))
+ state->space_preserve = FALSE;
+ else if (strcmp (str + arg_off, "preserve") == 0)
+ state->space_preserve = TRUE;
+ else
+ state->space_preserve = FALSE;
} else if (rsvg_css_param_match (str, "visibility")) {
state->has_visible = TRUE;
if (!strcmp (str + arg_off, "visible"))
@@ -789,6 +803,7 @@
rsvg_lookup_parse_style_pair (ctx, state, "visibility", atts);
rsvg_lookup_parse_style_pair (ctx, state, "writing-mode", atts);
rsvg_lookup_parse_style_pair (ctx, state, "xml:lang", atts);
+ rsvg_lookup_parse_style_pair (ctx, state, "xml:space", atts);
{
/* TODO: this conditional behavior isn't quite correct, and i'm not sure it should reside here */
Modified: trunk/rsvg-styles.h
==============================================================================
--- trunk/rsvg-styles.h (original)
+++ trunk/rsvg-styles.h Sun Feb 24 16:14:25 2008
@@ -201,6 +201,9 @@
gboolean visible;
gboolean has_visible;
+ gboolean space_preserve;
+ gboolean has_space_preserve;
+
gboolean has_cond;
gboolean cond_true;
Modified: trunk/rsvg-text.c
==============================================================================
--- trunk/rsvg-text.c (original)
+++ trunk/rsvg-text.c Sun Feb 24 16:14:25 2008
@@ -90,34 +90,36 @@
}
static GString *
-_rsvg_text_chomp (GString * in, gboolean * lastwasspace)
+_rsvg_text_chomp (RsvgState *state, GString * in, gboolean * lastwasspace)
{
GString *out;
guint i;
out = g_string_new (in->str);
- for (i = 0; i < out->len;) {
- if (out->str[i] == '\n')
- g_string_erase (out, i, 1);
- else
- i++;
- }
-
- for (i = 0; i < out->len; i++)
- if (out->str[i] == '\t')
- out->str[i] = ' ';
-
- for (i = 0; i < out->len;) {
- if (out->str[i] == ' ' && *lastwasspace)
- g_string_erase (out, i, 1);
- else {
- if (out->str[i] == ' ')
- *lastwasspace = TRUE;
- else
- *lastwasspace = FALSE;
- i++;
- }
- }
+ if (!state->space_preserve) {
+ for (i = 0; i < out->len;) {
+ if (out->str[i] == '\n')
+ g_string_erase (out, i, 1);
+ else
+ i++;
+ }
+
+ for (i = 0; i < out->len; i++)
+ if (out->str[i] == '\t')
+ out->str[i] = ' ';
+
+ for (i = 0; i < out->len;) {
+ if (out->str[i] == ' ' && *lastwasspace)
+ g_string_erase (out, i, 1);
+ else {
+ if (out->str[i] == ' ')
+ *lastwasspace = TRUE;
+ else
+ *lastwasspace = FALSE;
+ i++;
+ }
+ }
+ }
return out;
}
@@ -172,7 +174,7 @@
RsvgNode *node = g_ptr_array_index (self->children, i);
if (!strcmp (node->type->str, "RSVG_NODE_CHARS")) {
RsvgNodeChars *chars = (RsvgNodeChars *) node;
- GString *str = _rsvg_text_chomp (chars->contents, lastwasspace);
+ GString *str = _rsvg_text_chomp (rsvg_state_current (ctx), chars->contents, lastwasspace);
rsvg_text_render_text (ctx, str->str, x, y);
g_string_free (str, TRUE);
} else if (!strcmp (node->type->str, "tspan")) {
@@ -208,7 +210,7 @@
RsvgNode *node = g_ptr_array_index (self->children, i);
if (!strcmp (node->type->str, "RSVG_NODE_CHARS")) {
RsvgNodeChars *chars = (RsvgNodeChars *) node;
- GString *str = _rsvg_text_chomp (chars->contents, lastwasspace);
+ GString *str = _rsvg_text_chomp (rsvg_state_current (ctx), chars->contents, lastwasspace);
*x += rsvg_text_length_text_as_string (ctx, str->str);
g_string_free (str, TRUE);
} else if (!strcmp (node->type->str, "tspan")) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]