Re: Pango Font Scaling

On Sat, 2004-08-14 at 23:07, Haran Shivanan wrote:
> Hi,
> I'm having problems understanding how font scaling works in Pango.
> I have a box into which I'm rendering a PangoLayout object.
> When I double the size of the box, I need the font to be scaled by both 
> height and width accordingly.
> At first I naively tried just pango_font_description_set_size(...) with a 
> size twice as large but this doesn't work.

Doesn't work how? It should be "approximately" twice as large, with
a bit of fuzz from hinting to integer pixel sizes. Unless you
are using bitmap fonts.

> If I understand correctly, 
> (shape of a font at size X)*2 != (shape of font at size 2X)
> Is this correct?
> How can I get what I want?
> I essentially need to "zoom in" to the layout.

If you want linear scaling, you need to turn off hinting -- which
requires using a separate font map. Unfortunately, that does require
using the FT2 backend, since there is only one fontmap per screen
for Xft.

For FT2, turning off hinting looks like:


/* This function gets called to convert a matched pattern into what
 * we'll use to actually load the font. We turn off hinting since we
 * want metrics that are independent of scale.
static void
substitute_func (FcPattern *pattern, gpointer   data)
        FcPatternDel (pattern, FC_HINTING);
        FcPatternAddBool (pattern, FC_HINTING, FALSE);

pango_ft2_font_map_set_default_substitute (ft2fontmap, 
                                           NULL, NULL);


Attachment: signature.asc
Description: This is a digitally signed message part

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