problems with glyph y-axis flipping in an NSBezierPath
problems with glyph y-axis flipping in an NSBezierPath
- Subject: problems with glyph y-axis flipping in an NSBezierPath
- From: Brad Werth <email@hidden>
- Date: Tue, 07 Aug 2001 12:49:43 -0700
- Organization: ORCAS, Inc.
I've been lurking for a bit to see if anyone else has experienced this
problem, but haven't seen anything yet, so I'm going to do my best to
formulate the difficulty:
I am trying to create an NSBezierPath containing some line art and some
text that can be drawn as needed when my subclass of NSCell is resized.
My NSCell subclass has two NSBezierPath instance variables -- one which
is filled and one which is stroked. The text glyphs are being added to
the NSBezierPath that gets filled. When drawing, the lines, rects,
ovals etc. are consitently correct, but the text is not: sometimes the
y-axis of the font is flipped such that a glpyh draws upside-down, but
at the same baseline. As if a mirror was placed under the letter.
It seems like it is some kind of coordinate system flipping problem.
The docs for NSFont fontWithName:matrix: talk about magic font matricies
that will display correctly in flipped or unflipped views. But my code
is using systemFontOfSize: which says it should always be correct.
Anyway, here's the relevant code:
NSFont *font = [NSFont systemFontOfSize:10.0f];
NSBezierPath *fontPath = [[NSBezierPath alloc] init];
// centerPoint is defined in the "real" code and works as expected
[fontPath moveToPoint:NSMakePoint(centerPoint.x, centerPoint.y)];
// likewise, glyphs is an array of the correct glyph followed by a
NULL, and works correctly
[fontPath appendBezierPathWithGlyphs:glyphs count:1 inFont:font];
// fillPath is an instance variable of the class, and has been
allocated/inited at this point
[fillPath appendBezierPath:fontPath];
[fontPath release];
Seems pretty straightforward, right? Perhaps this isn't even the right
bit of code to show you all -- still learning here. Anyway, sometimes
the glyph appears right side up, and sometimes upside down. If anyone
has any insight into why this is happening, please enlighten me.
Thanks,
Brad Werth
email@hidden