Re: Finding width of a piece of text



> -----Original Message-----
> From: > Behdad Esfahbod
> Sent: Sunday, April 26, 2009 6:13 PM
> 
> On 04/26/2009 09:09 PM, Ian Puleston wrote:
> > I may well be wrong, but it seems to me that in this case it should
> not matter. Should 10-point courier font not be the same size no matter
> what it is printed on since a point is fixed at 1/72 inch? The "device
> unit" of a Pango layout is a point so it would seem logical that the
> text width being a certain number of points is the always going to be
> the same size. What am I missing here?
> 
> Font hinting.  The same font can have different widths when hinted vs
> not hinted.
> 
> > I can't use pango_cairo_create_layout() at this point because I don't
> yet know what print device it will be printed on.
> 
> Then at least 1) make sure your context is set to 72 dpi, and 2) set
> font
> options to disable metrics hinting.
> 
> behdad

I added a call to pango_cairo_context_set_resolution(ctx, 72) and that fixed it. I notice that the documentation for pango_cairo_context_set_resolution says "The default value is 96" which explains why the numbers were a bit too big.

The font option metric hinting probably isn't a problem for me because from what I read it seems to be to do with zooming and there isn't any zooming involved, but I added it anyway to be safe.

Thanks Behad.

Ian




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