Re: GdkFont->Pango replacement
- From: Havoc Pennington <hp redhat com>
- To: Deepa Chacko Pillai <deepa chacko wipro com>
- Cc: desktop-devel-list <desktop-devel-list gnome org>
- Subject: Re: GdkFont->Pango replacement
- Date: 22 Feb 2002 12:02:13 -0500
Deepa Chacko Pillai <deepa chacko wipro com> writes:
>
> I am facing few problems when I replace gdk_draw_string with pango
> equivalents. I am using PangoLayout.
>
> * Earlier gdk_font_width () used to give the distance from the
> beginning of the current string to the point where the next string is to
> be drawn. The closest equivalent I found to this is
> pango_font_metrics_get_approximate_char_width (metrics). It gives the
> character width. Can I multiply this by the length of the string to get
> string width as given by gdk_font_width ()? Or is there any other way
> for doing this?
>
You need to rewrite the code to create the layout and call
pango_layout_get_pixel_extents() to get its size.
> * To replace gdk_draw_string (), I do the following
> GtkWidget *area;
> PangoLayout *layout;
> GdkPixmap *pixmap;
> layout = gtk_widget_create_pango_layout (area, "");
> pango_layout_set_text (layout, string, -1);
> gtk_paint_layout (area->style,
> pixmap,
> GTK_WIDGET_STATE (area),
> FALSE,
> NULL,
> area,
> NULL,
> x,
> y,
> layout);
That's right if the layout should be "themed", if it shouldn't be
themed then it should just be gdk_draw_layout() instead of
gtk_paint_layout().
You probably don't need the pixmap with GTK 2.
It all depends a bit on the specific code you are working on.
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]