High-quality offscreen rendering of text?

2013-10-06 Thread Jens Alfke
My little Mac font-preview app displays swatches of zillions of different fonts, which is expensive. To speed it up, I’m rendering each font’s preview text into an NSImage and caching that, then just blitting the image in the view’s -drawRect: method. The method I’m using is -[NSImage

Re: High-quality offscreen rendering of text?

2013-10-06 Thread Jiang Jiang
On Sun, Oct 6, 2013 at 10:15 PM, Jens Alfke j...@mooseyard.com wrote: (1) On a non-retina display, the text quality is poor. It looks like it’s drawn without sub-pixel anti-aliasing (“ClearType”). I do remember hearing that this mode is disabled for offscreen drawing, which makes sense because

Re: High-quality offscreen rendering of text?

2013-10-06 Thread Jens Alfke
On Oct 6, 2013, at 1:37 PM, Jiang Jiang gzjj...@gmail.com wrote: Could it be that you are missing a call to: CGContextSetShouldSmoothFonts(context, YES); If it still doesn't work, try putting CGContextSetAllowsFontSmoothing(context, YES); Thanks for the suggestion. But these calls don’t

Re: High-quality offscreen rendering of text?

2013-10-06 Thread Marcelo Alves
I don’t know if you know it, but “ClearType” / antialiasing in fonts works only on opaque images, you won’t have the best rendering method possible if your background is transparent. (From CATextLayer documentation, but I think it applies to the entire OS as well, because it makes sense :

Re: High-quality offscreen rendering of text?

2013-10-06 Thread Jens Alfke
On Oct 6, 2013, at 9:23 PM, Marcelo Alves marcelo.al...@me.com wrote: I don’t know if you know it, but “ClearType” / antialiasing in fonts works only on opaque images, you won’t have the best rendering method possible if your background is transparent. Thanks! That was the problem. In the