Pango help



Hello,

I am having some problems in displaying fonts properly using pango.

In the following code segment, I am displaying a text at a position (50,50) in a drawing area. For a font size of 24 and family=courier, i am NOT gettting the message displayed at the exact position (50,50). The starting of the text is displaced by some pixels from position 50,50. Also I noticed that the amount displacement varies with font size and type of the font used. Is there any method to ensure that the text gets displayed in the exact position 50,50 irrespective of font size/family/style/weight.

                                                                                                                          
pango_layout_set_font_description (layout, lFontDesc);
pango_layout_set_text(layout, "test message", 15 );
gdk_draw_layout (lWid->window, lWid->style->fg_gc[GTK_STATE_NORMAL],50,50, layout);

The full code for the font display routine is given below.


void g_pango_expose(GtkWidget *lWid, gpointer data)
{
gdk_draw_rectangle (lWid->window, lWid->style->fg_gc[GTK_STATE_NORMAL], FALSE, 50, 50, 130, 30);
                                                                                                                            
PangoContext *          context = NULL;
PangoLayout *           layout  = NULL;
context = gtk_widget_create_pango_context(lWid);
layout  = pango_layout_new(context);
                                                                                                                            
pango_layout_set_font_description (layout, lFontDesc);
pango_layout_set_text(layout, "test message", 15 );
gdk_draw_layout (lWid->window, lWid->style->fg_gc[GTK_STATE_NORMAL],50,50, layout);
                                                                                                                            
g_object_unref (layout);
}

Thanks in advance for the help
nerdy


Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]