• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Non-Sub-Pixel Rendering Font Rendering Differences when using Core Animation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Non-Sub-Pixel Rendering Font Rendering Differences when using Core Animation


  • Subject: Re: Non-Sub-Pixel Rendering Font Rendering Differences when using Core Animation
  • From: Evadne Wu <email@hidden>
  • Date: Wed, 27 Apr 2011 13:41:37 +0800

This is a wild guess but it worked for me with Core Text on the iPad a long time ago.  One or several of these can probably work for you.

	• CGContextSetAllowsAntialiasing
	• CGContextSetAllowsFontSmoothing
	• CGContextSetShouldSmoothFonts
	• CGContextSetAllowsFontSubpixelPositioning
	• CGContextSetShouldSubpixelPositionFonts
	• CGContextSetAllowsFontSubpixelQuantization
	• CGContextSetShouldSubpixelQuantizeFonts

-ev

On Apr 27, 2011, at 12:45, Simone Manganelli wrote:

> I'm adding some Core Animation to my existing project, and I'm encountering some differences in the font rendering compared to non-Core Animation code.  Here's the code used to draw my strings:
>
>> NSShadow *selectedShadow = [[NSShadow alloc] init];
>> [selectedShadow setShadowOffset:NSMakeSize(0,-1)];
>> [selectedShadow setShadowColor:[NSColor colorWithCalibratedWhite:0.0 alpha:0.33]];
>> [selectedShadow autorelease];
>>
>> NSMutableParagraphStyle *leftAlignedEllipsisStyle = [[NSMutableParagraphStyle alloc] init];
>> [leftAlignedEllipsisStyle setAlignment:NSLeftTextAlignment];
>> [leftAlignedEllipsisStyle setLineBreakMode:NSLineBreakByWordWrapping];
>> [leftAlignedEllipsisStyle autorelease];
>>
>> NSDictionary *selectedAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
>> 					[NSFont systemFontOfSize:11.0], NSFontAttributeName,
>> 					[NSColor whiteColor], NSForegroundColorAttributeName,
>> 					selectedShadow, NSShadowAttributeName,
>> 					leftAlignedEllipsisStyle, NSParagraphStyleAttributeName,
>> 					nil];
>>
>> [someString drawWithRect:textRect
>> 		 options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin
>> 	      attributes:selectedAttributes];
>
> Here's the difference: http://homepage.mac.com/simx/images/antialiasing-diff.png
>
> On the left is text rendered in my existing project using the above code via the drawRect: method.  On the right is text rendered into a CALayer using the drawLayer:inContext: method.
>
> I'm aware of the fact that Core Animation disables sub-pixel rendering for text when drawing to transparent backgrounds, so I've intentionally designed my CALayers so that they have opaque backgrounds.  Sub-pixel rendering is definitely active now that I've drawn an opaque color to the layer.  This doesn't seem to be the issue, especially because the Core Animation text appears *heavier* than the normal Quartz text, whereas it usually appears more wispy when sub-pixel rendering is off.
>
> Nor does this seem to be an issue with half-pixels.  The selection bubble is rendering crisply (from image assets), which indicates that the layer is positioned correctly.  And the text itself isn't blurred, so the text is also positioned correctly.
>
> This almost looks as if a heavier kind of antialiasing is active on the text.  I recall that Mac OS X had four different types of antialiasing you could choose in the Appearance preference pane, but this preference is gone in more recent versions.  Could I be hitting that and somehow using some different form of antialiasing?
>
> Any help would be greatly appreciated.
>
> -- Simone
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Non-Sub-Pixel Rendering Font Rendering Differences when using Core Animation (From: Simone Manganelli <email@hidden>)

  • Prev by Date: Re: UI refresh in background thread while [NSTask waitUntilExit]
  • Next by Date: Re: BSD TCP Programming on iPad
  • Previous by thread: Non-Sub-Pixel Rendering Font Rendering Differences when using Core Animation
  • Next by thread: Re: Non-Sub-Pixel Rendering Font Rendering Differences when using Core Animation
  • Index(es):
    • Date
    • Thread