Re: How to use a monospace font in a Gtk::Label?



On Fri, 4 May 2007 07:48:55 +0200 (CEST)
Chris Dams mi infn it wrote:

> Could somebody please tell me how I can use a monospace font in a
> Gtk::Label? Browsing Pango documentation does not seem to lead to
> enlightenment with respect to this question within a reasonable amount of
> time.

I did it (in C/Gtk rather than Gtkmm, but the principle is the same)
like this:

  static const char ValueMarkup[] =
                       "<span font_desc=\"mono 24\">%6s%s</span>";

     G_Value[cc] = gtk_label_new ( NULL );
     sprintf ( markup, ValueMarkup, "--", ValueCoding[cc].Units );
     gtk_label_set_markup ( GTK_LABEL(G_Value[cc]), markup );

The essence is to use Gtk::Label::set_markup and pass a Pango markup
with a mono font specified.



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