CoreText font smoothing on a transparent background

空扰寡人 提交于 2019-12-10 15:07:50

问题


I'm trying to render using CoreText (appkit version) on a (semi-) transparent background, and as a result the edges aren't smooth.

Searching the web suggests that there's no solution to this problem, however I don't believe it because of one simple observation: if I create a CATextLayer containing the same string then the font is lovely and smooth.

I've tried setting the various 'allowed' settings to true and then working through the 16 possibilities that they offer. Some are better than others, this is what I have so far:

        CGContextSetAllowsAntialiasing(context, YES);
        CGContextSetAllowsFontSmoothing(context, YES);
        CGContextSetAllowsFontSubpixelPositioning(context, YES);
        CGContextSetAllowsFontSubpixelQuantization(context, YES);

        CGContextSetShouldAntialias(context, YES);
        CGContextSetShouldSmoothFonts(context, NO);
        CGContextSetShouldSubpixelPositionFonts(context, YES);
        CGContextSetShouldSubpixelQuantizeFonts(context, YES);

Can someone please tell me how to get the same results that CATextLayer achieves?

来源:https://stackoverflow.com/questions/14442498/coretext-font-smoothing-on-a-transparent-background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!