Loading and using Font UTF's in textObjects
by Kevin Epps · in Torque Game Builder · 05/19/2008 (7:35 pm) · 3 replies
I'm obviously too dense to see how to do this as there aren't any explanations that explain this in detail with examples.
I'm trying to use that "Font Boy" resource to create fonts. The UTF files(for instance, Day Poster Shadow NF 14 (ansi).uft) get created, but when I try to set the textobject's font to that font (i.e. "Day Poster Shadow NF"), I get the default font instead of my styled font. How can I call and use a specifically styled font when the original font's there as well.
PLEASE HELP!!!! I HAVE SPENT A WHOLE DAY ON THIS!!!
More than I should have to spend on something like a font.........
I'm trying to use that "Font Boy" resource to create fonts. The UTF files(for instance, Day Poster Shadow NF 14 (ansi).uft) get created, but when I try to set the textobject's font to that font (i.e. "Day Poster Shadow NF"), I get the default font instead of my styled font. How can I call and use a specifically styled font when the original font's there as well.
PLEASE HELP!!!! I HAVE SPENT A WHOLE DAY ON THIS!!!
More than I should have to spend on something like a font.........
About the author
#2
Also you'll need to use a function like this to load the images. The call to importCachedFont is extremely important, this is what actually loads your image as a TGB font.
I have a couple of custom fonts (colored/shaded) working in the latest TGB, so I know the tool works.. it just takes a little fudging around unfortunately.
The .uft file and your custom png should be portable across all supported TGB platforms, though I have yet to test on anything but WinXP.
05/19/2008 (9:11 pm)
Hi, I wrote Font Boy. I know it's kind of quirky..there's a lot that can go wrong. When you create new font object be sure you are using the correct size for your font. In your case it would probably be 14. You would set it like so $textObject.fontSizes = "14";I tend to use a bigger number like 80, but I'm not sure if that matters much. I don't think the editor has a way to set this yet so you may be forced to do it in script.
Also you'll need to use a function like this to load the images. The call to importCachedFont is extremely important, this is what actually loads your image as a TGB font.
function load_custom_font( %name, %size, %weight){
%pngdir = "pngs/";
%fontdir = "common/ui/cache/";
%fileName = %fontdir @ %pngdir @ %name SPC %size @ ".png";
importCachedFont( %name, %size, %fileName, %weight, 0);
}So to load a font image you created, call the above function like so:load_custom_font( "Day Poster Shadow NF", 14, 0 );
I have a couple of custom fonts (colored/shaded) working in the latest TGB, so I know the tool works.. it just takes a little fudging around unfortunately.
The .uft file and your custom png should be portable across all supported TGB platforms, though I have yet to test on anything but WinXP.
#3
I can use it flawlessly now!
05/21/2008 (6:29 am)
Thanks, Joe! I fully understand now. setting "fontSizes" is what did the trick. I can use it flawlessly now!
Torque 3D Owner Stephen Zepp
In your Game Directory (normally the name of your project), there is a fonts directory buried down a bit:
This is where TGB stores fonts in .uft form that it's told to use. It's possible that sticking your .uft file there, and referencing is as you have been trying may work.
I'm not particularly experienced with custom fonts myself, but it's also possible you may have to register the font somehow with your OS? I faintly remember several years ago having to place a font file in a specific place in my /system directory (windows) to use it in an application.