Re: Setting fixed-width font

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

 



Hi,

Peter Krueger <pkrueger@xxxxxxxx> writes:

> 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.

You don't need to create a string representation of the font
description and fiddle with it since you can modify the font
description using the provided Pango API:

 http://developer.gnome.org/doc/API/2.0/pango/pango-Fonts.html

Basically you call

 pango_font_description_set_family (font_desc, "monospace");

Note that "monospace" is the preferred alias to use for a font with
fixed glyph widths. Which font is choosen depends on the user's font
configuration then. Any correct fontconfig installation is supposed to
provide at least one font for each of the "sans" "serif" and
"monospace" aliases.


Sven
_______________________________________________

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