Re: Setting fixed-width font
- From: Sven Neumann <sven gimp org>
- To: Peter Krueger <pkrueger appss de>
- Cc: gtk-list gnome org, "Egon Andersen, Talura" <post talura dk>
- Subject: Re: Setting fixed-width font
- Date: 26 Sep 2003 17:17:32 +0200
Hi,
Peter Krueger <pkrueger appss de> 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]