1

我在 iPad SDK 上使用自定义像素字体,并试图找到一种方法来禁用 UIFont 的字体抗锯齿功能。像素字体通常在没有抗锯齿时效果最好。当我创建静态资源时,我很容易在 Photoshop 中禁用它,但这次我需要使用自定义字体的动态输出。

如果这是可能的,有什么想法吗?

谢谢。

4

1 回答 1

4

如果您将 UILabel 或类似的子类化,这样的事情可能会起作用:

-(void) drawRect:(CGRect)r {
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSaveGState( context );
    CGContextSetShouldSmoothFonts( context , false );
    [super drawRect:r];
    CGContextRestoreGState( context );
}

如果这不起作用,您也可以尝试这些调用:

CGContextSetAllowsAntialiasing( context , false );
CGContextSetShouldAntialias( context , false );
于 2010-04-23T01:44:53.303 回答