- Home /
How do I make copies of my Font with an editor script?
I have a TTF font. I want to make copies of that Font with different font sizes but I don't want to have to copy the font manually. Can someone post an example that shows how to write an editor script that will load my existing TTF font file, make a copy and then change the font size on the copy?
Answer by GlitchEnzo2 · Dec 06, 2010 at 08:38 AM
You can create a copy of your font programatically by using Object.Instantiate.
Font clonedFont = (Font)Object.Instantiate(myOriginalFont);
Unfortunately, there is no easy way to change the font size on the copy. That requires a reimport of the TTF.
Note: I say no easy way because there is a "hard" way by using the SerializedObject and SerializedProperty classes.
Answer by Justin Warner · Dec 06, 2010 at 05:53 AM
http://forum.unity3d.com/threads/13158-Changing-Font-Size-in-GUI
I wonder if that's the same as it is in 2008, and it isn't the same version of Unity, probably.
Checking the Font API, their isn't a Size you can change, so I'd guess it isn't possible.
I'd suggest make a folder "Fonts", then in that folder, make a folder for each font, and just make it FontName-12 for size 12, etc.
http://unity3d.com/support/documentation/ScriptReference/Font.html
Hope this helps!