Code

(sp_style_write_ipaint): Pretty colour names: use sp_svg_write_color instead of ...
authorpjrm <pjrm@users.sourceforge.net>
Mon, 13 Mar 2006 06:51:37 +0000 (06:51 +0000)
committerpjrm <pjrm@users.sourceforge.net>
Mon, 13 Mar 2006 06:51:37 +0000 (06:51 +0000)
style-test.cpp: Update unit tests accordingly.

src/style-test.cpp
src/style.cpp

index 86382b1743a9e53aabf4ae41360888c717f7d4cd..54be0040edfa2c1be17650d966e318410159bee6 100644 (file)
@@ -249,7 +249,7 @@ static void
 color_val(char const prop[], char const *const dummy_vals[])
 {
     assert(dummy_vals == NULL);
-    char const *const extra_vals[] = {"#0000ff", NULL};
+    char const *const extra_vals[] = {"blue", "#234", "#0100ff", NULL};
     enum_val(prop, extra_vals);
 #if 0
     char const *color_vals[G_N_ELEMENTS(color_keywords) + G_N_ELEMENTS(extra_vals)];
@@ -540,10 +540,10 @@ test_style()
         char const *const *tst_fn_arg;
         bool can_explicitly_inherit;
     } const props[] = {
-        {"color", "#000000", "#000000", color_val, NULL, true},
+        {"color", "black", "black", color_val, NULL, true},
         // initial value "depends on user agent"
         {"display", "inline", "inline", enum_val, display_vals, true},
-        {"fill", "#000000", "black", paint_val, NULL, true},
+        {"fill", "black", "black", paint_val, NULL, true},
         {"fill-opacity", "1", "1", opacity_val, NULL, true},
         {"fill-rule", "nonzero", "nonzero", enum_val, fill_rule_vals, true},
         {"font-family", "Bitstream Vera Sans", "Bitstream Vera Sans", font_family_val, NULL, true},
@@ -595,8 +595,8 @@ test_style()
         "writing-mode:lr-tb;"
         "text-anchor:start;"
         "opacity:1;"
-        "color:#000000;"
-        "fill:#000000;"
+        "color:black;"
+        "fill:black;"
         "fill-opacity:1;"
         "fill-rule:nonzero;"
         "stroke:none;"
@@ -687,7 +687,7 @@ test_style()
                                                bad[i], bad[i]);
             UTEST_TEST(tst_name) {
                 gchar *str0_set = merge_then_write_string(style_str, SP_STYLE_FLAG_IFSET);
-                UTEST_ASSERT(streq(str0_set, "color:#112233"));
+                UTEST_ASSERT(streq(str0_set, "color:#123"));
                 g_free(str0_set);
             }
             g_free(style_str);
index 3baa1678be88fc24c5b326cd551f1ddf60175287..3ed6f335f80e82aae4ac0b5854796ed39d9005e5 100644 (file)
@@ -3325,12 +3325,13 @@ sp_style_write_ipaint(gchar *b, gint const len, gchar const *const key,
             return g_snprintf(b, len, "%s:currentColor;", key);
         } else {
             switch (paint->type) {
-                case SP_PAINT_TYPE_COLOR:
-                    return g_snprintf(b, len, "%s:#%06x;", key, sp_color_get_rgba32_falpha(&paint->value.color, 0.0) >> 8);
-                    break;
+                case SP_PAINT_TYPE_COLOR: {
+                    char color_buf[8];
+                    sp_svg_write_color(color_buf, sizeof(color_buf), sp_color_get_rgba32_ualpha(&paint->value.color, 0));
+                    return g_snprintf(b, len, "%s:%s;", key, color_buf);
+                }
                 case SP_PAINT_TYPE_PAINTSERVER:
                     return g_snprintf(b, len, "%s:url(%s);", key, paint->value.paint.uri);
-                    break;
                 default:
                     break;
             }