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 ?

iphonic
  • 12,615
  • 7
  • 60
  • 107
  • 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. – Bill Burgess May 23 '12 at 13:12

2 Answers2

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

Bill Burgess
  • 14,054
  • 6
  • 49
  • 86
  • 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. – iphonic May 24 '12 at 06:24
  • 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. – Bill Burgess May 24 '12 at 13:01
  • can't we assign path of ttf here – Prince Kumar Sharma Jul 02 '13 at 15:13
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.

Community
  • 1
  • 1
roberto.buratti
  • 2,487
  • 1
  • 16
  • 10