Re: Setting fixed-width font

2003-09-26 Thread Havoc Pennington
On Fri, 2003-09-26 at 07:05, Egon Andersen, Talura wrote:
> 
> 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?

Use gtk_widget_modify_font() to set the font to "monospace"

Havoc


___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Setting fixed-width font

2003-09-26 Thread Sven Neumann
Hi,

Peter Krueger <[EMAIL PROTECTED]> 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 mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Setting fixed-width font

2003-09-26 Thread Peter Krueger
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:  [EMAIL PROTECTED]
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 mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Setting fixed-width font

2003-09-26 Thread Egon Andersen
Hi,

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?

(I've looked in the FAQ and mail-archive. But it only described a 
solution using a resource file, which I don't want to use in this case.)

Best regards
Egon Andersen
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Setting fixed-width font

2003-09-26 Thread Egon Andersen, Talura
Hi,

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?

(I've looked in the FAQ and mail-archive. But it only described a 
solution using a resource file, which I don't want to use in this case.)

Best regards
Egon Andersen
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list