带CoreGraphics的iPhone Unicode文本 [英] iPhone Unicode Text with CoreGraphics

查看:51
本文介绍了带CoreGraphics的iPhone Unicode文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用CGContextShowGlyphsAtPoint渲染路径后的字符.直到我开始使用该应用程序的i18n为止,我对此都没有任何问题,发现除了我尝试使用此功能进行渲染之外,日语字符到处都可以正常显示.

有没有一种方法可以使这些字符正确显示,而不是呈现为空框?愚蠢的是,我没有看到这种情况(新手iPhone开发人员),我真的需要支持这些字符:(

我整天都在搜索stackoverflow和google,但似乎一无所获.

感谢您提供的任何帮助,

Bryn

解决方案

这是一个与您自己的问题非常相似的问题.基本上,很难获得用于完成纯Quartz文本绘制的适当字形,因此,我建议使用NSString UIKit类别方法-drawAtPoint:withFont:.这将为您提供NSString对语言的所有支持,同时让您直接绘制到Core Graphics上下文.这就是我们在 Core Plot框架中用于在CALayer中进行文本呈现的方式. /p>

但是,以这种方式绘制比纯Quartz文本呈现要慢得多,因此,如果您要进行大量的文本绘制,可能会减慢应用程序的运行速度.另外,NSString的UIKit扩展考虑了UIViews及其CALayers的翻转图形上下文,具有导致了其他问题.

I'm using CGContextShowGlyphsAtPoint in my application to render characters that follow a path. I'd had no problems with this at all until I started on i18n of the application and found that Japanese characters appear fine everywhere apart from when I try to render them using this function.

Is there a way to have these characters appear properly, as opposed to being rendered as empty boxes? Stupidly, I didn't see this coming (newbie iPhone developer) and I really need to support these characters :(

I've been searching stackoverflow and google all day but seem to be getting nowhere with this.

Thanks for any help you can offer,

Bryn

解决方案

This is a very similar question to your own. Basically, it is very difficult to get the appropriate glyphs for doing pure Quartz drawing of text, so I recommend using the NSString UIKit category method -drawAtPoint:withFont:. This will get you all the support that NSString has for languages, while letting you draw directly to a Core Graphics context. It's what we use in the Core Plot framework for text rendering within a CALayer.

However, drawing this way is much slower than pure Quartz text rendering, so if you're doing a lot of text drawing it could slow things down in your application. Also, the UIKit extensions to NSString take into account the flipped graphics context of UIViews and their CALayers, which has caused others problems.

这篇关于带CoreGraphics的iPhone Unicode文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆