简体   繁体   English

CGBitmapContext 中没有带有 function “ShowTextAtPoint”的德语变音符号

[英]no german umlaute with function “ShowTextAtPoint” in CGBitmapContext

we have a problem displaying text with german umlaute with the function ShowTextAtPoint in CGBitmapContext .我们在CGBitmapContext中使用 function ShowTextAtPoint显示带有德语变音符号的文本时遇到问题。 The umlaute characters are not displayed.不显示变音符号。

We tried to convert Code from XCode:我们尝试从 XCode 转换代码:

CGContextSelectFont(MyBitmapContext, FontName, 24, kCGEncodingMacRoman);
CGContextShowTextAtPoint(MyBitmapContext, x, y, [caption cStringUsingEncoding:    
NSMacOSRomanStringEncoding], [caption length]);

to MonoTouch:到 MonoTouch:

MyBitmapContext.SelectFont(FontName, 24, CGTextEncoding.MacRoman);
MyBitmapContext.ShowTextAtPoint(x, x, caption , caption.Length);

Thanks a lot for any help.非常感谢您的帮助。

Frank坦率

The problem is that CoreGraphics APIs for CGContext do not support rendering UTF8 code, it is limited to the text encoding in MacRoman (as you showed in your sample).问题是 CGContext 的 CoreGraphics API 不支持呈现 UTF8 代码,它仅限于 MacRoman 中的文本编码(如您在示例中所示)。

The fix is to use the UIKit functions instead, to do this, you can change your code to be like this:解决方法是改用 UIKit 函数,为此,您可以将代码更改为:

UIGraphics.PushContext (mBmpContext);
mBmpContext.SetRGBFillColor(1f,1f,1f,1f);
var font = UIFont.FromName ("Arial", 30);
using (var nsstr = new NSString ("äöü ÜÖÄ")){
    nsstr.DrawString (new PointF (10, 400), font);
}
UIGraphics.PopContext ()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM