[lasem] svg: fix dash array parsing, when values are space separated.



commit b7c17a7b022925d5e5e14a7ee1fd3802db8efb12
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Sat Oct 27 14:16:07 2012 +0200

    svg: fix dash array parsing, when values are space separated.

 src/lsmsvgtraits.c                            |   25 ++++++++++++++++---------
 tests/data/svg/suite/paths/dash-array-ref.png |  Bin 0 -> 342 bytes
 tests/data/svg/suite/paths/dash-array.svg     |   14 ++++++++++++++
 3 files changed, 30 insertions(+), 9 deletions(-)
---
diff --git a/src/lsmsvgtraits.c b/src/lsmsvgtraits.c
index e83e3ea..9db4bea 100644
--- a/src/lsmsvgtraits.c
+++ b/src/lsmsvgtraits.c
@@ -698,14 +698,21 @@ lsm_svg_dash_array_trait_from_string (LsmTrait *abstract_trait, char *string)
 	dash_array->n_dashes = 0;
 	dash_array->dashes = NULL;
 
-	if (strcmp (string, "none") != 0) {
+	if (strcmp (string, "none") != 0 &&
+	    strcmp (string, "inherit")) {
 		char *iter = (char *) string;
 		unsigned int i;
 
 		while (*iter != '\0') {
-			if (*iter == ',')
+			if (*iter == ',' ||
+			    *iter == ' ') {
 				n_dashes++;
-			iter++;
+				do {
+					iter++;
+				} while (*iter == ',' ||
+					 *iter == ' ');
+			} else
+				iter++;
 		}
 
 		if (n_dashes > 0) {
@@ -737,14 +744,14 @@ lsm_svg_dash_array_trait_from_string (LsmTrait *abstract_trait, char *string)
 				sum += value;
 			}
 		}
-	}
 
-	if (is_error || sum <= 0.0) {
-		g_free (dash_array->dashes);
-		dash_array->n_dashes = 0;
-		dash_array->dashes = NULL;
+		if (is_error || sum <= 0.0) {
+			g_free (dash_array->dashes);
+			dash_array->n_dashes = 0;
+			dash_array->dashes = NULL;
 
-		return !is_error;
+			return !is_error;
+		}
 	}
 
 	return TRUE;
diff --git a/tests/data/svg/suite/paths/dash-array-ref.png b/tests/data/svg/suite/paths/dash-array-ref.png
new file mode 100644
index 0000000..1e41461
Binary files /dev/null and b/tests/data/svg/suite/paths/dash-array-ref.png differ
diff --git a/tests/data/svg/suite/paths/dash-array.svg b/tests/data/svg/suite/paths/dash-array.svg
new file mode 100644
index 0000000..41473ff
--- /dev/null
+++ b/tests/data/svg/suite/paths/dash-array.svg
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+
+<svg xmlns="http://www.w3.org/2000/svg"; width="100" height="100">
+  <defs>
+  </defs>
+    <line x1="10" y1="10" x2="80" y2="10" stroke-dasharray="4 4 10 10" stroke-width="10" stroke="red"/>
+    <line x1="10" y1="20" x2="80" y2="20" stroke-dashoffset="-4" stroke-dasharray="4 4 10 10" stroke-width="10" stroke="blue"/>
+
+    <line x1="10" y1="40" x2="80" y2="40" stroke-dasharray="4" stroke-width="10" stroke="red"/>
+    <line x1="10" y1="50" x2="80" y2="50" stroke-dashoffset="-4" stroke-dasharray="4" stroke-width="10" stroke="blue"/>
+
+    <line x1="10" y1="70" x2="80" y2="70" stroke-dasharray="4 4,10 10" stroke-width="10" stroke="red"/>
+    <line x1="10" y1="80" x2="80" y2="80" stroke-dasharray="  4 4 ,  10 10 " stroke-width="10" stroke="blue"/>
+</svg>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]