iOS 7自定义字体对齐 [英] iOS 7 custom fonts alignment

查看:193
本文介绍了iOS 7自定义字体对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS 6上实现应用程序的布局时,我使用了一个自定义TTF字体(Gotham)。我注意到它的基线总是比常规字体高一点,但只是轻轻一点。 p>

现在我已经更新到iOS 7 SDK,在iOS 7设备上运行时,字体位置更接近常规字体,但仍然看起来在iOS 6设备上。



所以看起来Apple解释了在解释iOS 7的字体指标时,在基线上引起的垂直移动,但是iOS 6没有改变。



我已经尝试使用Apple的Font Tools套装根据博客文章和许多答案stackoverflow,它对iOS 6有帮助,但在iOS 7上没有太大的变化。



我的问题是,有什么我可以做的使用自定义字体在iOS 6和7,而不需要根据正在运行的iOS版本调整每个标签?



我知道这已经在iOS 7发布说明中提到,但我不想

解决方案

在我的代码中添加多条条件子句,以便为iOS 6或iOS 7设备



我已遵循此 a> answer并在 Glyph 上打开我的TTF文件,然后再次导出。 Glyphs将上升和lineGap值调整为可能正确的字体,并且字体在iOS 6和IOS 7上的行为非常相似。基线现在甚至非常接近系统字体。



仍然有一些小的垂直差异,但显然这发生在iOS 7上的每个字体,即使在系统字体,但是很多不太明显。


I've used a custom TTF font (Gotham) when implementing the layout of an app on iOS 6. I've noticed its baseline was always a bit higher than regular fonts, but just nudged things around to fit.

Now that I've updated to the iOS 7 SDK, the font placement is closer to that of regular fonts when running on iOS 7 devices, but still looks nudged on iOS 6 devices.

So it looks like Apple fixed what caused that vertical shifting on the baseline when interpreting the font metrics for iOS 7, but left iOS 6 untouched.

I've already tried modifying the actual TTF ascender, descender and line gap properties using Apple's Font Tools suits according to this blog post and many answers here on stackoverflow, it does help on iOS 6 but doesn't change much on iOS 7.

My question is: is there something I can do to use a custom font on iOS 6 and 7 without needing to tweak each label depending on the running iOS version?

I know this has been mentioned on the iOS 7 release notes, but I don't want to add tons of conditional clauses on my code to nudge the labels differently for iOS 6 or iOS 7 devices.

解决方案

Editing the TTF file was the solution.

I've followed the suggestion from this answer and opened my TTF files on Glyphs and exported them again. Glyphs adjusted the ascender and lineGap values to something which is probably correct and the fonts behave pretty much identically on iOS 6 and IOS 7. The baseline now is even very close to the system fonts.

There are still some minor vertical differences, but apparently this happens with every font on iOS 7, even on system fonts, but it's much less noticeable.

这篇关于iOS 7自定义字体对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆