Skip navigation.
 
mlNSLayoutManager background and glyphs do not line up
FROM : Dave Dribin
DATE : Wed Jan 01 23:12:00 2003

Hello,

I am trying to use NSTextStorage, NSTextContainer, and NSLayoutManager
to draw some text for a custom view.  Here is how I am drawing in
drawRect:

    NSRange glyphRange = [_layoutManager glyphRangeForTextContainer:
_textContainer];
    [_layoutManager drawBackgroundForGlyphRange: glyphRange
                                        atPoint: NSMakePoint(0, 0)];
    [_layoutManager drawGlyphsForGlyphRange: glyphRange
                                    atPoint: NSMakePoint(0, 0)];

I am setting the line fragment padding in the text container to 0.  The
background color of the text in the text storage is red.  When drawn,
the background and glyphs (text) do not line up.  The red background
looks like it is in the correct position in the lower left corner, but
the text looks like it's moved up by about half the line height. 
Here's a image to help explain:

  http://www.dribin.org/dave/text.png

I did some searching and found that text views work better (only?) if
flipped.  Sure enough, if I make the custom view flipped, then the text
and background line up correctly, in the upper left corner.  I would
like to keep the view not flipped.  Is there anything I can do?

-Dave


Related mailsAuthorDate
mlNSLayoutManager background and glyphs do not line up Dave Dribin Jan 1, 23:12
mlRe: NSLayoutManager background and glyphs do not line up Douglas Davidson Jan 2, 09:58
mlRe: NSLayoutManager background and glyphs do not line up Dave Dribin Jan 2, 11:42
mlRe: NSLayoutManager background and glyphs do not line up Douglas Davidson Jan 2, 11:56
mlRe: NSLayoutManager background and glyphs do not line up Dave Dribin Jan 2, 14:07
mlRe: NSLayoutManager background and glyphs do not line up Douglas Davidson Jan 2, 14:19
mlRe: NSLayoutManager background and glyphs do not line up Dave Dribin Jan 2, 15:14
mlRe: NSLayoutManager background and glyphs do not line up Hubert Figuiere Jan 2, 15:38
mlRe: NSLayoutManager background and glyphs do not line up Dave Dribin Jan 2, 19:13
mlRe: NSLayoutManager background and glyphs do not line up Hubert Figuiere Jan 3, 07:03
mlRe: NSLayoutManager background and glyphs do not line up Dave Dribin Jan 7, 19:32
mlRe: NSLayoutManager background and glyphs do not line up Dave Dribin Jan 12, 15:40