FROM : Douglas Davidson
DATE : Mon Feb 18 19:44:15 2008
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
DATE : Mon Feb 18 19:44:15 2008
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
| Related mails | Author | Date |
|---|---|---|
| Keith Blount | Feb 18, 13:25 | |
| Douglas Davidson | Feb 18, 19:44 | |
| Keith Blount | Feb 18, 20:53 | |
| Douglas Davidson | Feb 18, 21:53 | |
| Keith Blount | Feb 19, 14:01 |






Cocoa mail archive

