简体   繁体   中英

Adding custom font to project, programmatically add item to plist

I want to add some font to my project. I have directory in my project contains fonts. So i can access to my font by:

NSString* path = [[NSBundle mainBundle] pathForResource:@"res_name" ofType:@"res_type" inDirectory:@"res_directory"];

But how to add it to my project so i will be able to call it like this:

[UIFont fontWithName:@"Font-Name" size:14.0]

I'm only interest how to do this programmatically I'm assume that I have to add it to my plist, but can i do this programmatically?

I understand o have to use a in plist:

<key>UIAppFonts</key>
<array>
    <string>swellfont.ttf</string>
</array>

But i cannot do this in Xcode manually. I want to check what fonts i included in my project in resource directory and add them programmatically from code.

The UIAppFonts key in Info.plist.


You can take a look at the Core Text Font Manager to see if registering fonts by URL make them loadable with +[UIFont fontWithName:] .

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