如何更改核心文本中的字母间距/字距?

发布于 2024-11-02 06:37:54 字数 403 浏览 1 评论 0原文

这也可能被问为“kCTKernAttributeName 是用词不当吗?”

我需要更改 iOS 中某些文本的字母间距/字距。 (我使用的字体在小尺寸下有点太紧。)有一些核心图形例程可以更改字符间距,但这些例程不处理 Unicode。还有其他核心图形例程是根据字形定义的,但这些例程似乎是一个充满伤害的世界,除其他外,没有安全网来恢复我的字体中不存在的字形的系统字体。

因此,核心文本似乎是执行此操作的方法,并且核心文本支持 CFAttributedString 上的 kCTKernAttributeName。我认为这会做我想要的,尽管这实际上不是字距调整,因为字距调整通常是一个字符对属性,并且这(从文档看来)只是对所有字形的字形前进的统一调整,即, 追踪。

在我走上转换为核心文本 API 的相当痛苦的道路之前,如果有人知道的话......

This could probably also be asked as "Is kCTKernAttributeName a misnomer?"

I need to change the letter spacing/tracking of some text in iOS. (The font I'm using is a little too tight at small sizes.) There are core graphics routines that will change character spacing, but those routines don't handle Unicode. There are other core graphics routines that are defined in terms of glyphs but those seem like a world of hurt, among other things, not having the safety net of reverting back to system fonts for glyphs that don't exist in my font.

So core text seems like the way to do this and core text supports kCTKernAttributeName on CFAttributedString. I think this will do what I want, though this really isn't kerning since kerning is a generally a character-pair attribute and this (appears to be, from the docs) just a uniform adjustment to the glyph advance for all glyphs, i.e., tracking.

If anyone knows before I go down the rather painful path of converting to the core text API ...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ι不睡觉的鱼゛ 2024-11-09 06:37:54

kCTKernAttribute 名称应该满足您的要求。将其设置在一系列文本上可以一致地调整字形间距,而不管特定的字形如何。

我认为部分问题在于字距调整似乎是跟踪的虚拟同义词(它仍然只是在 OS X 附带的字典中“调整要打印的一段文本(字母或字符)之间的间距”) ,由于冗余,现在仅采用对字距调整的含义。词源学家可能更适合对事物的这一方面进行评论......

kCTKernAttribute name should do what you want. Setting it over a range of text adjusts the inter-glyph spacing consistently, irrespective of the specific glyphs.

I think part of the problem is that kerning seems to have been a virtual synonym of tracking (it's still just "adjust the spacing between (letters or characters) in a piece of text to be printed" in the dictionary that comes with OS X), and is now adopting just the meaning of pair kerning because of the redundancy. Probably an etymologist would be better placed to comment on that side of things...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文