blender www.blender.nl
this document is online at http://www.blender.nl/showitem.php?id=44
ALT
 Building bitmap fonts Intermediate  Learn how to create you own bitmap fonts
2000 10 19 
  Frank van Beek  id44 
How to create your own bitmap fonts
So how can you create new bitmap fonts for blender ?

I've written a utility called ftblender that can do just that. It uses the FreeType library which you can download from www.freetype.org . This library reads PostScript and TrueType outline fonts and can convert these fonts into bitmaps. FreeType comes with a couple of demos. I've used the ftview demo as a basis to write ftblender.

I build ftblender on a FreeBSD 4.0 machine. I tried to build the library and ftblender on other platforms (Windows, Irix, Linux), but I ran into some problems that I didn't investigate.

So this tutorial is meant for the die-hard unix users who know how to compile and debug a program. Most other users probably only want to use the bitmap fonts, or use a precompiled binary.

Volunteers anyone ?

If you want to compile your own ftblender, you first need to get all the sources. Get the FreeType 2 library and demos (two separate downloads) from www.freetype.org . I downloaded the beta8 sources. Then download these ftblender sources:

Download:
 ftblender.tgz
Building the library
Unpack these packages in a common subdirectory and rename the freetype2-beta8 directory to freetype2, the ft2demos depend on it.

To improve rendering quality, you might want to enable the bytecode interpreter. Please be aware that by doing this you could be infringing on patents owned by Apple. You can read more about it here.

To build the library, go into the freetype2 directory and type 'make' and again 'make'.

Modifying the demos
Copy ftblender/ftblender.c into the ft2demos/src directory, next to ftview.c .

If you're using the beta8 sources you can use the Makefile that comes with the ftblender sources. Copy ftblender/Makefile to the ft2demos directory, replacing the Makefile already there and skip the next bit about how to modify the Makefile.

If you didn't download the beta8 sources, apply these changes to the Makefile:

Look for the line reading:
EXES := ftlint ftview fttimer ftstring memtest ftmulti

And add ftblender to:
EXES := ftlint ftview fttimer ftstring memtest ftmulti ftblender

Then look for the lines:
$(OBJ_)ftview.$(SO): $(SRC_DIR_)ftview.c $(GRAPH_LIB)
$(COMPILE) $(GRAPH_INCLUDES:%=$I%) $T$@ $<

Add the following lines below these lines. Make sure the first line does not start with a tab, and that the second line does start with a tab.
$(OBJ_)ftblender.$(SO): $(SRC_DIR_)ftblender.c $(GRAPH_LIB)
$(COMPILE) $(GRAPH_INCLUDES:%=$I%) $T$@ $<

Finally look for the lines:
$(BIN_)ftview$E: $(OBJ_)ftview.$(SO) $(FTLIB) $(GRAPH_LIB) $(COMMON_OBJ)
$(GRAPH_LINK)

And add the following lines. Again make sure the first line does not start with a tab, and that the second line does start with a tab.
$(BIN_)ftblender$E: $(OBJ_)ftblender.$(SO) $(FTLIB) $(GRAPH_LIB) $(COMMON_OBJ)
$(GRAPH_LINK)

Building and using ftblender
Eventually type make in the ft2demos directory. If all goes well this should compile ftblender for you. You can find it in the bin subdirectory.

Ftblender has a simple command line interface. You can get usage information by typing:

ftblender -h

If you want to render a 32 point image using Arial.ttf, then start ftblender with the following command line options:

ftblender -o arial.tga 32 Arial.ttf

This will open a 256 x 256 window with a preview of the bitmap. You can change the pointsize by using the up-arrow and down-arrow keys. Make sure that all the characters that you need are in the bitmap and are at least one pixel away from the image border. Then press F2 (sorry F3 was already reserved ;-)) to save arial.tga. You're now ready to use this bitmap font in blender.

There are more tricks and hacks in ftblender. Experiment with the different command line options and look what keyboard input is supported by pressing F1 while ftblender is running.

I know that ftblender is still unfinished. There are more compact ways to store all the characters in the bitmap and there are a couple of known bugs in ftblender . I'm not going to fix them. Use ftblender as it is or change, improve and redistribute it.

Legal issues
First of all you must make sure that the outline font you're using is actually yours to use. If it is, you're free to create a bitmap from it because that's what fonts are used for: To typeset some document on paper, or to use the font to render text in an image.

From the Copyright FAQ:

3.9) Are fonts copyrighted?
...
In essence, a font will be protectable only if it rises to the level of a computer program. Truetype and other scalable fonts will therefore be protected as computer programs, a particular species of literary works. Bitmapped fonts are not copyrightable, because in the opinion of the Copyright Office, the bitmap does not add the requisite level of originality to satisfy the requirement for copyright.

But as always with legal issues: it depends on the country you live in.


Feedback
nikolatesla20 2001 11 18
Here is a link to the Windows port I built.

http://home.centurytel.net/nt20/ftblender.zip

:)

-nt20
arimail 2001 10 08
Yo ablo un poco espanol, estoi aprendiendo.

Mi padre es de Argentina.

(I don´t know what made me tell you that......)
jatc18 2001 06 12
Si aqui llega alguien que hable español , y quiera aprender algo o compartir opiniones o ideas acerca de blender, fabor escribir a jatc18@yahoo.com.mx
Angel7 2001 03 18
Wonder what happened to that windows port?
BadCheese 2000 10 24
I have built two Windows ports of this tool: one with the bytecode interpreter, and one without.

I will have Frank or Bart post them as soon as possible.
B@rt 2000 10 23
I fixed the download - sorry about that!
lec 2000 10 21
This link is dead,
http://www.blender.nl/content_base/44/499/file/ftblender.tgz

Luis

Toonami_fan 2000 10 20
cool