cairo: text on multiple lines in diferent positions and widths



   Hello.
   I have various lines that start at diferent positions and have
diferent lengths (widths) and I want to put some user text (paragraph)
on them with wordwrapping and some alignment; I am using Cairo to draw
on a GtkDrawingArea and I got the lines and other things drawed correctly but the text part is dificult.
   ASCII art may come handy :-), here is a paragraph:

   _____________
 ______
          ________


   I want the users to be able to specify:
      - the text of the paragraph.
      - the font.
      - the type of alignment: left, right, center, justify (by the
doc. it seems Pango doesn't implement justify yet is that true?).
      - maybe other properties in the future.

   I am a bit lost after reading the Pango and Cairo documentations,
maybe someone can point me in the right direction for doing this or has
some clues.
   With pango it seems that I can specify only a single width and it
does the work to do the wordwrapping, alignment, etc. but in my paragraphs the widths are diferent on every line. It seems that Pango also has support for indentation but I don't see that it can be specified for diferent lines... though maybe I could do it with attributes and pango_attr_shape_new() but I don't see how: I would need to specify spaces at the beginning and the end of the line to obtain the real width of the line but with the attributes I can put them between two characters and are not for specifing properties of the visual layout.
   What it would be somewhat ideal for me is to just specify a diferent
width for every line and have Pango layout the text for me (doing the
wordwrapping) then I could just iterate over the Pango lines and draw
them in the required positions.
   In an ideal world though, Pango would layout the text over the lines
I specify to him with xstart, ystart, xend, yend positions ;-) or maybe
just follow a group of Cairo paths! ;-)
Maybe the only solution is to set the width for the first line and get the first line that Pango was able to put into it and write it (draw it), then get the remaining text and repeat for the second line, etc. after all lines have been written or no more text is available.
   Is there something easier than that?
   Thanks for your help.


--
Ivan Baldo - ibaldo adinet com uy - http://ibaldo.codigolibre.net/
ICQ 10215364 - Phone/FAX (598) (2) 613 3223.
Caldas 1781, Malvin, Montevideo, Uruguay, South America, planet Earth.
In favour of world peace and freedom, against U.S.A. and allies!!!
Alternatives: ibaldo codigolibre net - http://go.to/ibaldo






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]