how to get the width(in pixels) of a font
- From: Chandra Shekar Sengupta <sengupta tataelxsi co in>
- To: <gtk-app-devel-list gnome org>
- Subject: how to get the width(in pixels) of a font
- Date: Thu, 28 Jun 2007 18:46:32 +0530
hi
i am using GtkLabel for displaying some text where i have set font family
and font size. Before displaying the label, i want to set the width of the
label depending on the characters present int the text. I want to determine
the width(in pixels) of each character present in the text and add them to
get the width of the string.
My code is given bellow:
PangoFontDescription* font;
GtkWidget* label;
char* text;
int width;
font = pango_font_description_from_string("Arial 24");
if( NULL != font)
{
pango_font_description_set_weight(font,PANGO_WEIGHT_BOLD);
}
gtk_widget_modify_font(label,font);
strcpy(text,"abcijk");
gtk_label_set_text (label,text);
width= function_for_determining_width_of_text_in_pixels(text);
gtk_widget_set_size_request(label,width,20);
i want to know how to get the width of a character of a certain font family
and font size,so that i can implement the
function_for_determining_width_of_text_in_pixels();
Thanks in Advance.
Regards,
Chandra Shekhar Sengupta.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]