News Tutorials Games Downloads Links Contact

Featured Author:

Tutorial - Blender Game Engine

Right-Aligned UV Text and RTL Language Support

I'd been wondering for a while if there was a way to right align UV text in the GE, so I thought I'd give it a try. The solution I found is incredibly simple, and you'll love knowing how to do it for future projects. It also has the added benefit of RTL (Right-to-Left) language support for languages like Japanese and Hebrew.

1. Start with a regular UV Text object.

If you don't already know how to make UV Text, I encourage you to use ST150's helpful tutorial and premade text images. Also, I have several ready to use UV Text objects available for downlaod on the downloads page. (They're in Blender Library format. Follow the easy tutorial to import them.)

2. Okay, now that you have a Text object, rotate it 180 degrees so that it faces away from you.

You can do this all much quicker with the keyboard than with the mouse. Press "R" to rotate, then press "Y" twice to contrain rotation to the local Y-axis. Type "180" to enter the rotation directly, the press "Enter".

3. Flip the normal in edit mode (W Key >> Flip Normals). When you view the text in object mode, you will see that the text is mirrored.

Notice where the origin is, though? Previously the text had generated from the left to the right. The mirrored text originates from the right! Now we just need to flip it around...

4. Flip the UV mapping. From object mode, enter UV face select mode (F Key over the 3d view). In the UV editor, select the two vertices on the left. Grab them and move them along the X axis to the opposite side of the other two vertices. Now the two selected vertices should be on the right. Select all vertices and move the box back over the @ symbol. Exit UV face select mode (F Key again). Now the letters are no longer mirrored.

This is exactly what we want for RTL language support, but if your using a LTR language (like English), it reads backward. That's easy enough to fix, though.

5. Reverse the Text. Go to the logic buttons (F9) and reverse the data in the property named "Text". For this example, I changed "" to "moc.oznednelb.www". To use Python to reverse your text, use the short script at the end of this tutorial.

Tip: Don't think too hard about it. Just type the text the way it appears already in 3D view. Look at the image of backward text above. Start with "m", then type the letters as they appear from left to right "moc.ozne.....

Vioala! Right-aligned text. And they said it couldn't be done...

Supplementary Material - Script

Typing everything in reverse may seem a bother, so I've created a script that will reverse the text for you. Here's the code:

import GameLogic as g

def reverseText(text):
length = len(text)
newText = ""
for x in range(length):
newText += text[(length-1)-x]
return newText

own = g.getCurrentController().getOwner()

own.Text = reverseText("Fill in your text here!")

Right-click and "Save As" to download the .py file and connect it to your right-aligned text object. Have fun! (You could also use it on a left aligned text object if you were going for a Leonardo Davinci effect...)

Back to the tutorials index...

Website design by Tony "blendenzo" DiRienzo. All content Copyright Tony DiRienzo unless otherwise noted.