Re: Height and location of text within a line in NSLayoutManager ignoring spacing?
Re: Height and location of text within a line in NSLayoutManager ignoring spacing?
- Subject: Re: Height and location of text within a line in NSLayoutManager ignoring spacing?
- From: Keith Blount <email@hidden>
- Date: Mon, 18 Feb 2008 11:53:33 -0800 (PST)
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@hidden>
To: Keith Blount <email@hidden>
Cc: email@hidden
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
I
>
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
a
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
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden