diff --git a/src/svg/svg-color.cpp b/src/svg/svg-color.cpp
index 6bbcdd8846c7db93a4bd0e15d3fdcd0f185dbfed..9040d6e4389ae02a900ae6338304c98ede446bdc 100644 (file)
--- a/src/svg/svg-color.cpp
+++ b/src/svg/svg-color.cpp
# include "config.h"
#endif
-#include "svg-color.h"
-#include "svg-icc-color.h"
+#include <cstdlib>
+#include <cstdio> // sprintf
+#include <cstring>
+#include <string>
#include <cassert>
#include <math.h>
#include <glib/gmem.h>
+#include <glib.h> // g_assert
#include <glib/gmessages.h>
#include <glib/gstrfuncs.h>
#include <glib/ghash.h>
#include <glib/gutils.h>
-#include <cstdio> // sprintf
#include <errno.h>
+
#include "strneq.h"
+#include "preferences.h"
+#include "svg-color.h"
+#include "svg-icc-color.h"
+
using std::sprintf;
struct SPSVGColor {
@@ -240,17 +247,17 @@ internal_sp_svg_read_color(gchar const *str, gchar const **end_ptr, guint32 def)
gdouble r, g, b;
s = (gchar *) str + 4;
- hasp = FALSE;
- hasd = FALSE;
+ hasp = false;
+ hasd = false;
r = g_ascii_strtod(s, &e);
if (s == e) return def;
s = e;
if (*s == '%') {
- hasp = TRUE;
+ hasp = true;
s += 1;
} else {
- hasd = TRUE;
+ hasd = true;
}
while (*s && g_ascii_isspace(*s)) s += 1;
if (*s != ',') return def;
@@ -260,10 +267,10 @@ internal_sp_svg_read_color(gchar const *str, gchar const **end_ptr, guint32 def)
if (s == e) return def;
s = e;
if (*s == '%') {
- hasp = TRUE;
+ hasp = true;
s += 1;
} else {
- hasd = TRUE;
+ hasd = true;
}
while (*s && g_ascii_isspace(*s)) s += 1;
if (*s != ',') return def;
@@ -273,10 +280,10 @@ internal_sp_svg_read_color(gchar const *str, gchar const **end_ptr, guint32 def)
if (s == e) return def;
s = e;
if (*s == '%') {
- hasp = TRUE;
+ hasp = true;
s += 1;
} else {
- hasd = TRUE;
+ hasd = true;
}
while(*s && g_ascii_isspace(*s)) s += 1;
if (*s != ')') {
strcpy(buf, src);
}
- assert(sp_svg_read_color(buf, 0xff) == (rgb24 << 8));
+ // assert(sp_svg_read_color(buf, 0xff) == (rgb24 << 8));
}
/**
{
g_assert(8 <= buflen);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
unsigned const rgb24 = rgba32 >> 8;
- rgb24_to_css(buf, rgb24);
+ if (prefs->getBool("/options/svgoutput/usenamedcolors")) {
+ rgb24_to_css(buf, rgb24);
+ } else {
+ g_snprintf(buf, buflen, "#%06x", rgb24);
+ }
}
static GHashTable *
@@ -476,7 +488,7 @@ bool sp_svg_read_icc_color( gchar const *str, gchar const **end_ptr, SVGICCColor
// Name must start with a certain type of character
good = false;
} else {
- while ( g_ascii_isdigit(*str) || g_ascii_islower(*str) || (*str == '-') ) {
+ while ( g_ascii_isdigit(*str) || g_ascii_isalpha(*str) || (*str == '-') ) {
if ( dest ) {
dest->colorProfile += *str;
}