Game Development Community

Text Manipulation

by Phillip O'Shea · in Torque Game Builder · 08/02/2007 (9:46 pm) · 2 replies

Is there any possible way to stretch the width of a font, or put spaces in between letter for the GUI text control object?

Failing that, can I use fonts that I have imported into the font cache with GUI text boxes?

Thank you

About the author

Head of Violent Tulip, a small independent software development company working in Wollongong, Australia. Go to http://www.violent-tulip.com/ to see our latest offerings.


#1
08/08/2007 (9:29 am)
I believe the font size is defined in the profile. Look at the default gui profile or the text control profile, make a new profile derived from it with the font size you want. If you already knew that and really just wanted to make a font wider but not taller... well you cant. You would have to modify some engine code to add the ability to set both a font "width / height" rather than just "size", but I also can't imagine why you would want to do that. Maybe just find another font that looks "wider".
#2
08/14/2007 (2:10 pm)
If you just want spacing, you could add a function to GuiTextCtrl:

function GuiTextCtrl::setTextSpaced(%this, %text, %spacing)
{
  %length = strlen(%text);
  if(%length == 0)
    %this.setText("");
  if(%spacing <= 0)
    %this.setText(%text);
 
  %spacer = " ";
  for(%i=1; %i<%spacing; %i++)
    %spacer = %spacer @ " ";
 
  %result = getSubStr(%text, 0, 1);
  for(%i=1; %i<%length; %i++)
    %result = %result @ %spacing @ getSubStr(%text, %i, 1);
 
  %this.setText(%result);
}

As for stretching the actual letters, you'd need to modify the engine for that. And having tried it, it screws up the aliasing. Probably simpler to just use a wide font.