Re: Setting fixed-width font

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

 



Hi Egon,
> I have a widget (actually a GtkLabel, but it may be changed later) for
> which I want use fixed-width font.
>
> Is there a simple way to achieve this?
yes it is. You can modify the font of any widget like this:

  PangoFontDescription *font_desc = pango_font_description_from_string(
    "Fixed 12");
  gtk_widget_modify_font(pGTKLabel, font_desc);
  pango_font_description_free(font_desc);

This will completely override the old font attributes. If you only want to
change the font from "Helvetica" or whatever it is to "Fixed" and keep the
other attributes (style and font size) but you don't already know
them, this is a bit more complicated. I never tried it, but I think
something like this could work:
First you must get the current PangoFontDescription from the
widget's style. Then get the description string for it ( char*
pango_font_description_to_string(const PangoFontDescription *desc); ) and
exchange the font name with "Fixed". When you got that you can
create a new PangoFontDescription and modify the widget as explained
above.

Regards...Peter
-- 
====================================================================
Peter Krüger

applied software solutions (appss) GmbH
Sandtorstr. 23
D-39106 Magdeburg
Germany

Phone:  +49-(0)391-54486-19388
Fax:    +49-(0)391-54486-19222
email:  krueger@xxxxxxxx
URL:    http://www.appss.de

Managing Director: Uwe Hess, Dietmar Schäfer
Register: HRB12386, AG Mageburg

"Virtual business becomes reality!"

This e-mail may contain confidential and/or privileged information. If
you are not the intended recipient (or have received this e-mail in
error) please notify the sender immediately and destroy this e-mail. Any
unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
====================================================================

_______________________________________________

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