Re: changing font, color, size, etc. in a GtkEntry
- From: Michael Cronenworth <mike cchtml com>
- To: gtk-app-devel-list gnome org
- Subject: Re: changing font, color, size, etc. in a GtkEntry
- Date: Tue, 05 Nov 2013 10:15:31 -0600
Eric Wajnberg wrote:
I simply want to modify the font, color, size, etc. of the characters entered
while they are typed in a GtkEntry. I am coding with GTK 2.24.0.
Looking around on the web, I found several possible functions to do that, some
of them seem to be specific to GTK3, however. I found - and tried to play with -
things like:
gtk_entry_set_attributes
gtk_widget_modify_text
gtk_widget_modify_base
gtk_widget_modify_font
gtk_widget_create_pango_layout
gtk_widget_create_pango_context
Some of them lead me to define and to argument a pointer to a struct of type
PangoFontDescription or GtkStyle. Hence, it seems that I also need to use
function like, e.g., pango_font_description_set_weight, etc., but I'm not fully
sure about this.
You are close. You need to use gtk_widget_modify_font(). You pass in a font
description created by:
PangoFontDescription *fontDesc =
pango_font_description_from_string( "monospace 10" );
This would set the entry text to a monospace-type font with 10 point size. Don't
forget to call pango_font_description_free() afterwards.
If you wish to change font while typing you need to connect to the
"key-press-event" signal on the GtkEntry widget and handle key presses that way.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]