Skip navigation.
 
mlRe: Height and location of text within a line in NSLayoutManager ignoring spacing?
FROM : Keith Blount
DATE : Mon Feb 18 20:53:33 2008

Many thanks for your reply, much appreciated. The trouble is that I don't just need the measurements of the text that is laid out in the text container, but also of the arbitrary control string that I am going to draw behind the text, using NSString's -drawWithAttributes:. Would I have to set up a separate layout manager to calculate all of the measurements for the control glyphs? (I suppose I could cache that information given that the control glyph attributes and thus sizes won't change.)
Many thanks,
Keith

----- Original Message ----
From: Douglas Davidson <<email_removed>>
To: Keith Blount <<email_removed>>
Cc: <email_removed>
Sent: Monday, February 18, 2008 6:44:15 PM
Subject: Re: Height and location of text within a line in NSLayoutManager ignoring spacing?


On
Feb
18,
2008,
at
4:25
AM,
Keith
Blount
wrote:

>

-
lineFragmentRectForGlyphAtIndex:effectiveRange:
in
combination 
>

with
-locationOfGlyphAtIndex:
this
is
better
and
does
give
me
the 
>

point
at
which
the
original
glyph
would
be
drawn.
However,
there 
>

seems
to
be
no
way
to
then
offset
this
for
the
new
character.
If

>

call
NSString's
-sizeWithAttributes:
on
the
control
character
I'm 
>

going
to
draw,
I
get
padding
above
and
below
the
character
in
that 
>

method
and
cannot
find
a
way
to
offset
that
so
that
it
will
then
get 
>

drawn
at
the
right
location.


The
key
methods
here
are
-
lineFragmentRectForGlyphAtIndex:effectiveRange:,
-
lineFragmentUsedRectForGlyphAtIndex:,
-locationOfGlyphAtIndex:,
and 
NSTypesetter's
-baselineOffsetInLayoutManager:glyphIndex:. 
It's

little
difficult
for
me
to
describe
all
of
the
relationships
between 
these
measurements
without
a
diagram,
but
you
should
be
able
to
try 
them
out
and
see
how
they
differ
in
all
of
the
various
cases
you're 
interested
in--paragraph
spacing,
line
spacing,
line
height
multiple, 
etc. 
The
line
fragment
rect
is
the
rect
within
which
the
line
was 
laid
out. 
The
used
rect
is
the
rect
within
that
actually
taken
up
by 
the
text,
including
some
forms
of
padding. 
The
baseline
offset
is
the 
distance
from
the
bottom
of
the
line
fragment
rect
to
the
baseline
for 
a
particular
glyph.

Douglas
Davidson






      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

Related mailsAuthorDate
mlHeight and location of text within a line in NSLayoutManager ignoring spacing? Keith Blount Feb 18, 13:25
mlRe: Height and location of text within a line in NSLayoutManager ignoring spacing? Douglas Davidson Feb 18, 19:44
mlRe: Height and location of text within a line in NSLayoutManager ignoring spacing? Keith Blount Feb 18, 20:53
mlRe: Height and location of text within a line in NSLayoutManager ignoring spacing? Douglas Davidson Feb 18, 21:53
mlRe: Height and location of text within a line in NSLayoutManager ignoring spacing? Keith Blount Feb 19, 14:01