- Home /
Load TTF font instead of OTF
I have two fonts with the same name, but different extensions (ttf and otf). If I do
Font f = Resources.Load("Fonts/bimasakti") as Font;
the variable f
gets an instance of the otf font, which is quite reasonable as I'm guessing the loader is searching for files in alphabetical order. Anyways, if I do
Font f = Resources.Load("Fonts/bimasakti.ttf") as Font;
the variable f
gets nulled, which means that the loader can't find the ttf font.
Why is that and how can I force the loader to load my ttf font instead of the otf?
Answer by tanoshimi · Sep 27, 2016 at 10:27 AM
Well, there's several possible solutions, but the simplest is to place your OTF and TTF fonts in separate directories, then use:
Font f = Resources.Load("Fonts/OTF/bimasakti") as Font;
or
Font f = Resources.Load("Fonts/TTF/bimasakti") as Font;
as appropriate.
Your answer
Follow this Question
Related Questions
3D Text Mesh : Font Texture change to a Blank (Black) On Project Save 1 Answer
Bitmap fonts in unity 5 1 Answer
Issue with Dynamic Fonts not displaying correctly in standalone 0 Answers
Resource Load Prefab 0 Answers
Resource.Load always return null 2 Answers