On Sat, 2007-02-03 at 14:59 -0500, Owen Taylor wrote: > On Sat, 2007-02-03 at 21:48 +0200, Dov Grobgeld wrote: > > I > > In pango_cairo_show_layout() on the other hand, the layout logical > > upper left corner is aligned at the current cairo point when drawing, > > and I could not find any PangoLayout call that gets the distance from > > the top of the logical rectangle to the baseline position. Is this a > > bug, or did I miss something? > > Well, one easy way to do it is to just draw the first line of the > layout instead of the entire layout - since the y origin when drawing a > single line is at the baseline of the line. > > PangoLayoutLine *line = pango_layout_get_lines(layout)->data; > pango_show_layout_line(cr, line); Or: PangoLayoutLine *line = pango_layout_get_line(layout, 0); pango_cairo_show_layout_line(cr, line); > If you want to draw an entire layout with the first line positioned > at a particular y position, then you'd need to get the ascent of the > first line: > > PangoRectangle rect; > pango_layout_line_get_extents(line, NULL, &rect); > double ascent = (double)PANGO_ASCENT(rect) / PANGO_SCALE; Or: PangoLayoutIter *iter = pango_layout_get_iter (layout); double baseline = (double) pango_layout_iter_get_baseline (layout) / PANGO_SCALE; > It might be handy to have a convenience function to get this - > pango_layout_get_depth(), say, to steal terminology from TeX. > > - Owen > > -- behdad http://behdad.org/ "Those who would give up Essential Liberty to purchase a little Temporary Safety, deserve neither Liberty nor Safety." -- Benjamin Franklin, 1759 _______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list