Game Development Community

Working with text objects in Editor

by Drew -Gaiiden- Sikora · in Torque Game Builder · 12/05/2006 (11:49 am) · 22 replies

I think I'm using the t2dTextObject wrong or something - when I create it in the editor it shows up all blocky, and when I run the level and use addAutoFontSize to size it properly I get bleed-through withe the various characters and it looks like this

members.gamedev.net/gaiiden/images/screens/bb/bleed.jpg
I would have thought the implementation of fonts would be a bit more streamlined - how come you can't choose a font size in the level editor??
Page«First 1 2 Next»
#21
03/27/2007 (12:03 am)
To be sure, the garbage in the text field above ("土") is not garbage, but a Japanese character.

Let's see if non-code stuff works: 土.

EDIT: Nope.
#22
03/27/2007 (2:07 am)
After some playing around, I have discovered a few things:
1) The LevelBuilderCreateTool::onTextObjectCreated() function plays havoc with your objects if you wish to use datablocks (provided this is a valid approach).
function LevelBuilderCreateTool::onTextObjectCreated( %this, %object )
{
   [b]// This is where Andrew made his edit above.[/b]
   %object.hideOverlap = false;
   if( %object.getWidth() > 2.0 )
   {
      %object.autoSize = false;
      %object.wordWrap = true;
   }
   else
   {
      %object.wordWrap = false;
      %object.autoSize = true;
   }
   
   %object.font = "Arial";
   %object.lineHeight = 10;
   %camHeight = 75;

   if( isObject( ToolManager.getLastWindow() ) && isObject( ToolManager.getLastWindow().getSceneGraph() ) )
      %camHeight = getWord( ToolManager.getlastWindow().getSceneGraph().cameraSize, 1 );
      
   %object.addAutoFontSize( $levelEditor::DesignResolutionY, %camHeight, %object.lineHeight );
   %object.textAlign = "Left";
   %object.aspectRatio = 1;
   %object.lineSpacing = 0;
   %object.characterSpacing = 0;
}
Note that the object is given all of those settings once the object is created. I'm not certain but I get the feeling that a lot of my t2dtextobject<->datablock related pain is coming from this: I create the object, it gets config'd with the datablock I selected within the "Create" tab, and then this code runs, fiddling with my settings. One thing I found was that t2dTextObjects I created in this method would have their font converted to "Arial" instead of the custom one I designated within the datablock.

I've a sneaking feeling that this can also explain some of the inconsistencies I've been seeing when I do multi-line text objects: the object looks okay in the editor but multiplies its height by the number of lines when simulated (looking really tall and stretched).

2) @Drew & Tom: I think I have a fix for your problem as it seems to help fix mine temporarily. Try deleting the font cache. It's located here: "[your TGB Install Directory]/games/common/data/fonts". I deleted the entire folder and a few of my display artifacts went away. I still had to call %textObj.removeAllFontSizes() and then %textObj.addFontSize(%somethingGood) for all text objects to get them to look right (once in the simulation), though. still had to added a few font sizes, removed them, and then re-added them to a text-object.

I can consistently get them the fonts to blow up again, though, by telling the editor that I want a t2dTextObject configured using a datablock (the one I entered in a previous post). Things are okay for one simulation and then go straight to crazy-town. The fonts don't come back until I flush the cache.

Definitely look into removing the font cache.

To Sum Up:
1) Do not use datablocks on t2dTextObjects within TGB 1.1.3.
2) If your fonts show artifacting, Do delete your font cache at "TGB/games/common/data/fonts", call removeAllFontSizes() on t2dTextObjects you create in the editor on level start, and call addFontSize(%x), where %x is something reasonable for your object, on your t2dTextObjects to make them pretty.

[EDIT]
OR!
1) Do not use datablocks on t2dTextObjects within TGB 1.1.3.
2) Specify a font size by calling %myTextObj.fontSizes = %myGoodFontSizes; where %myGoodFontSizes is a string of space separated font-sizes (Ex: "32 64 80"). This has the effect of doing all of line 2 above.
[/EDIT]
Phew! Hope that helps!

(My game is extremely text heavy... thus the tendency towards datablocks.)

ALSO: I have documented a few bugs dealing with these issues. See this thread for more.
Page«First 1 2 Next»