开发者

Setting Font in CGBitmapContext.SelectFont using variable

I'm trying to write a general purpose routine that will set t开发者_如何学JAVAhe font using a variable instead of the literal font name.

CGBitmapContext.SelectFont(fontName, fontSize, CGTextEncoding.MacRoman);

instead of:

CGBitmapContext.SelectFont("Arial", fontSize, CGTextEncoding.MacRoman);

But it seems not to work. Any suggestions would be much appreciated.

Thanks, Rick


Please post a more complete sample, the following code works for me:

context.SetFillColor (0.0f, 1.0f);
context.SelectFont ("Arial", 28, CGTextEncoding.MacRoman);
context.ShowTextAtPoint (pageRect.GetMidX (), pageRect.GetMidY (), "Hello Select Font (string)");
string font = "Arial";
context.SelectFont (font, 28, CGTextEncoding.MacRoman);
context.ShowTextAtPoint (pageRect.GetMidX (), pageRect.GetMidY () + 40, "Hello Select Font (var)");

Both lines uses Arial and it still works if I switch them (using the var first).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜