Lefora Free Forum
login join
Loading
1365 views

NSString drawAtPoint/drawInRect

Page 1
1–2
rookie - member
1 posts

Hello.
I've spent whole day but still can't find a solution...
I'm drawing NSString in NSView intance using method drawInRect:withAttributes
Current code:
 NSFont *slFont = [[NSFontManager 
  sharedFontManager]
  fontWithFamily:@"Courier"
  traits:NSBoldFontMask
  weight:9 size:16.0];
 NSDictionary *attr =
  [NSDictionary dictionaryWithObjectsAndKeys: 
  slFont, NSFontAttributeName,
  [NSColor greenColor], NSForegroundColorAttributeName,
  nil ];

 bounds = [self bounds];
 bounds.origin.y -= 64;
 [@"Hello World" drawInRect:bounds withAttributes:attr];
But it's drawing text with sharp edged font.
Is it possible to get smoothed/antialiased text?
I know there exists Bezier path techniques, but I would not like to use them, because source code becomes too large.


?
288 posts


I think you'll have set the antialias flag in the graphics context of the window with this code immediately before the call to drawInRect:withAttributes

[[[self window] graphicsContext] setShouldAntialias:YES];

__________________
Page 1
1–2

Locked Topic


You must be a member to post in this forum

Join Now!