gpt4 book ai didi

ios - 与 AppKit 的 NSObliquenessAttributeName 等效的 CoreText 是什么?

转载 作者:可可西里 更新时间:2023-11-01 05:06:44 26 4
gpt4 key购买 nike

我正在使用 CoreText 在 Mac/iOS 跨平台代码中绘制一些文本。我可能使用的字体没有在操作系统中为所有用户安装真正的“斜体”版本,但他们需要知道文本即使在那时也是斜体的。

通过 AppKit 的 NSAttributedString -drawAtPoint:,我可以使用 NSObliquenessAttributeName 使文本倾斜(因此看起来是斜体——嗯,倾斜)。 CoreText 似乎没有此属性的等效项。至少我在 CTStringAttributes.h 中没有找到任何文件(即使在 CoreText 发布多年后也没有任何文档)。

有人知道如何在 iOS 上使用 CoreText 获取倾斜文本吗?

最佳答案

我会尝试使用带有剪切矩阵的 CTFontCreateWithName() 的仿射变换参数。例如

CGAffineTransform matrix = { 1, 0, 0.5, 1, 0, 0 };
CTFontRef myFont = CTFontCreateWithName(CFSTR("Helvetica"), 48, &matrix);

这会造成相当大的偏差(假设我做对了),但你明白了。

更新:

事实上,the documentation appears to imply that this is the right way to do things .

关于ios - 与 AppKit 的 NSObliquenessAttributeName 等效的 CoreText 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9486737/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com