Re: determining character width



On Fri, Jul 12, 2002 at 10:21:37AM -0400, Allin Cottrell wrote:
That is, pango is not using the correct (monospaced) font in its
calculations. This seems weird, since prior to doing
pango_layout_set_text() I have initialized the layout using
gtk_widget_get_pango_context(widget), where the widget in question has
already been processed with gtk_widget_modify_font() to apply the
monospaced font (and the text comes out in the right font on screen).

Ah!  That's a step in the right direction, though-- get_pango_context()
must not use the font applied with modify_font()... (*checks*) yep.

Sorry for leading you in the wrong direction... modify_font() actually
modifies the widget's "modifier style" (see
gtk_widget_get_modifier_style()) and not the basic font.

It looks like something like this might work:

PangoContext *pc;
GtkRCStyle *style;

pc = gtk_widget_create_pango_context(widget);
style = gtk_widget_get_modifier_style(widget);
pango_context_set_font_description(pc, style->font_desc);

and then unref the context when you're done.

(I also realize that my previous mail was totally wrong about unreffing
the pango context, because with _get_pango_context() the widget holds
the reference.  Sorry!)

-- 
      Evan Martin
martine cs washington edu
  http://neugierig.org



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