在iPhone上绘制Unicode字符 [英] Drawing Unicode characters on iPhone

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

问题描述

为什么很难弄清楚如何在iPhone上绘制Unicode字符,沿途获得简单的字体指标,比如每个图像字形在选择字体中的宽度如何?

b
$ b

看起来像 NSLayoutManager 很容易,但是这个API显然在手机上不可用。看来人们这样做的方式是使用一个私有API, CGFontGetGlyphsForUnichars ,它不会让你通过Apple守门人进入App Store。



任何人都可以指向我的文档,说明如何做到这一点?我很快就失去了头发。



Howard

解决方案

排除> CGFontGetGlyphsForUnichars


是一个疏忽,而不是一个故意的行动,但我不是b $ b b投注农场它。因此,我使用

[NSString drawAtPoint:withFont:]; (在UIStringDrawing.h中)


$ b



[NSString sizeWithFont];



这还有一个好处,就是对字体中缺少的字符进行体面的替换,
>
CGContextShowGlyphs 不行。


Why is it so hard to figure out how to draw Unicode characters on the iPhone, deriving simple font metrics along the way, such as how wide each imaged glyph is going to be in the font of choice?

It looks like it'd be easy with NSLayoutManager, but that API apparently isn't available on the phone. It appears the way people are doing this is to use a private API, CGFontGetGlyphsForUnichars, which won't get you past the Apple gatekeepers into the App store.

Can anybody point me to documentation that shows how to do this? I'm losing hair rapidly.

Howard

解决方案

I assumed that the exclusion of CGFontGetGlyphsForUnichars
was an oversight rather than a deliberate move, however I'm not
betting the farm on it. So instead I use

[NSString drawAtPoint:withFont:]; (in UIStringDrawing.h)

and

[NSString sizeWithFont];

This also has the advantage of performing decent substitution
on characters missing from your font, something that
CGContextShowGlyphs does not do.

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

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