我可以关闭当前未使用的UIAppFonts的文件描述符吗? [英] Can I close file descriptors for currently unused UIAppFonts?

查看:181
本文介绍了我可以关闭当前未使用的UIAppFonts的文件描述符吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们将大量字体与我们的iOS应用捆绑在一起,我们将它们全部放在 UIAppFonts 中以便加快加载速度。

(我们正在使用它们在 UIWebView 里面,并且 比使用 @ font-face 加载文件更快 。

We bundle a lot of fonts with our iOS app, and we put them all in UIAppFonts for faster loading.
(We're using them inside UIWebView and it's much faster than using loading files with @font-face).

然而这导致我偶尔得到这种警告:

However this lead me to occasionally get this kind of warning:

Mar 13 23:07:16 iPad afcd[2582] <Error>: Max open files: 78
Mar 13 23:07:17 iPad mobile_house_arrest[2584] <Error>: Max open files: 78
Mar 13 23:07:17 iPad mobile_house_arrest[2586] <Error>: Max open files: 78
Mar 13 23:07:17 iPad mobile_house_arrest[2587] <Error>: Max open files: 78
Mar 13 23:07:17 iPad mobile_house_arrest[2588] <Error>: Max open files: 78

这也与打开文件时的I / O异常相关。

This also correlated with I/O exceptions when opening files.

我使用此代码段来查找泄漏文件和看起来iOS 在应用程序的整个生命周期内为 UIAppFonts 中列出的每种字体保持打开文件描述符

I used this snippet to find out the leaking files and it looks like iOS keeps open file descriptors for every font listed in UIAppFonts throughout the whole lifetime of the application.

File Descriptor 8 number 9 in use for: Fonts/ABeeZee-Regular.ttf
File Descriptor 9 number 10 in use for: Fonts/ABeeZee-Regular.ttf
File Descriptor 10 number 11 in use for: Fonts/ABeeZee-Italic.ttf
File Descriptor 11 number 12 in use for: Fonts/ABeeZee-Italic.ttf
File Descriptor 12 number 13 in use for: Fonts/AmaticSC-Regular.ttf
File Descriptor 13 number 14 in use for: Fonts/AmaticSC-Regular.ttf
File Descriptor 14 number 15 in use for: Fonts/AmaticSC-Bold.ttf
File Descriptor 15 number 16 in use for: Fonts/AmaticSC-Bold.ttf
File Descriptor 16 number 17 in use for: Fonts/AnonymousPro-Bold.ttf
File Descriptor 17 number 18 in use for: Fonts/AnonymousPro-Bold.ttf
File Descriptor 18 number 19 in use for: Fonts/AnonymousPro-Regular.ttf
File Descriptor 19 number 20 in use for: Fonts/AnonymousPro-Regular.ttf

对于我们来说,它意味着大约一百个打开的文件描述符,尽管不超过五个<$ c $目前正在使用c> UIAppFonts 。有时会出现重复的条目。

For us, it means about a hundred open file descriptors, although not more than five of UIAppFonts are being used at the moment. Sometimes, duplicate entries show up.

无论如何强行关闭 UIAppFonts的文件描述符我'目前还没有使用?

Is there anyway to forcibly close file descriptors for UIAppFonts I'm not using at the moment?

如果没有,是否有另一种方法可以将本地字体保存到 UIWebView 没有诉诸 @ font-face 哪个很慢?

If not, is there an alternative way of keeping local fonts available to UIWebView without resorting to @font-face which is slow?

推荐答案


如果没有,是否有另一种方法可以保持UIWebView可以使用本地字体而不需要使用慢速的@ font-face?

If not, is there an alternative way of keeping local fonts available to UIWebView without resorting to @font-face which is slow?

原来,有。

我们通过使用 CTFontManagerRegisterFontsForURL 并使用 CTFontManagerUnregisterFontsForURL 。这使得它们可用于 UIWebView ,因为在 font-family 中使用它们之前总是注册字体。

We solved the problem by registering fonts using CTFontManagerRegisterFontsForURL and unregistering them with CTFontManagerUnregisterFontsForURL. This keeps them available for UIWebView, given that you always register fonts before using them in font-family.

这篇关于我可以关闭当前未使用的UIAppFonts的文件描述符吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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