How to set the font's size of the GtkLabel?

2008-08-28 Thread Lazy Fox
I wrote the following statememts to set a GtkLabel's font size.
But it seems don't work?
I'm not good at Pango, can anybody help me?
+---
| PangoAttrList *pg_attr_list = pango_attr_list_new();
| PangoAttribute *pg_attr = pango_attr_size_new(10);
|
| label = gtk_label_new(This is a label);
| pango_attr_list_change(pg_attr_list, pg_attr);
| gtk_label_set_attributes(GTK_LABEL(label), pg_attr_list);
+--
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to set the font's size of the GtkLabel?

2008-08-28 Thread Dov Grobgeld
Hi Lazy (great name),

The way to do it is to set the name of the label through:

gtk_widget_set_name(label, foo);

and then define a style for the name foo, that includes a font
specification:

gtk_rc_parse_string(style \foo\ {\n
  font = \Serif 32\\n
  }\n
  );

Hope this helps,
Dov

2008/8/28 Lazy Fox [EMAIL PROTECTED]

 I wrote the following statememts to set a GtkLabel's font size.
 But it seems don't work?
 I'm not good at Pango, can anybody help me?

 +---
 | PangoAttrList *pg_attr_list = pango_attr_list_new();
 | PangoAttribute *pg_attr = pango_attr_size_new(10);
 |
 | label = gtk_label_new(This is a label);
 | pango_attr_list_change(pg_attr_list, pg_attr);
 | gtk_label_set_attributes(GTK_LABEL(label), pg_attr_list);

 +--

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


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to set the font's size of the GtkLabel?

2008-08-28 Thread Tomas Carnecky
Dov Grobgeld wrote:
 Hi Lazy (great name),
 
 The way to do it is to set the name of the label through:
 
 gtk_widget_set_name(label, foo);
 
 and then define a style for the name foo, that includes a font
 specification:
 
 gtk_rc_parse_string(style \foo\ {\n
   font = \Serif 32\\n
   }\n
   );
 

Ugh, that's complicated. An easier way is:

GtkLabel *label = gtk_label_new();
gtk_label_set_markup(label, span font_desc=\10.0\This is a
label/span);

See http://library.gnome.org/devel/pango/stable/PangoMarkupFormat.html
how to use the pango markup language.

 
 2008/8/28 Lazy Fox [EMAIL PROTECTED]
 
 I wrote the following statememts to set a GtkLabel's font size.
 But it seems don't work?
 I'm not good at Pango, can anybody help me?

 +---
 | PangoAttrList *pg_attr_list = pango_attr_list_new();
 | PangoAttribute *pg_attr = pango_attr_size_new(10);
 |
 | label = gtk_label_new(This is a label);
 | pango_attr_list_change(pg_attr_list, pg_attr);
 | gtk_label_set_attributes(GTK_LABEL(label), pg_attr_list);

 +--

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


 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
 

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to set the font's size of the GtkLabel?

2008-08-28 Thread Dov Grobgeld
Hi Tomas,

You are certainly right The style method is more suited when you want to
change additional properties like background color, etc. I stand corrected.

Regards,
Dov

2008/8/28 Tomas Carnecky [EMAIL PROTECTED]

 Dov Grobgeld wrote:
  Hi Lazy (great name),
 
  The way to do it is to set the name of the label through:
 
  gtk_widget_set_name(label, foo);
 
  and then define a style for the name foo, that includes a font
  specification:
 
  gtk_rc_parse_string(style \foo\ {\n
font = \Serif 32\\n
}\n
);
 

 Ugh, that's complicated. An easier way is:

 GtkLabel *label = gtk_label_new();
 gtk_label_set_markup(label, span font_desc=\10.0\This is a
 label/span);

 See http://library.gnome.org/devel/pango/stable/PangoMarkupFormat.html
 how to use the pango markup language.

 
  2008/8/28 Lazy Fox [EMAIL PROTECTED]
 
  I wrote the following statememts to set a GtkLabel's font size.
  But it seems don't work?
  I'm not good at Pango, can anybody help me?
 
 
 +---
  | PangoAttrList *pg_attr_list = pango_attr_list_new();
  | PangoAttribute *pg_attr = pango_attr_size_new(10);
  |
  | label = gtk_label_new(This is a label);
  | pango_attr_list_change(pg_attr_list, pg_attr);
  | gtk_label_set_attributes(GTK_LABEL(label), pg_attr_list);
 
 
 +--
 
  ___
  gtk-list mailing list
  [EMAIL PROTECTED]
  http://mail.gnome.org/mailman/listinfo/gtk-list
 
 
  ___
  gtk-app-devel-list mailing list
  gtk-app-devel-list@gnome.org
  http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
 


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to set the font's size of the Gtklabel

2008-08-28 Thread Garth's KidStuff
Hey there,

Using Gtkmm

void ChangeLabelFontSize(


Glib::RefPtrPango::Context pPangoContext =
pLabel-get_pango_context();
Pango::FontDescription fontD =
pPangoContext-get_font_description();
fontD.set_size((int)(scale * fontD.get_size()));
pLabel-modify_font(fontD);


-- 
Garth Upshaw
Garth's KidStuff
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to set the font's size of the Gtklabel

2008-08-28 Thread Garth's KidStuff
Whops, hit the send button before I was finished..

the method should be:

void ChangeLabelFontSize(
Gtk::Label *pLabel,   // [in] Pointer to label to change font on
float scale)  // [in] amount to scale font size by.  1.0 leaves label
unchanged
{
Glib::RefPtrPango::Context pPangoContext =
pLabel-get_pango_context();
Pango::FontDescription fontD =
pPangoContext-get_font_description();
fontD.set_size((int)(scale * fontD.get_size()));
pLabel-modify_font(fontD);
}

-- 
Garth Upshaw
Garth's KidStuff
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to set the font's size of the Gtklabel

2008-08-28 Thread Lazy Fox
But I only use gtk api, not gtkmm. How to do this by gtk?

On Thu, Aug 28, 2008 at 9:50 PM, Garth's KidStuff
[EMAIL PROTECTED]wrote:

 Whops, hit the send button before I was finished..

 the method should be:

 void ChangeLabelFontSize(
Gtk::Label *pLabel,   // [in] Pointer to label to change font on
float scale)  // [in] amount to scale font size by.  1.0 leaves label
 unchanged
 {
Glib::RefPtrPango::Context pPangoContext =
 pLabel-get_pango_context();
Pango::FontDescription fontD =
 pPangoContext-get_font_description();
fontD.set_size((int)(scale * fontD.get_size()));
pLabel-modify_font(fontD);
 }

 --
 Garth Upshaw
 Garth's KidStuff
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




-- 
--
┏┓
┃菩提本无树,明镜亦非台。本来无一物,何处惹尘埃。┃
┗┛
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: How to set the font's size of the GtkLabel?

2008-08-28 Thread Lazy Fox
I find another way:
+-
| PangoFontDescription * desc = pango_font_description_new();
| pango_font_description_set_size(desc, 50*PANGO_SCALE);
| .
| .
| gtk_widget_modify_font(label, desc);
+-

Is this a better choice, or the pango markup language?


On 8/28/08, Dov Grobgeld [EMAIL PROTECTED] wrote:

 Hi Lazy (great name),

 The way to do it is to set the name of the label through:

 gtk_widget_set_name(label, foo);

 and then define a style for the name foo, that includes a font
 specification:

 gtk_rc_parse_string(style \foo\ {\n
   font = \Serif 32\\n
   }\n
   );

 Hope this helps,
 Dov

 2008/8/28 Lazy Fox [EMAIL PROTECTED]

 I wrote the following statememts to set a GtkLabel's font size.
 But it seems don't work?
 I'm not good at Pango, can anybody help me?

 +---
 | PangoAttrList *pg_attr_list = pango_attr_list_new();
 | PangoAttribute *pg_attr = pango_attr_size_new(10);
 |
 | label = gtk_label_new(This is a label);
 | pango_attr_list_change(pg_attr_list, pg_attr);
 | gtk_label_set_attributes(GTK_LABEL(label), pg_attr_list);

 +--

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







-- 
--
┏┓
┃菩提本无树,明镜亦非台。本来无一物,何处惹尘埃。┃
┗┛
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list