简体   繁体   English

如果字体在UILabel的顶部或底部被“切除”,如何修改字体属性

[英]How to modify font properties if the font is “cut off” at the top or bottom in a UILabel

如果从UILabel的顶部“切下”字体,特别是在使用非英语特殊字符(例如ČŠÑ时,如何增加字体的高度?

This answer helped me, however, it is missing a few things. 这个答案帮助了我,但是,它缺少了一些东西。

Download the Apple Font Tools and install them. 下载并安装Apple字体工具 Then open the Terminal, navigate to the "Fonts" folder, or open "font Book", find your font, right click to show it in the Finder, copy-paste it somewhere else and then navigate to that folder in Terminal. 然后打开终端,导航到“字体”文件夹,或打开“字体书”,找到您的字体,右键单击以在Finder中显示它,将其复制粘贴到其他位置,然后导航到终端中的该文件夹。

Then paste this in the terminal (beware of spaces in the name of the font, put a \\ in front of them): 然后将其粘贴到终端中(注意字体名称中的空格,在它们前面加一个\\ ):

ftxdumperfuser -t hhea -A d MyFont.ttf

This will generate a MyFont.hhea.xml file, which you can open with any text editor. 这将生成一个MyFont.hhea.xml文件,您可以使用任何文本编辑器打开该文件。 Now you can modify the ascender & descender properties. 现在,您可以修改ascenderdescender属性。 If your font gets cut off at the top, then increase ascender and descender by the same amount. 如果您的字体在顶部被截断,则将上升和下降量增加相同的数量。

When you're done editing, paste this in the terminal: 完成编辑后,将其粘贴到终端中:

ftxdumperfuser -t hhea -A f MyFont.ttf

This will generate a new .ttf file which you can install like a normal font. 这将生成一个新的.ttf文件,您可以像正常字体一样进行安装。 Works with other font extensions as well, such as .otf . 也可以与其他字体扩展名一起使用,例如.otf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM