objective c - NSImage lockFocus and NSString size on retina display -


I am facing a strange peculiarity, I am portrayed inside the NSIM using the following pseudo code :

  NSString * text = "Hello World!"; NSDictionary * dict = [[[NSDictionary alloc] initWithObjectsAndKeys: [NSColor colorWithCGColor: textColor], NSForegroundColorAttributeName, font, NSFontAttributeName, zero] autorelease]; NSMutableAttributedString * str = [[[NSMutableAttributedString alloc] initWithString: Text attributes: dict] Autoresalez]; NSSize stringSize = [str shape]; NSImage * image = [[[NSImage alloc] initWithSize: stringSize] Autorege]; [Image lockfocus]; NSRact Direct = NSMKAct (0,0, string sin. Wide, string sin high.); [Stretch drag: draw]; [Image Unlock Focus];  

The problem is now, with double monitors configuration, if I keep my retina display open, the string is confused (I have a half string drawn), while my bus is closed By using retina display and only using my cinema display, the string is properly crafted. It seems that the NSIEmage is getting the default reference and some scaling factors from the retina display.

Do you have any signs?

Thank you!

OK, I'll keep it for future reference, even displaying NSImage Something about that, which involves the same aspect.

There is no point what your primary performance is, but it seems that the NSGFinContext comes with an acine conversion that multiplies X2 to address retinal resolution.

You need to reset animation changes before drawing in NSImage:

  NSAffineTransform * trans = [[[NSAffineTransform alloc] init] autorelease]; [Trance set];  

Comments