Re: Eeek! My fonts have the shrinks!



On 10 Sep 2003, Owen Taylor wrote:
> On Tue, 2003-09-09 at 18:37, Lars Clausen wrote:
>> Strangely, starting from Pango 1.2.4, Pango seems to render fonts in Dia
>> very, very small.  The default size (~11000 Pango units) is a single
>> pixel.  Setting a big font and zooming in, I get to 27 pixels high when
>> using 1146879 Pango units for the font height.  I'm using
>> pango_ft2_render_layout() for rendering, but I doubt that's to blame,
>> since pango_layout_get_pixel_size() agrees with the size given above.
>> The size is set with pango_font_description_set_size().  I'm mighty
>> confused and unhappy to have this turn up just before releasing a new
>> version.  Any clues or pointers would be appreciated.
>
> Nothing has intentionally changed. We've had another report of a problem
> (in the opposite direction ... fonts were too big) so maybe there is
> something going wrong in the code to handle DPI. I'd certainly like
> a test case.
>
> The main 1.2.3 => 1.2.4 change that seems relevant here is:
>
> Fri Aug  8 12:59:42 2003  Owen Taylor <otaylor redhat com>
>
> * pango/pangoft2-fontmap.c (pango_ft2_font_map_default_substitute):
> Move DPI substitution before FcDefaultSubstitute so
> it actually works.
>
> So, possibly the problem is that you were simply relying on fontconfig's
> default DPI value before and not setting it correctly yourself. 
>
> Hmm, are you using
> pango_ft2_font_map_new()/pango_ft2_font_map_create_context()
> the old pango_ft2_get_context()?

I'm indeed using the old pango_ft2_get_context().  Switching to the above
makes the font disappear entirely, but their height seems awfully big.

The layout is created with 

PangoLayout*
dia_font_build_layout(const char* string, DiaFont* font, real height)
{
    PangoLayout* layout;
    PangoAttrList* list;
    PangoAttribute* attr;
    guint length;

    height *= 0.7;

    dia_font_set_height(font,height);
    layout = pango_layout_new(pango_context);

    length = string ? strlen(string) : 0;
    pango_layout_set_text(layout,string,length);
        
    list = pango_attr_list_new();
    pango_font_description_set_family(font->pfd, g_utf8_strdown(pango_font_description_get_family(font->pfd), -1));
    attr = pango_attr_font_desc_new(font->pfd);
    attr->start_index = 0;
    attr->end_index = length;
    pango_attr_list_insert(list,attr); /* eats attr */
    
    pango_layout_set_attributes(layout,list);
    pango_attr_list_unref(list);

    pango_layout_set_indent(layout,0);
    pango_layout_set_justify(layout,FALSE);
    pango_layout_set_alignment(layout,PANGO_ALIGN_LEFT);
    {
      int lwidth, lheight;
      pango_layout_get_size(layout, &lwidth, &lheight);

      printf("Layout dia height %f pfd height %d layout height %d, width %d\n",
	     height, pango_font_description_get_size(font->pfd),
	     lheight, lwidth);
    }   
    return layout;
}

The final printf gives things like

Layout dia height 175.000000 pfd height 3583999 layout height 4096, width 2032

for a big font zoomed in all the way.  Is there something I should set that
I don't?

-Lars

-- 
Lars Clausen (http://shasta.cs.uiuc.edu/~lrclause)| HÃ¥rdgrim of Numenor
"I do not agree with a word that you say, but I   |----------------------------
will defend to the death your right to say it."   | Where are we going, and
    --Evelyn Beatrice Hall paraphrasing Voltaire  | what's with the handbasket?



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