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
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






Cocoa mail archive

