Game Development Community

BUG: Extra output in t2dTextObject

by Pedro Vicente · in iTorque 2D · 07/21/2011 (6:49 pm) · 6 replies

Build: 1.4.1

Platform: All

Issues: t2dTextObject displays extra output in some letters.

Using the code below, some letters have extra output.

function WordySceneGraph::MakeTextObject( %this, %code )
{
    %text = %this.GetASCIICharacter( %code );
    %obj = new t2dTextObject() 
    { 
        scenegraph      = %this;
        text            = "";
        textAlign       = "Center";
        font            = "Times New Roman Bold";
        hideOverflow    = false;
        autoSize        = true;
        Visible         = true;
    };
    %fontsize = 48;
    %obj.removeAllFontSizes();
    %obj.addFontSize( %fontsize );
    %obj.LineHeight = %fontsize;  
    %obj.setBlendColor( 0.0, 0.0, 0.0, 1.0 );
    %obj.setSize( 40 );
    %obj.setLayer( 5 );
    %obj.text = %text;
    return %obj;
}


function WordySceneGraph::GenerateFont( %this )
{
   %fontsizes = "48"; 
   for (%i = 0; %i < getWordCount(%fontsizes); %i++)  
   {  
      populateFontCacheRange("Arial Bold", getWord(%fontsizes, %i), 32, 126);    
   }  
   writeFontCache();
	
}

Note: this does not happen for all fonts and sizes, only for this particular combination;

The "P" and "G" have 2 vertical lines; the "B" and "O" are truncated




www.space-research.org/games/garage_games/127035_1.png

#1
07/21/2011 (7:32 pm)
Changing the font size until they look right is a process of trial and error.

1) Does anyone found a good combination that works?
2) Is this a logged bug? (and if yes is there a solution ? :-) )
Thanks

This issue has been discussed just not sure if a permanent solution will be available (or if actually it's the same issue)

www.garagegames.com/community/forums/viewthread/115773

An example changing the code to use a font size 80

www.space-research.org/games/garage_games/127035_2.png




#2
07/22/2011 (8:17 am)
I get similar glitches on all my text objects in Torque. I've just randomly moved things around until the problems go away, although it is very frustrating.

Looking at your first image I just realized what's going on - The right edge of the F is getting chopped off and drawn on the left of the G, and the right of the O is showing up on the left of the P. So basically the boundaries of the letters are not aligning correctly. Hopefully this clarification of what the bug actually is will allow Garagegames to finally fix it. I suspect when the font .UFT files are generated they need to be padded with 1 extra pixel.
#3
07/22/2011 (10:23 am)
@Conor
Good catch, the right of the O is showing up on the left of the P yes.
#4
07/22/2011 (12:03 pm)
How does it look if you set the size of the the t2dtextobject larger? e.g. setSize(48)
#5
07/22/2011 (12:59 pm)
@Scott

1) setting the size of the t2dtextobject object larger makes the fonts look like in post #2, that is, bad.

but...

2) I tried setting line height to slightly larger than font size and other parameters like below, and the problem seems to be *gone*, which is great !

function WordySceneGraph::MakeTextObject( %this, %code )
{
    %text = %this.GetASCIICharacter( %code );
    %obj = new t2dTextObject() 
    { 
        scenegraph      = %this;
        text            = "";
        textAlign       = "Center";
        font            = "Times New Roman Bold";
        hideOverflow    = false;
        autoSize        = true;
        Visible         = true;
  
		  blendIgnoreTextureAlpha = "0";
		  wordWrap = "0";
		  hideOverflow = "0";
		  aspectRatio = "1";
		  lineSpacing = "0";
		  characterSpacing = "0";
		  autoSize = "1";
		  filter = "1";
		  integerPrecision = "1";
		  noUnicode = "0";
		  hideOverlap = "0";        
        
    };
    %fontsize = 48;
    %obj.removeAllFontSizes();
    %obj.addFontSize( %fontsize );
    %obj.LineHeight = %fontsize + 10;  
    %obj.setBlendColor( 0.0, 0.0, 0.0, 1.0 );
    %obj.setSize( 40 );
    %obj.setLayer( 5 );
    %obj.text = %text;
    return %obj;
}

Result: Note "O" and "P" are ok.

www.space-research.org/games/garage_games/127035_3.png
#6
07/22/2011 (1:04 pm)
Glad you got it working ... that was my advice in this thread ;-)

www.garagegames.com/community/forums/viewthread/115773