- Home /
dynamic fonts rendering differently on mobile
I'm trying to get dynamic fonts to work on mobile (android and iOS) and have run into some weird behavior. I have a GUI Skin that references HelveticaNueu as the font, size 100 and bold. When I preview inside Unity the font looks fine but when I move it to an actual device it shows up as italic. If I make other changes like try Helvetica instead it's the same issue. (These are referencing dfont resources pulled from font book on the mac)
I should mention similar weird font rendering is happening for all my gui elements, including buttons and toggles. I want them to be bold but for some reason these are rendering as UltraLight of all things. It feels like Unity is picking a font styles at random.
If I export the project as a standalone game on desktop (mac) the fonts are fine. Do dynamic fonts not work on mobile when applied to GUI elements? Can you only use them with a GUIText object?
Answer by parkerwhitney · Jul 21, 2013 at 08:32 PM
So I ran into this problem and what I noticed was the UIFont Script only has four style choices for any dynamic font, regardless of what font you're using: Normal, Bold, Italic, Bold and Italic. Obviously the styles available for any given font are going to vary so your selection is getting lost in translation somewhere. A more educated person can speak to exactly why, but in the meantime the solution I've found is to simply load the .ttf of the individual style you want to use, instead of using the the main .ttf and relying on Unity to chose your style.
So if I want Helvetica Neue Medium I'm not using HelveticaNeue.ttf. I'm importing HelveticaNeueMedium.ttf, creating a dynamic font with it, and simply leaving the style set to Normal.
Let me know if this works for you. It did for me.
Answer by rustbucket · Jul 23, 2013 at 10:23 PM
Oh man, THANKS. That did the trick. Just in case anyone else has the DFONT issue, here's a small app that let's you extract the individual TTF files from those combination packages. (this also explained why it worked so well with the google fonts in ttf format)
http://peter.upfold.org.uk/blog/2008/03/11/dfontsplitter-convert-dfont-files-to-ttf/
Awesome! Glad I could help. I think I actually used that exact tool. Thanks for the link.
Your answer
Follow this Question
Related Questions
How to create ParticleEmitter in code 2 Answers
Invoke Repeating Rate 1 Answer
how to draw a laneway/tunnel dynamically and simulate bombed hole 2 Answers
Weather :) 1 Answer
I wonder Why has so little resources To this important topic؟ 0 Answers