From: Ben Pfaff Date: Mon, 22 Mar 2010 04:06:44 +0000 (-0700) Subject: psppire: Use default GTK+ font in output shown in GUI. X-Git-Tag: sav-api~334 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp;a=commitdiff_plain;h=43ed0a7cbd9cd3795bba6f3e6dbbae457fd0d269 psppire: Use default GTK+ font in output shown in GUI. This makes the output look more consistent with the rest of the interface. I didn't see an easy way to get a "default" monospace font. GTK+ doesn't seem to have one. Reported by John Darrington. --- diff --git a/src/output/cairo.c b/src/output/cairo.c index 6eb39b276b..977a414420 100644 --- a/src/output/cairo.c +++ b/src/output/cairo.c @@ -959,15 +959,9 @@ struct xr_rendering #define CHART_HEIGHT 375 struct xr_driver * -xr_create_driver (cairo_t *cairo) +xr_create_driver (cairo_t *cairo, struct string_map *options) { - struct xr_driver *xr; - struct string_map map; - - string_map_init (&map); - xr = xr_allocate ("cairo", 0, &map); - string_map_destroy (&map); - + struct xr_driver *xr = xr_allocate ("cairo", 0, options); xr->width = INT_MAX / 8; xr->length = INT_MAX / 8; if (!xr_set_cairo (xr, cairo)) diff --git a/src/output/cairo.h b/src/output/cairo.h index bcbe8e097d..6fe3273300 100644 --- a/src/output/cairo.h +++ b/src/output/cairo.h @@ -23,9 +23,10 @@ struct chart_item; struct output_item; +struct string_map; /* Used by PSPPIRE to render in the GUI. */ -struct xr_driver *xr_create_driver (cairo_t *); +struct xr_driver *xr_create_driver (cairo_t *, struct string_map *options); struct xr_rendering *xr_rendering_create (struct xr_driver *, const struct output_item *, cairo_t *); diff --git a/src/ui/gui/psppire-output-window.c b/src/ui/gui/psppire-output-window.c index e217c0edca..3003fba837 100644 --- a/src/ui/gui/psppire-output-window.c +++ b/src/ui/gui/psppire-output-window.c @@ -216,7 +216,29 @@ psppire_output_submit (struct output_driver *this, cr = gdk_cairo_create (GTK_WIDGET (pod->viewer)->window); if (pod->xr == NULL) - pod->xr = xr_create_driver (cr); + { + const GtkStyle *style = gtk_widget_get_style (GTK_WIDGET (viewer)); + struct string_map options = STRING_MAP_INITIALIZER (options); + PangoFontDescription *font_desc; + char *font_name; + + /* Use GTK+ default font as proportional font. */ + font_name = pango_font_description_to_string (style->font_desc); + string_map_insert (&options, "prop-font", font_name); + g_free (font_name); + + /* Derived emphasized font from proportional font. */ + font_desc = pango_font_description_copy (style->font_desc); + pango_font_description_set_style (font_desc, PANGO_STYLE_ITALIC); + font_name = pango_font_description_to_string (font_desc); + string_map_insert (&options, "emph-font", font_name); + g_free (font_name); + pango_font_description_free (font_desc); + + pod->xr = xr_create_driver (cr, &options); + + string_map_destroy (&options); + } r = xr_rendering_create (pod->xr, item, cr); if (r == NULL)