pspp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: font sizes


From: John Darrington
Subject: Re: font sizes
Date: Tue, 29 Jun 2010 14:18:26 +0000
User-agent: Mutt/1.5.18 (2008-05-17)

The function pango_cairo_create_context doesn't exist on the pango
version shipped with debian lenny.

I had to change it to :

  PangoFontMap *fm = pango_cairo_font_map_get_default ();
  PangoContext *context = pango_cairo_font_map_create_context 
(PANGO_CAIRO_FONT_MAP (fm));

Also, I suggest this is taken out of the for() loop.
Shouldn't we also unref context ?

J'


On Mon, Jun 28, 2010 at 09:36:32AM -0700, Ben Pfaff wrote:
     
     It would be great if you could do this.  For now the following
     kluge seems to fix it.  Do you think that this is OK for now?
     
     diff --git a/src/output/cairo.c b/src/output/cairo.c
     index 90ae60e..eb3c41a 100644
     --- a/src/output/cairo.c
     +++ b/src/output/cairo.c
     @@ -247,6 +247,17 @@ xr_allocate (const char *name, int device_type, 
struct string_map *o)
      }
      
      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)
      {
        int i;
     @@ -260,9 +271,20 @@ xr_set_cairo (struct xr_driver *xr, cairo_t *cairo)
        for (i = 0; i < XR_N_FONTS; i++)
          {
            struct xr_font *font = &xr->fonts[i];
     +      PangoContext *context;
            int char_width, char_height;
      
     -      font->layout = pango_cairo_create_layout (xr->cairo);
     +      context = pango_cairo_create_context (xr->cairo);
     +      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);
     +        }
     +      font->layout = pango_layout_new (context);
            pango_layout_set_font_description (font->layout, font->desc);
      
            pango_layout_set_text (font->layout, "0", 1);
     
     -- 
     Peter Seebach on managing engineers:
     "It's like herding cats, only most of the engineers are already
      sick of laser pointers."

-- 
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://pgp.mit.edu or any PGP keyserver for public key.


Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]