Re: Font style in widget->size_request

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

 



The problem seems to be that you're using Cairo to render the text but use Pango to calculate the text extents. This doesn't make a lot of sense to me.

Just use Pango for everything, or just use Cairo for everything (it has functionality to determine extents of text layouts as well), that should fix the problem.

Sounds a little bit "bump on the head"-ish to just say it like this but it's really the only viable solution, because at the level you're doing this Pango and Cairo have nothing in common.

Regards,
M.

On Tue, Mar 24, 2009 at 7:18 PM, David Brigada <brigad@xxxxxxx> wrote:
Hello,

I am writing a graph widget for use in GTK+ applications.  I'm trying to calculate the minimum size for the widget from the text along the axes of the graph.  I use Cairo to draw the text, so I'm using the cairo_text_extents functions to calculate their sizes.

However, I'm running into a problem where widget->style->font_desc does not seem to be returning a valid Pango font description.  When I call pango_font_description_get_size on the font_desc, it returns 10 * PANGO_SCALE, which seems to be a default value when the style isn't initialized.  This causes my function to assume the incorrect font size when calculating its size request.  I tried calling gtk_widget_ensure_style on my widget before accessing the font_desc element, but that does not help.

Here's a code snippet:

static void gtk_graph_size_request(GtkWidget *widget,
               GtkRequisition *requisition)
{
       gdouble bfont_sz;
       /* ... */
       gtk_widget_ensure_style(widget);
       bfont_sz = pango_font_description_get_size(
                       widget->style->font_desc) /
               (gdouble)PANGO_SCALE;

       /* bfont_sz here is 10, for my theme, it should be 13.3 */

       /* ... */
}

I'm running GTK+ 2.14.7, (2.14.7-4+b1 as shipped by Debian sid), GLib 2.20.0 (2.20.0-2), ATK 1.24.0 (1.24.0-2), Pango 1.22.4 (1.22.4-3), and Cairo 1.8.6 (1.8.6-2+b1).

Let me know if you need any more information.  Thanks in advance for your help!

Thanks,
David Brigada
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list



--
Please note that according to the German law on data retention,
information on every electronic information exchange with me is
retained for a period of six months.
[Bitte beachten Sie, dass dem Gesetz zur Vorratsdatenspeicherung zufolge
jeder elektronische Kontakt mit mir sechs Monate lang gespeichert wird.]
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux