[gtkmm] Text in DrawingArea



I would like to draw non-proportionnal text in a DrawingArea.
I started with the "Drawing Text" example from the online gtkmm book.
   http://www.gtkmm.org/gtkmm2/docs/tutorial/html/ch14s06.html

I can set the font by adding the following two lines at the beginning of
the expose event code:
   Pango::FontDescription fontDesc("Courier 12");
   modify_font(fontDesc);
But when I do that the expose event keeps being triggered. What is
wrong?

Then I would like to know the height and width of a character (it's a
non-proportional font). I though I could do it with something like:
   int w, h;
   Glib::RefPtr<Pango::Layout> pangolayout = create_pango_layout("?");
   pangolayout->get_size(w, h);
But since the font information seems to be in the DrawingArea rather
than in the PangoLayout, it can't give me a correct value and in fact
the values are wrong.

Looks like I could use some help (RTFM welcome).

Perhaps using pango is wrong in my case as I want to draw simple ascii
text without carriage returns.  

Thanks,
Christophe

-- 
Christophe Barbé <christophe barbe ufies org>
GnuPG FingerPrint: E0F6 FADF 2A5C F072 6AF8  F67A 8F45 2F1E D72C B41E

There's no sense in being precise when you don't even know what you're
talking about. -- John von Neumann



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