Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text render is less clear than AppKit(Subpixel rendering?) #67

Open
xhan opened this issue Sep 25, 2011 · 6 comments
Open

Text render is less clear than AppKit(Subpixel rendering?) #67

xhan opened this issue Sep 25, 2011 · 6 comments

Comments

@xhan
Copy link

xhan commented Sep 25, 2011

by using same font and fontSize LucidaGrande 14
Render effect on AppKit(using NSTextField)
AppKit
Render effect on Chameleon(tested with UILabel, UINSCellControl with NSTextFieldCell)
Chameleon
Let's zoom in (top one is rendered in AppKit)
diff

@BigZaphod
Copy link
Owner

Chameleon does not use subpixel smoothing when rendering text because it is implemented with CALayers (as is the real UIKit on iOS). Since each major part of a typical UIKit/Chameleon control is drawn into their own layers, there is no way to access the color information behind the text that's necessary to smooth the text in the way AppKit does. If you flatten your views manually by drawing everything (text, etc.) in drawRect:, you can turn on smoothing and have it work but then you're stuck not having any transparent backgrounds on your views and it changes how you do things pretty significantly.

On Sep 25, 2011, at 10:24 AM, xu han wrote:

by using same font and fontSize LucidaGrande 14
Render effect on AppKit(using NSTextField)
AppKit
Render effect on Chameleon(tested with UILabel, UINSCellControl with NSTextFieldCell)
Chameleon
Let's zoom in (top one is rendered in AppKit)
diff

Reply to this email directly or view it on GitHub:
#67

@jspahrsummers
Copy link

Subpixel antialiasing, as you mentioned, can be enabled any time you're drawing into an opaque background. Since everything eventually composites onto an opaque background, the easiest way to enable subpixel antialiasing is to avoid drawing and caching individual layers (or, at least, non-opaque layers).

This approach may or may not be possible with CALayer and the rendering employed in Chameleon, but we have some code in a Core Animation imitation framework that successfully employs this technique. It could be useful as a reference: https://github.com/joshaber/MoreAnimation/blob/master/Framework/MoreAnimation/MoreAnimation/Classes/MALayer.m#L835

@xhan
Copy link
Author

xhan commented Sep 26, 2011

Still not find a solution on how to enable Subpixel antialiasing on transparent context. next step I will try CGContextSetBlendMode to seem if it helps.
but I just noticed that TWUI has Sub-pixel text rendering enabled. not sure how they did it.

@Naituw
Copy link

Naituw commented Sep 26, 2011

TWUI can not get sub-pixel AA on transparent context too..

@xhan
Copy link
Author

xhan commented Sep 26, 2011

Found a quick-dirty solution so far, by adding a stroke around text with width 0.1.
This makes text feel more clean and a bit border.

@ghost
Copy link

ghost commented Oct 7, 2011

@ jspahrsummers even if I would do it more efficiently but I think you'll optimize your calls you are totally right

@xhan does something like pixel grid means something to you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants