简体   繁体   English

CGBitmapContext 中没有德语变音符号

[英]no german umlaute in CGBitmapContext

we have a problem with displaing text with german umlaute with the function "ShowTextAtPoint" in CGBitmapContext.我们在使用 CGBitmapContext 中的 function "ShowTextAtPoint" 用德语变音符号显示文本时遇到问题。 The umlaute characters are not displayed.不显示变音符号。 Has anybody an idea for any workaround?有人有任何解决方法的想法吗?

thanks for an answer, 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 ()

You can also use escape sequences to get it to work:您还可以使用转义序列来使其工作:

see this page for the characters you want: http://en.wikipedia.org/wiki/Mac_OS_Roman请参阅此页面以获取您想要的字符: http://en.wikipedia.org/wiki/Mac_OS_Roman

"\x80, \xE8, \xEC, \x85, \x86" will give the capital vowels in order: A, E, I, O, U with umlaute "\x80, \xE8, \xEC, \x85, \x86" 将按顺序给出大写元音:A、E、I、O、U 带元音变音

"\x8A, \x91, \x95, \x9A, \x9F" will give the lowercase vowels in order: a, e, i, o, u with umlaute "\x8A, \x91, \x95, \x9A, \x9F" 将按顺序给出小写元音:a, e, i, o, u 带变音符号

MacRoman includes the characters you were needing, so you don't need to use UIKit if you prefer to work in CoreGraphics. MacRoman 包含您需要的字符,因此如果您更喜欢在 CoreGraphics 中工作,则无需使用 UIKit。

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

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