[cairo] Exact placement of a multiline pango layout

Stefan Salewski mail at ssalewski.de
Fri Oct 22 14:02:44 PDT 2010


On Fri, 2010-10-22 at 15:13 -0400, Behdad Esfahbod wrote:
> pango_layout_get_extents()?
> 
> On 10/22/10 14:51, Stefan Salewski wrote:
> > Hello,
> > 
> > I am drawing a multiline pango layout to a cairo surface, and I want
do
> > draw a rectangle around that text, giving something
> > ---------------
> > |Line 1       |
> > |Line two     |
> > |A longer Line|
> > ---------------
> > 

Yes, pango_layout_get_extents() gives me the rectangles. When i was
pondering about how I should apply the .x and .y value of the rectangle
(or the Ascent/Descent macro) I discovered that these values are always
zero for my current font, so adjusting with positive or negative sign
always gave the same result (which indeed is OK for my current font).
But I am not sure if .x and .y are always zero, for all fonts and all
layouts. From googling I got the impression that I may have to extract
the first line of the layout first, and then I may get an rectangle with
non zero .x and .y offset?

May be easy for experts -- not for me currently. Writing code, hope that
it is correct, and fix it when bug reports come may be a solution, but
that do not really make me happy.




More information about the cairo mailing list