summaryrefslogtreecommitdiffstats
path: root/src/style.cpp
diff options
context:
space:
mode:
authorMenTaLguY <mental@rydia.net>2007-06-30 23:40:01 +0000
committermental <mental@users.sourceforge.net>2007-06-30 23:40:01 +0000
commit28fda77b97c3fd349d018a751d99bfebc195d2b4 (patch)
tree4eaf75067d1bec1360a7b82fb968b5d38ef79256 /src/style.cpp
parentAdd keybindings for the 3D box tool (diff)
downloadinkscape-28fda77b97c3fd349d018a751d99bfebc195d2b4.tar.gz
inkscape-28fda77b97c3fd349d018a751d99bfebc195d2b4.zip
isolated internal spaces no longer force font-family quoting, for the
sake of backwards-compatibility with older Inkscape version; also, additional comments (bzr r3157)
Diffstat (limited to 'src/style.cpp')
-rw-r--r--src/style.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/style.cpp b/src/style.cpp
index fbd472129..d7e0186b0 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -4047,24 +4047,42 @@ css2_escape_quote(gchar const *val) {
Glib::ustring t;
bool quote = false;
+ bool last_was_space = false;
for (gchar const *i = val; *i; i++) {
+ bool is_space = ( *i == ' ' );
if (g_ascii_isalnum(*i) || *i=='-' || *i=='_') {
+ // ASCII alphanumeric, - and _ don't require quotes
+ t.push_back(*i);
+ } else if ( is_space && !last_was_space ) {
+ // non-consecutive spaces don't require quotes
t.push_back(*i);
} else if (*i=='\'') {
+ // single quotes require escaping and quotes
t.push_back('\\');
t.push_back(*i);
quote = true;
} else {
+ // everything else requires quotes
t.push_back(*i);
quote = true;
}
if (i == val && !g_ascii_isalpha(*i)) {
+ // a non-ASCII/non-alpha initial character requires quotes
quote = true;
}
+ last_was_space = is_space;
+ }
+
+ if (last_was_space) {
+ // a trailing space requires quotes
+ quote = true;
}
- if (quote) { // we use the ' quotes so the result can go to the XML attribute
+ if (quote) {
+ // we use single quotes so the result can be stored in an XML
+ // attribute without incurring un-aesthetic additional quoting
+ // (our XML emitter always uses double quotes)
t.insert(t.begin(), '\'');
t.push_back('\'');
}