Font transform bug?
Font transform bug?
- Subject: Font transform bug?
- From: Timothy Larkin <email@hidden>
- Date: Sat, 31 Aug 2002 16:06:20 -0400
Create a custom view with the following as its drawRect method.
- (void)drawRect:(NSRect)rect
{
NSAffineTransform *t = [NSAffineTransform transform];
union {
NSAffineTransformStruct tStruct;
float matrix[6];
} trans;
NSFont *font;
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
NSRect r = NSMakeRect(100, 100, 100, 100);
[t scaleXBy:10 yBy:10];
trans.tStruct = [t transformStruct];
font = [NSFont fontWithName:@"Lucida Grande" matrix:trans.matrix];
[dict setObject:font forKey:NSFontAttributeName];
text = [[NSAttributedString alloc] initWithString:@"Hello world"
attributes:dict];
[dict release];
NSPoint point = NSMakePoint(200, 200);
[text drawInRect:r];
}
Now if the scaleXBy:yBy arguments in line 12 are the same, everything
works as expected. In this case, a 10 point font is created. However,
if the X and Y scaling factors are not the same, the glyphs are drawn
upside-down. Note that the proportions are correct; only the
orientation is wrong. For instance, if we have "[t scaleXBy:10
yBy:20]", the result is a narrow, tall font, with upside-down glyphs.
The glyphs are not rotated 180 degrees; they are vertically flipped.
I'm pretty sure the union works correctly. The example produces a
transform matrix of (10, 0, 0, 20, 0, 0).
Is this a bug, or am I missing something?
--
Timothy Larkin
Abstract Tools
Caroline, NY
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.