Tutorial: Generating Realtime Font Textures With FTBlender

Edit: FTBlender used to be the only readily available method of making bitmap fonts for the BGE. However, ashsid has written a Python script which gives much better results. I recommend you use it instead.

Find it here:
http://www.ashsid.sk/wp/?p=21&lang=en-us
Thread here:
http://blenderartists.org/forum/showthread.php?t=114069

Original Post:
Blender uses special bitmap font textures for realtime text, and these textures can only be generated with a program called FTBlender. I thought I’d throw together a quick tut on making font textures with ftblender. I’ve also got a windows version of ftblender available for download on my site (link in the tutorial).

http://www.blendenzo.com/tutFTBlender.html

Cross-Platform Support?: Apparently ftblender was originally written in Free-BSD, and the source was generally available. That was years ago, though, and I can’t find it anymore. Anybody have a copy or know where I can find it?

Thanks for the tutorial… and yes the source code of ftblender seem impossible to find.
You may want to check this post (if you havent already) … its rather old but maybe one of this two people have the code (I doubt so)
http://www.blender3d.org/forum/viewtopic.php?t=2285&sid=372f415e17695ff059b3200729e50b81

Great deal! this is a much needed tutorial.

Please include something about texture size!!!

I see it time and time again here…
The people spend lots of time modeling and programming their games to make them look nice…

But then they go and take a 256x256 or 128x128 image to do their text with.
Which is ok, if they want to make small text.**

Well,then they blow it up to 10 times bigger than it has to be, to match the size of the UI overlay/HUD (heads up display).
The text comes out with blocky, chunky, UGLY, pixilation. jag-gie lines that are un-fixable.
Any CG art teacher will ABSOLUTLY mark you project with a lower rating, the second they see over scaled , pixilated textures.

it is a BAD BAD BAD BAD thing.
It totaly shows the diffrence between the skilled and the unskilled, the novice and the master (like me!)

In my opinion it just ruins the over all appearance of the game…
It makes it look like the person who did it is a real poor texturing artist.

Well, this is in my efforts to rid the world of “Programmer art” / “Poorly crafted art”.

please help :slight_smile:

Bye the way… after our first classes, i am going to get the kids to do a group thank you e-mail to the blender comunity
belndenzo.com and you are going to be at the top of the list :slight_smile:
Thanks man!

**EDIT:
sorry for being vague on small… open the text image in GIMP or photo$hop, and scale it to 100%
the text in your game should never be bigger than this… You can go smaller, just not bigger.
BIG textures can kill game preformance, ESPECIALY ALPHA MASKED ONES, so it is a real challange to balance preformance with looks.

One word:

CEGUI

It has been successfully implemented with many OGRE projects, it should really be an option with the OGRE plug-in for blender as well.

God that looks great Social!

Here is a working link to a wiki on the subject :slight_smile: I got 2 , 404 errors from your’s
http://www.cegui.org.uk/wiki/index.php/Main_Page

I have beed deaming of something like this for BGE from day 1!

Hey Blendenzo,
I clicked on every google link to help out…
Do you have a paypal?
I know I am going do be wanting to give a % of what I make to help buy bandwidth and Coffee (or beer, or soda if coffee is not your thing).

Funny that you should ask, because the thought just occured to me today. I don’t have paypal yet, but I’ll sign up tonight when I get home from work and add “donation/support” to the tutorials page. I could use a little coffee money. :wink:

Hi Blendenzo.

ive found this ftblender extremely useful.
I realised that the script fails if the fonts name has spaces so i modified the code a bit. No big deal but it works. If anyone can find the authors to tell them the better.

Heres the code:


import os
import time

print "------------"
for f in os.listdir(os.curdir):
    if f[-3:]=="ttf" or f[-3:]=="TTF":
        cad = 'ftblender'+' -o '+ '"'+ f[:-3]+ 'tga" -x 512 -y 512 -r 53 ppem "'+f+'"'
        print cad
        os.system(cad)
        time.sleep(0)

I can make fonts with this tool, but the resolution is limited to 512…
I need higher resolution fonts.
Any idea somebody?

endi,

ashsid wrote a Blender script that creates bitmap font textures and automatically maps them to a blender object. It is not limited in resolution, and you can give it instructions to use extended character sets for non-English languages.

Find it here:
http://www.ashsid.sk/wp/?p=21&lang=en-us

blendzo, thank you
but I have problems: PIL says: another python version need
I have python2.5 and I downloaded PIL for python2.5
but it not works :frowning:

What OS are you using? I’m on Linux Mint with the python and python-image packages installed, and the script is working fine in Blender 2.49b.

winxp and blender 2.49b

What version of Python was your Blender built with? If it includes the python26.dll and python26.zip, then the script may be trying to use the Python 2.6 libraries included with Blender instead of using your main Python 2.5 installation. Perhaps you should upgrade to Python 2.6?

I have installed Python2.6 and now the gui started
but when I press the create button, new error message coming… :frowning:

ImportError: The _imagingft C module is not installed
Traceback (most recent call last):
File “blendFont.py”, line 264, in proc
basicChar.val, delimiter.val)
File “blendFont.py”, line 32, in init
self.font = ImageFont.truetype(fontFile, size, 0, ‘unic’)
File “C:\Python26\lib\site-packages\PIL\ImageFont.py”, line 218, in truetype
return FreeTypeFont(filename, size, index, encoding)
File “C:\Python26\lib\site-packages\PIL\ImageFont.py”, line 134, in init
self.font = core.getfont(file, size, index, encoding)
File “C:\Python26\lib\site-packages\PIL\ImageFont.py”, line 34, in getattr

raise ImportError("The _imagingft C module is not installed")

ImportError: The _imagingft C module is not installed

Apparently there is a problem with the windows version of Python Image Library 1.1.7. You can either fix the problem with a hex editor following these instructions or install PIL 1.1.6 instead.

thank you! using PIL1.1.6 it works :slight_smile:

I have a new problem: I cant make color tga for fonts. Blender uses only grayscale tga for this?
(My game must run in texture face mode.)

problem solved: Photoshop cant convert gray to rgb without changing the pixels.
I have use other converter and now I can use rgb tga-s for font :slight_smile:

Glad you figured it out. :slight_smile:

I had written a tutorial on coloring fonts a while back which includes a good workflow for the GIMP. It’s here if you’re interested: http://www.blendenzo.com/tutColoredText.html

I have a new problem with this.
I can make only fonts where is all characters on the center of a line, see image.
Check the “unusable,” part or the “crate.” part. The comma and the dots are on vertical center. The chars are too but this is no problem for me now. The main problem is the dots and the commas. It looks ugly and unreadable.

Maybe this is a BGE font drawing bug?


EDIT: this is not the problem of the font generator… I dont know what is the problem but in my game EVERY font looks like this…
Help…