Hello Guest

Author Topic: Weird problem setting font dynamically on iOS  (Read 3379 times)

Antifuzz

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 4
    • View Profile
Weird problem setting font dynamically on iOS
« on: August 20, 2013, 04:49:05 pm »
I'm getting a strange problem when changing the font dynamically on iOS (which I need to do for localisation).

I've got my fonts in my Resources folder, and am changing them at runtime like this:

textBox.font = (Resources.Load("euro_blue") as GameObject).GetComponent<tk2dFont>()

... and it works fine in the editor. No problems.

BUT... when I compile for iOS and test on a device, the changed fonts show up all garbled as if they are using a spritesheet from another seemingly random font asset in the library.

The only way I've found to fix it is to manually place a textfield somewhere off-camera in a scene with its font set to the new one that I'm changing too. Which kind of reminds me of working in Flash circa 2003. ;)

It's as if the fonts I have in my Resources folder aren't actually getting packaged into the app unless I brute-force it by placing dummy text fields in my scene.

I can of course, just do the above, but it feels super-clunky and obviously doesn't scale well as I add more fonts. Am I missing something?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Weird problem setting font dynamically on iOS
« Reply #1 on: August 20, 2013, 07:16:41 pm »
Are you sure this works? It should be tk2dFontData and not tk2dFont.

Also, are those fonts in a sprite collection? Can you check the build log to see if all the necessary files are included? And finally, are you using platform sprite collections?