+/* Parse color information specified by KEY into {RED,GREEN,BLUE}.
+ Currently, the input string must be of the form "#RRRRGGGGBBBB"
+ Future implementations might allow things like "yellow" and
+ "sky-blue-ultra-brown"
+*/
+void
+parse_color (struct output_driver *d, struct string_map *options,
+ const char *key, const char *default_value,
+ struct xr_color *color)
+{
+ int red, green, blue;
+ char *string = parse_string (opt (d, options, key, default_value));
+
+ if (3 != sscanf (string, "#%04x%04x%04x", &red, &green, &blue))
+ {
+ /* If the parsed option string fails, then try the default value */
+ if ( 3 != sscanf (default_value, "#%04x%04x%04x", &red, &green, &blue))
+ {
+ /* ... and if that fails set everything to zero */
+ red = green = blue = 0;
+ }
+ }
+
+ free (string);
+
+ /* Convert 16 bit ints to float */
+ color->red = red / (double) 0xFFFF;
+ color->green = green / (double) 0xFFFF;
+ color->blue = blue / (double) 0xFFFF;
+}
+
+static PangoFontDescription *
+parse_font (struct output_driver *d, struct string_map *options,
+ const char *key, const char *default_value,
+ int default_size)
+{
+ PangoFontDescription *desc;
+ char *string;
+
+ /* Parse KEY as a font description. */
+ string = parse_string (opt (d, options, key, default_value));
+ desc = pango_font_description_from_string (string);
+ if (desc == NULL)
+ {
+ msg (MW, _("`%s': bad font specification"), string);
+
+ /* Fall back to DEFAULT_VALUE, which had better be a valid font
+ description. */
+ desc = pango_font_description_from_string (default_value);
+ assert (desc != NULL);
+ }
+ free (string);
+
+ /* If the font description didn't include an explicit font size, then set it
+ to DEFAULT_SIZE, which is in inch/72000 units. */
+ if (!(pango_font_description_get_set_fields (desc) & PANGO_FONT_MASK_SIZE))
+ pango_font_description_set_size (desc,
+ (default_size / 1000.0) * PANGO_SCALE);
+
+ return desc;
+}
+
+
+static void
+apply_options (struct xr_driver *xr, struct string_map *o)