5

I was wondering that how to load a TTF font from a absolute file path, not relative, which is usually done with [UIFont fontWithName:@"xyz"];

In cocos2d we can do it by using CCLabelBMFont that takes file as parameter, but when use CCLabelTTF it takes the name of font, not the file name.

Is there any workaround to load an external font not embedded with the application but downloaded from some resource as per need ?

1
  • Even if you downloaded the font as needed, the only way to get the dynamic referencing would be to have it listed in the info.plist file. Commented May 23, 2012 at 13:12

2 Answers 2

10

Yes, you can do this.

Just copy the font to your project and add this reference in your info.plist. Then you can reference the font name just like any other system font.

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

Bill Burgess, thanks for the comment, but this is a know method, for this you have to configure the font in the info.plist with the app, in my situation I am getting the font from some resource, and there is no information in the .plist, I have just the "ttf" file in say application's Documents directory, no in the Main Bundle, and you can't put any file from outside into app directory, it is read- only.
I did some more research and I can't find a way to load fonts from a dynamic path. There are some options depending on your usage, but you have a little work ahead of you.
can't we assign path of ttf here
0

if I did well understand your question, maybe this post Can I embed a custom font in an iPhone application? will give you an answer.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.