How do I get X,Y pos and PangoLogAttr of each glyph in a rendered string?



Hello,

I'm using a really basic Cairo Pango prog as a test bed. It just displays a short string on a Cairo surface using a Pango layout, which works fine.

For each glyph in the string, I now want to get it's X,Y pos (and width and height) on the rendered Cairo surface, and the PangoLogAttr data, e.g. so I could draw a box around each glyph, or whatever.

After a lot of reading the API stuff, and googling for examples, I'm not quite sure how to tie the API functions together to achieve this. Anyone got any suggestions, ideas, or code please?

Pseudocode for what I'm trying to do would be:

1. Render Pango text to Cairo surface (note: could be right-to-left, e.g. Arabic, as well as left-to-right) - Done this.

2. For each glyph (or ligature) in the line of text:
    {
    3. Get X, Y, Width and Height of rendered glyph (or ligature)
    4. Get the PangoLogAttr structure for the same character
    5. Move onto the next glyph (/ligature/character) in the line
    }

P.S. As a separate side note, I understand glyphs to be the separate components of a final rendered character, i.e. the main body and diacritic (if present) would be separate glyphs. Each glyph in turn could possibly be made up of more than one UTF-8 character. The rendering engine can potentially combine certain combinations of glyphs to form a single ligature. Glyphs or ligatures can also be referred to as characters (so PangoLogAttr applies to ligatures and glyphs?). Have I got this right!?

Any help much appreciated :)

Many thanks indeed!
Alex





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