iOS Custom Font displaced

♀尐吖头ヾ 提交于 2019-12-03 14:04:22

问题


For a project I bought a OTF font and included it into my project (with adding to plist file etc). It works and I can set the font on my buttons, but the label is displaced then. I added a screenshot so you can see my issue. Anyone an idea what the problem can be?

system: iPad 3 with iOS 6.0 beta, but same problem on iOS 5.1.1

EDIT:

I found a post about the problem.

http://www.andyyardley.com/2012/04/24/custom-ios-fonts-and-how-to-fix-the-vertical-position-problem/


回答1:


Ok, now I got it :) Just look at the blogpost I linked in my question.

http://www.andyyardley.com/2012/04/24/custom-ios-fonts-and-how-to-fix-the-vertical-position-problem/

summary:

  • Download the Apple Font Tool Suite
  • Terminal: ftxdumperfuser -t hhea -A d font.ttf
  • XML file created in the directory
  • Open XML with Text Editor and adjust the settings of ascender, descender
  • Terminal:ftxdumperfuser -t hhea -A f font.ttf
  • Add custom font to your projekt(dont forget plist item)



回答2:


you can re-align the UIButton's text place with:

[_button setTitleEdgeInsets:UIEdgeInsetsMake(0.f, 0.f, 10.f, 0.f)]; // e.g.


来源:https://stackoverflow.com/questions/11683280/ios-custom-font-displaced

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