如何使用CGContextSelectFont根据当前语言选择编码?
使用 CGContextSelectFont 绘制位图,但使用某种编码。当使用不同的语言时,这将不起作用。根据当前语言选择编码的推荐方式是什么?请注意,本地化工作正常。
CGContextDrawImage(context, rect, image.CGImage);
NSString *temp = [[NSString alloc] initWithFormat:@"%@%@",[Localization string:@"WaitingForDownloadFor"],title];
const char *text = [temp UTF8String];
CGContextSelectFont(context, "Arial", 18, kCGEncodingMacRoman); //*** line in question
CGContextSetTextDrawingMode(context, kCGTextFill);
CGContextSetRGBFillColor(context, 1, 1, 1, 1);
CGContextShowTextAtPoint(context, 10, h/2, text, strlen(text));
Using CGContextSelectFont to draw to a bitmap, but using a certain encoding. When using a different language, this will not work. What is the recommended way of choosing the encoding based on current language? Please note that the localization is working fine.
CGContextDrawImage(context, rect, image.CGImage);
NSString *temp = [[NSString alloc] initWithFormat:@"%@%@",[Localization string:@"WaitingForDownloadFor"],title];
const char *text = [temp UTF8String];
CGContextSelectFont(context, "Arial", 18, kCGEncodingMacRoman); //*** line in question
CGContextSetTextDrawingMode(context, kCGTextFill);
CGContextSetRGBFillColor(context, 1, 1, 1, 1);
CGContextShowTextAtPoint(context, 10, h/2, text, strlen(text));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是回答问题的代码,感谢您的指点......Localization 类是一个自定义类。
Here is the code that answers the question, thanks for the pointers....The Localization class is a custom class.