Measure size of each char in an NSString

人盡茶涼 提交于 2019-12-11 07:35:38

问题


We have [NSString sizeWithFont:] which returns the size of the entire string.

What about getting an array of the sizes of each individual character within the string?

How would you do that (besides tokenizing the string and calling sizeWithFont for each)?

Best, Vance


回答1:


You should be able to get size information about individual glyphs (note though that those don't always map one-to-one with individual characters in a string) by using the Core Graphics function CGFontGetGlyphBBoxes.



来源:https://stackoverflow.com/questions/5129547/measure-size-of-each-char-in-an-nsstring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!