简体   繁体   中英

How to load font from disk?

Is it possible to load a font from disk and use it during run-time?

If so, how/where do you store the fonts on the iphone/ipod/ipad for your app to use?

(To be clear, I'm not talking about adding the font as a resource at design-time. I'm asking about a way to allow a user to select a font file during run-time, loading it, and making it available for use.)

您应该将它们(.ttf,.otf)放入UIAppFonts下的信息UIAppFonts然后可以通过setFont: withSize: “使用”它们setFont: withSize:

You add your font as a resource, add it to your info.plist under Fonts provided by application ( UIAppFonts ) array, then use it as any embedded one.


Ok, in that case take a look at FontLabel project.

One thing though, looking through it's code - you can only get CGFontRef and with kind of voodoo work with it, no conversion between CGFontRef and UIFont really exists. See this question

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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