x和y是整数。iOS使用CGcontextshowtextatpoint为某些字体的文本绘制矩形
int theSize = [caption.text length];
CGContextShowTextAtPoint(context, x, y, [caption.text UTF8String], theSize);
但是当我使用某些字体,字母显示为矩形:当我使用CGBitmapCreateContext发送自定义创建的上下文,然后用普通的字体使用它像ArialMT
下面的代码工作正常。于是,我就做什么其他堆栈溢出回答表明,这是使用CoreText:
// supposedly a solution to glyphs problem
CGContextSaveGState(context);
CGContextSetRGBFillColor(context, 0, 0, 0, .5);
[caption.text drawAtPoint:CGPointMake(x, y) withFont:caption.font];
CGContextRestoreGState(context);
但是,这只是给了我一个错误:9月7日十三点33分31秒...:CGContextShowGlyphsWithAdvances:无效的情况下为0x0