diff options
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-src/src/Color.cpp')
-rw-r--r-- | Build/source/texk/dvisvgm/dvisvgm-src/src/Color.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/Color.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/Color.cpp index 916403c859b..aa6b90b4063 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/Color.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/Color.cpp @@ -222,6 +222,9 @@ Color Color::operator *= (double c) { } +/** Returns an RGB string representing the color. Depending on the + * color value, the string either consists of 3 or 6 hex digits + * plus a leading '#' character. */ string Color::rgbString () const { ostringstream oss; oss << '#'; @@ -229,7 +232,15 @@ string Color::rgbString () const { oss << setbase(16) << setfill('0') << setw(2) << (((_rgb >> (8*i)) & 0xff)); } - return oss.str(); + // check if RGB string can be reduced to a three digit hex value + // #RRGGBB => #RGB, e.g. #112233 => #123 + string hexstr = oss.str(); + if (hexstr[1] == hexstr[2] && hexstr[3] == hexstr[4] && hexstr[5] == hexstr[6]) { + hexstr[2] = hexstr[3]; + hexstr[3] = hexstr[5]; + hexstr.resize(4); + } + return hexstr; } |