Bug#296939: Debian bug follow up (Re: bug 296939)
Kevin B. McCarty
kmccarty at Princeton.EDU
Thu Apr 26 21:30:06 UTC 2007
tags 296939 + patch
thanks
Sven Arvidsson wrote:
> This is a follow up to Debian bug 296939.
> See http://bugs.debian.org/296939
>
> Hi,
>
> Does this bug still happen with pango version 1.16.2-1 (or later)
> on an up to date testing/unstable system?
I just looked at the source for gdk_color_parse and pango_color_parse in
the gtk+2.0 and pango1.0 source packages in unstable (respective
versions 2.10.11-2 and 1.16.2-2), and as far as I can see there was no
change to reintroduce the functionality I requested in this bug.
I've spent a few minutes to write the long-ago promised patch, in case
you want to submit it upstream. However, by this point I guess any
package that was going to be ported to gtk+2 already has been, so the
pango maintainers should feel free to downgrade this bug to "wishlist"
or close it if they want.
best regards,
--
Kevin B. McCarty <kmccarty at princeton.edu> Physics Department
WWW: http://www.princeton.edu/~kmccarty/ Princeton University
GPG: public key ID 4F83C751 Princeton, NJ 08544
-------------- next part --------------
--- pango-color.c.orig 2007-01-22 18:41:43.000000000 -0500
+++ pango-color.c 2007-04-26 17:27:38.000000000 -0400
@@ -206,6 +206,9 @@
* components of the color, respectively. (White in the four
* forms is '#fff' '#ffffff' '#fffffffff' and '#ffffffffffff')
*
+ * Hex values in the form 'rgb:#rr/#gg/#bb' are also accepted,
+ * with the same limit on the number of hex digits in each value.
+ *
* Return value: %TRUE if parsing of the specifier succeeded,
* otherwise false.
**/
@@ -213,23 +216,32 @@
pango_color_parse (PangoColor *color,
const char *spec)
{
+ int is_rgb_val, is_html_val;
g_return_val_if_fail (spec != NULL, FALSE);
+
+ is_rgb_val = (strncmp (spec, "rgb:", 4) == 0); /* assume rgb:RR/GG/BB */
+ is_html_val = (spec[0] == '#'); /* assume #RRGGBB */
- if (spec[0] == '#')
+ if (is_rgb_val || is_html_val)
{
- size_t len;
+ size_t len, offset = 0;
unsigned int r, g, b;
+ if (is_rgb_val) {
+ offset = 1; /* need this to deal with the internal slashes */
+ spec += 3;
+ }
+
spec++;
- len = strlen (spec);
+ len = strlen (spec) - 2 * offset;
if (len % 3 || len < 3 || len > 12)
return FALSE;
len /= 3;
if (!hex (spec, len, &r) ||
- !hex (spec + len, len, &g) ||
- !hex (spec + len * 2, len, &b))
+ !hex (spec + len + offset, len, &g) ||
+ !hex (spec + (len + offset) * 2, len, &b))
return FALSE;
if (color)
More information about the pkg-gnome-maintainers
mailing list