我有一个小型 MacRuby 应用程序,它在 NSTextView
中显示一些文本。我有一个名为 make_label()
的方法,它使用一些文本构建 NSTextView 并返回它,我用它通过 addSubview()
make_label()
看起来像这样:
def make_label( x, y, width, height, color, font_size, text )
label = NSTextView.alloc.initWithFrame( NSMakeRect( x, y, width, height) )
font = NSFont.systemFontOfSize(font_size)
label.setFont( font )
label.insertText( text )
label.setTextColor( color )
label.setDrawsBackground(false)
label.setRichText(true)
label.setEditable(false)
label.setSelectable(false)
label
end
我的问题是,为什么我的文字看起来渲染得这么差?它看起来非常像素化,而且根本没有抗锯齿(据我所知)。
Click here for screenshot
此截图显示了两种不同大小的字体,具有相同的现象。
最佳答案
如果渲染到不透明的上下文,Cocoa 无法绘制子像素抗锯齿文本。
我来自 Objective-C 方面,所以我猜测了一下,但尝试将 label.setDrawsBackground(false)
设置为 true。
关于cocoa - MacRuby/Cocoa 中文本 (NSFont) 渲染效果不佳。有什么建议吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8193870/