Re: go from PangoGlyphItemIter to an index into a PangoLogAttr ?



> My main problem, which I have partially solved, is how to iterate
> through a layout (line by line, run by run, and then glyphitem by gitem)
> and keep the log_attributes I get from the layout in sync with my
> iteration.
> 
> I noticed that when I change the set_width() of my layout, the number of
> characters in the layout/log_attr array changes.  Why is that? 
> I was surprised when I found this out...but still don't know how it
> changes the character count.  Is there now an extra char in my log_attr
> for every line or run or some mixture?  I ran some tests where I
> increment my index into the log_attr array for each line or run, but did
> not see any regularity.   My solution for now is to not set_width on the
> layout.
> 
> I've also tried to get an index into the log_attr array using
> log_attr[glyphitemiter.glyph_item.glyphs.log_clusters[i]] 
> 
> where "i" is incremented for every call to next_cluster()
> 
> however, this does not work ( at least not when you set_width on the
> layout).

I think I can narrow my question down a bit.  I the pango docs for
pango_layout_get_log_attr() it says:

n_attrs: location to store the number of the attributes in the array.
(The stored value will be one more than the total number of characters
 in the layout, since there need to be attributes corresponding to both
 the position before the first character and the position after the last
 character.) 

So, when I do this, I know the number of characters in the layout.  I
can also count the number of characters in the source text fed into the
layout.  However, what I don't know is the correlation between the  #
characters in the layout and the # characters in the source text.  They
are not the same.

-august.




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