I'm not sure that depth is a good name as it according to the MetaFont book page 101 describes the distance from the baseline of a character to the bottom of the character bounding box. Since both pango and cairo work in a top-bottom coordinate system, the depth is usually not what is needed but rather the "distance_from_top_of_the logical_rect_to_baseline" but that is a bit long to type. Perhaps just "get_top_baseline_pos": /** * Returns the "baseline" of a layout, that is the distance from the * top of the layout to the baseline of the first line in the * layout. */ int pango_layout_get_top_baseline_pos(PangoLayout *layout) { PangoLayoutLine *layout_line = pango_layout_get_line(layout,0); PangoRectangle rect; pango_layout_line_get_extents(layout_line, NULL, &rect); return PANGO_ASCENT(rect); } The terminology is problematic for vertical layouts though... Regards, Dov On 2/3/07, Owen Taylor <otaylor@xxxxxxxxxx> 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); > > 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; > > It might be handy to have a convenience function to get this - > pango_layout_get_depth(), say, to steal terminology from TeX. > > - Owen > > > _______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list