From a50c92abb67c3086a56c754cfb14a8873eaee6eb Mon Sep 17 00:00:00 2001 From: John Darrington Date: Fri, 11 Jan 2013 15:26:58 +0100 Subject: [PATCH] Simplify creation of pango layout in xr driver. Create the layouts with pango_cairo_create_layout instead of pango_layout_new. This seems simpler and avoids a kludge. Reviewed-By: Ben Pfaff --- src/output/cairo.c | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/src/output/cairo.c b/src/output/cairo.c index cd8f0b0e99..89013c2a0c 100644 --- a/src/output/cairo.c +++ b/src/output/cairo.c @@ -299,40 +299,15 @@ xr_allocate (const char *name, int device_type, struct string_map *o) return xr; } -static bool -xr_is_72dpi (cairo_t *cr) -{ - cairo_surface_type_t type; - cairo_surface_t *surface; - - surface = cairo_get_target (cr); - type = cairo_surface_get_type (surface); - return type == CAIRO_SURFACE_TYPE_PDF || type == CAIRO_SURFACE_TYPE_PS; -} - static bool xr_set_cairo (struct xr_driver *xr, cairo_t *cairo) { - PangoContext *context; - PangoFontMap *map; int i; xr->cairo = cairo; cairo_set_line_width (xr->cairo, xr_to_pt (xr->line_width)); - map = pango_cairo_font_map_get_default (); - context = pango_font_map_create_context (map); - if (xr_is_72dpi (cairo)) - { - /* Pango seems to always scale fonts according to the DPI specified - in the font map, even if the surface has a real DPI. The default - DPI is 96, so on a 72 DPI device fonts end up being 96/72 = 133% - of their desired size. We deal with this by fixing the resolution - here. Presumably there is a better solution, but what? */ - pango_cairo_context_set_resolution (context, 72.0); - } - xr->char_width = 0; xr->char_height = 0; for (i = 0; i < XR_N_FONTS; i++) @@ -340,7 +315,7 @@ xr_set_cairo (struct xr_driver *xr, cairo_t *cairo) struct xr_font *font = &xr->fonts[i]; int char_width, char_height; - font->layout = pango_layout_new (context); + font->layout = pango_cairo_create_layout (cairo); pango_layout_set_font_description (font->layout, font->desc); pango_layout_set_text (font->layout, "0", 1); @@ -349,8 +324,6 @@ xr_set_cairo (struct xr_driver *xr, cairo_t *cairo) xr->char_height = MAX (xr->char_height, char_height); } - g_object_unref (G_OBJECT (context)); - if (xr->params == NULL) { int single_width, double_width; -- 2.30.2