Re: getting extents of individual words in a layout
- From: Behdad Esfahbod <behdad behdad org>
- To: Theo Veenker <Theo Veenker let uu nl>
- Cc: gtk-i18n-list gnome org
- Subject: Re: getting extents of individual words in a layout
- Date: Tue, 19 Feb 2008 17:02:26 -0500
On Tue, 2008-02-19 at 22:33 +0100, Theo Veenker wrote:
> Hi,
>
> I need to know the extents of the individual 'words' in a layout
> object (for an eye-tracking experiment). I want to draw a rectangle
> around each word (in cairo) and also output the extents of each
> word numerically.
>
> Using an PangoLayoutIter I can walk over the layout lines and see
> each character/grapheme but I how do I relate the current iterator
> position to an index in the text? I need that in order to be able
> to detect spacing characters between the words.
>
> I also toyed with pango_layout_get_lines_readonly() and worked down
> to the actual glyphitems but that seems rather tedious.
You are on the right track. What's missing is an API to iterate over
glyphitems. That code exists in Pango internally. See:
http://bugzilla.gnome.org/show_bug.cgi?id=377948
It's pretty short. I suggest you copy/paste it for now.
When you get back to character offsets, you can use
pango_get_log_attrs() results to find word boundaries, etc.
> What would be the proper way to approach this?
>
> Thanks,
> Theo
--
behdad
http://behdad.org/
"Those who would give up Essential Liberty to purchase a little
Temporary Safety, deserve neither Liberty nor Safety."
-- Benjamin Franklin, 1759
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]