Game Development Community

t2dtextobject is illiterate

by Oriol "Orgarus" Garcia · in Torque Game Builder · 04/27/2010 (4:27 pm) · 7 replies

Hello to Torque community,

I have a dream, one day I'll write here only to send kind regards and my best wishes to everyone who reads in the TGB forums (the other forums have to wait). But now I'm having knighmares (sorry, I meant nightmares, my subconscious tricked me with the konami's old classic) and I have to write (again) to expose my current problem. Let's go:

-I have to put some text in my game(I'm soooo original I know O_o) and I'm using GUITextCtrl's and (try to use) t2dtextobjects to tell things to the future players (all the mankind I hope...XD).

-Today I changed my computer for a brand new (and awesome) one with the default font configuration.

-I said to myself "I won't install the font in the system because I have the uft file (lots of uft files) in the project".

-As my fiancée called to the doctor (when she saw that I was talking alone) I tested the game in my awesome (and new) computer and "oh! surprise! WTFH!" the t2dtextobjects didn't (and don't, I'm still having the problem) show nothing, but the GUItextctrl's did.

I coded GUI profiles on the profiles.cs from the common/etc directory and the text is displayed properly for the GUI (as expected).
I tried the few "populate fonts on cache" functions and writeFontCache, etc... with undesired results (game crashing, text NOT displayed...)
Actually I'm beating around the bush and the documentation that deals with these functions is... brief, two links as search results in the mighty TDN, one of them with an undocumented tag and the other with an unsatisfactory explanation, and new c++ functions (I seize the opportunity to say that what a mess if I have to buy the PRO version if I want to change the window's game icon).

What can I do to display text on a t2dtextobject?
Any ideas are welcome.
Thanks in advance.

Regards.

...

...

Ok.. kind regards and my best wishes to everyone who reads this ;)




#1
04/27/2010 (6:43 pm)
@Oriol, your posts never let me down... Always an entertaining read!

Quote:
I seize the opportunity to say that what a mess if I have to buy the PRO version if I want to change the window's game icon

Agreed but not really GG's fault, I mean it IS a compiled exe... I guess.

Quote:
I tried the few "populate fonts on cache" functions and writeFontCache, etc... with undesired results (game crashing, text NOT displayed...

It sounds like you've done what you need to do. Are you sure it's not something simple like a typo in the path to the font?

This computer doesn't have TGB on it, so I can't provide a working code example. Sorry.

I've never used it but this resource looks like it could be helpful too.. The author puts out good stuff.

EDIT: Try putting your ttf file in your root of your game project and refer to it in code using:
new GuiControlProfile( GuiTextProfileName )
{
 justify = "left";
 fontType = "NameOfFont";
 fontSize = 16;
 fontColor = "0 0 0";
 modal = false;
}
#2
04/28/2010 (3:20 am)
Hi Patrick!
How are you?

Thanks for your quick response.
I'm glad to read you again and that you like my posts :).

-Typo problems? I'll have to check it, but the console didn't say nothing about it.

-This morning (our morning in this side of the ocean, you know) I tried your last suggestion to put the ttf file (and after the uft) on the root
and didn't work.

-I installed then the fontboy resource, but it's pending to try in next attempts (when I finish my working day).

I'll tell you about my progresses (I hope).

Thanks again Patrick.

Kind regards.


PS.-I would not complain about the window's icon if I didn't see that a friend of mine could to do this in Game Maker (sorry, GG team) easily, and I'm green of envy! (And no, I don't want to change to GM)
#3
04/28/2010 (6:57 am)
Oriol,

Quote:
Hi Patrick!
How are you?

I'm great actually. My wife and I just had our first baby last week. She only weighs 800 grams but she's doing great! That's her in my pic! Onward!

To be clear where I put:
fontType = "NameOfFont";

"NameOfFont" should be the actual name, not the name of the file. For example if you had a font called AwesomeFont (what appears in an application when you access it) that is stored in a file called aweFont.ttf, then you would use:
fontType = "AwesomeFont";

I'm sure this works as I looked at a project that uses this code properly. If not, hopefully the resource will work for you; and if that doesn't work, either use a bitmap as a font (which I can help with) or maybe Joe Rossi will weigh in.

`Patrick
#4
04/28/2010 (3:01 pm)
Hi Patrick!

I hope everything goes well for you. My best wishes to you and your family!

I tried to put in the font type field both names, and nothing.
I supose that I have to write the new GUIControlProfile on the profile.cs file, but the question is ¿ain't this snippet of code only for GUI controls? ¿this works on a t2dtextobject? I haven't problems with GUI texts, but I'm trying to make that it works on a t2dblahblah because I want to move text later. To use a bitmap as a font sounds interesting.

Kind regards.

Oriol.




#5
04/28/2010 (7:25 pm)
Hi Oriol!

Thanks for the well wishes. So I led you astray a bit there. I apologize.

The easy way to do this is to simply add the font you want to use as a system font. (Drag it into Window/fonts folder) restart TGB if it's open the select the font for the t2dTextObject or if you're creating it in script set the font parameter to the name of the font.

TGB will create a uft file in the common/data/fonts folder that you can distribute with your game and still be legal but I guess you already knew this so maybe I'm not understanding the problem.
#6
05/03/2010 (3:23 am)
Hi Patrick!!

All is fine for you and your family? My best wishes again.

I finally used the Joe Rossi's solution and it works fine now.
About what you say about the utf files I had them when I had the problem, and as I said the GUITextControl detected the font but the t2dtextobjcet didn't. What a mistery! TGB writes straight using slanting lines.

Kind regards and thanks for all Patrick!
#7
05/03/2010 (8:09 am)
All is well here... Glad it's working for you!