[cairo] Bounding boxes for text

Kieran McCusker kieran.mccusker at kwest.info
Mon Jan 10 10:45:26 PST 2011


Hi

Could I just ensure that I'm not going mad? I'm creating PDFs with tight 
bounding boxes for multi-line text. What I do at the moment is (code 
snippet in ruby) :-

     while true

       @cr.update_pango_layout(@layout)
       layout_ink_rect, layout_logical_rect = @layout.extents
       ink_width = layout_ink_rect.x.abs + layout_ink_rect.width

       break if ink_width<= width

       @layout.width -= layout_ink_rect.x.abs

     end

     layout_ink_rect, layout_logical_rect = @layout.extents


I have to do this as otherwise my text will overlap my bounding box as, 
especially for italic text, layout_ink_rect.x.abs will be negative and I 
will have to move my drawing position to the right.
This will cause the text to overlap the right hand side of the bounding box.

Is this the correct way to do this in cairo?

Many Thanks

Kieran

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20110110/6eeb239f/attachment.html>


More information about the cairo mailing list