Re: pango_layout_get_size() return 0



Hi,

Robert Roebling t-online de (Robert Roebling) writes:

> I have some code that enumerates Pango font families
> and then calculates the widths of some text (actually
> only some characters). The problem I have is that
> pango_layout_get_size() return 0 width for many
> font families (even Sans) so I must be doing something
> wrong. The code is as simple as this:

gtk-devel-list is about development of GTK+, not development with
GTK+. Such questions should be asked on gtk-list or gtk-app-devel-list
instead.
 
>         PangoFontFamily **families = NULL;
>         gint n_families = 0;
>         pango_context_list_families( context,  &families, &n_families
> );
> 
>         for (int i=0; i<n_families; i++)
>         {
>             const gchar *name = pango_font_family_get_name( families[i]
> );
>             
>             if (true)
>             {
>             
>                 PangoFontDescription *desc =
> pango_font_description_new();
>                 pango_font_description_set_family( desc, name );
>                 pango_font_description_set_size( desc, 12 );

you are setting a font size of 0.01172 pixels here so it isn't
surprising that the layout gets rendered pretty small. Pango uses
units of 1/1024 pixels. Try this instead:

 pango_font_description_set_size( desc, 12 * PANGO_SCALE );


Salut, Sven



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