Re: pango_layout_iter_get_char_extents()



Havoc Pennington <hp redhat com> writes:

> Sven Neumann <sven gimp org> writes: 
> > That's what I would have guessed. However it looks as if 
> > pango_layout_iter_next_cluster() iterates line by line inserting
> > an extra cluster at the end of the line. This is prooven by the
> > extents returned by pango_layout_iter_get_cluster_extents() which
> > alternatingly give the extents of a whole line and zero-wide 
> > rectangles.
> 
> Yes, that's right. The reason for this is to handle empty lines or
> something, I don't remember. I agree it's a bit weird.

For Sven's operation, it sounds like he should call 
pango_layout_set_single_paragraph_mode(), since there is nothing
reasonable to do with multiple lines.

> > > A cluster is a block of characters represented by a single font glyph.
> > > So say I have two characters, "a" and "add an accent to the previous
> > > char", those combine into the "a with accent" char. This is why char
> > > width is cluster_width/chars_in_cluster, because you divide the font
> > > glyph among the chars that motivated the glyph.
> > 
> > if this is the case, pango_layout_iter_get_char_extents() makes no 
> > sense at all. The extents returned are useless and the function should 
> > be removed (probably together with pango_layout_iter_next_char()).
> > 
> 
> IIRC cluster-splitting cases may happen from time to time, if
> graphemes and clusters are not identical for some reason.
> 
> That is, some languages may allow you to do the equivalent of
> selecting the accent but not the letter the accent is over the top of.

This actually will never be allowed by Pango, but there are other less
exotic possibilities where a cluster might correspond to multiple
graphemes.

Simple case being a 'fi' ligature.

Just iterate by characters, adding up the widths until it gets too wide,
and when run over in width, back up to the last grapheme boundary.

Regards,
                                        Owen




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