简体   繁体   中英

Add Custom Fonts In Xcode 4.1

i want to use custom fonts in y application.

i have declared the "Fonts provided by the application" in the info.Plist file

and set the label.font to the font with name with / without the .TTF extension

draged the TTF file in to the project and copied the file to the project

created an outlet to the label but still, nothing works.

if someone knows what is going on over there i would like to get some help.

recently i have noticed the this problem are known @ the 4.1 (xcode version).

TNX :)

The font name isn't the name of the file. What you want to do is double click on the font in Finder.

This should open it in Font Book like this image

The font name you want is the one in the title which I've highlighted so attractively in red.

I just spent a big chunk of my day trying to figure my problem out... what I missed was, when I dragged the .ttf file into xcode, I did not select my app's name under "Add to target:" section.

Even though it seemed as if the file was in the correct directory and what not, it wasn't recognising it under the family names, using this code:

NSLog(@"FONT FAMILIES\n%@",[UIFont familyNames]);

So hopefully this can help someone if they're stuck.

The above advice did not work for me, so I wanted to share what did:

Opening the font in Finder gave a long name that did not work (TypeWrong Smudged - DGL), but when I looked for the same font in the Photoshop font list it showed the name as just TypeWrong, which did work. So if Finder shows a long name with spaces in it, you might want to try just using the first space-free chunk.

You have to check what is the font name it is at times different from font file name...

check this link

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