作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在使用 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/
我正在使用 CoreText 在 Mac/iOS 跨平台代码中绘制一些文本。我可能使用的字体没有在操作系统中为所有用户安装真正的“斜体”版本,但他们需要知道文本即使在那时也是斜体的。 通过 AppKi
我是一名优秀的程序员,十分优秀!