Bitmap font creation

For the menus in my game I want text that’s normal mapped and alpha transparent, so I decided to turn to bitmap fonts- I went ahead and got the order of the character set from another font, and baked an alpha transparent normal mapped font to an image- but I can’t actually use the font unless I have the rows of pixels across the top that indicate alignment and UV mapping. Unfortunately all the tools I can find take a ttf font and convert it to a bitmap font, there seems to be nothing for modifying a bitmap font to be Blender capable.

I even tried copying the alignment rows of pixels from another font so I could change them manually and maybe figure it out by hand, but since my font was substantially larger (2048x) it didn’t work.

Is there some other tool that I missed, or am I just screwed?

Well, you’re not exactly screwed. You can probably figure out what the rows of dots at the top mean by reading ashsid’s bitmap font creator script (or from the FTBlender source code). If you can tell from reading the code how to recreate the dots for a bitmap font, then you could convert your existing bitmap font to a Blender usable format.

It’s a bit of work, but I believe that is your only hope.

Edit: It seems that lines 195-203 in ashsid’s script may be what you would want to look at. Of course, you’d need to do a bit more digging to find out what all the local variables being called are. Having the script print out some of that data to the console may give a better idea of what’s happening.

Unfortunately the actual pixel drawing uses bitwise operations, which I can barely wrap my head around- never mind being able to figure out what the resulting color would be.

My last-ditch attempt is to see if I can dig through the blender source code to find the section that handles bitmap font rendering, and hope that it includes comments that explain what the pixels correlate to.

[edit] hmm, didn’t take long for me to give that up…

Yeah. I felt the same way when I looked at the script and FTBlender source. Perhaps you could ask one of the developers for help? dfelinto or Moguri may know the answer. Or you could ask ashsid, since ashsid must have some idea of what’s going on in order to write that script.

I would just generate a fontbitmap (ftblender) with a ttf that matches as close as possible. Make the resulting texture the same size as you need (ftblender_batch.py line 59) or scale down your baked texture.

Then copy the baked texture (GIMP?) over the generated fontbitmap without removing the contol pixels.

Maybe that helps

If you’re feeling saucy try out some proper .ttf fonts in the GE.

Check out http://stokes.dyndns.org:8443/svn/bgui/trunk and see if you can pick apart the example .blend. It requires a blender version somewhere after the second alpha, so if you have 2.53 that should be fine.

I feel that the blf (blender’s font drawing) module is little known to be supported in the GE, its a well needed addition.

I was going to check out bgui later on for my game’s hud, but in this case I wanted the text to be in 3d and normal mapped, and if I’m not mistaken bgui is only diffuse texture fills and flat text- generally quite useful, but not so much in my specific case right now.

[edit] so I’m gonna go ahead and try Monster’s solution, but I’m curious- is there a way to get blendfont on a mac without having to compile and install multiple libraries? To get a functional build of PIL, I’ve counted at least 6 libraries that I will need to find, confirm compatibility, install, and then compile with- even though I really can’t afford the space for any of them, nor will I use them.

Monster:

The Captain’s font is 2048x2048. FTBlender is limited to 512x512. Bitmap Font Creator is limited to a width of 1024, but this can be altered by editing line 232 of blendFont.py.

Captain:

Is the font mono-spaced? I have two ideas that could work, depending on that.

If it is monospaced:
Figure out the point size (I believe 1pt = 1px in 72x72 resolution) and then use any mono-spaced font at that point size. Render out a font image with Bitmap Font Creator (make sure you edit line 232 to allow for 2048 width). You should then be able to use the dots from that font image at the top of your bitmap font (or paste the font on top of the monospaced one).

If it is not monospaced:
Use FontForge to create a .ttf file from your bitmap font (this may take a bit of tedium, and requires that you know how to use FontForge). Then use Bitmap Font Creator to render out a Blender usable font image. This may degrade the fidelity of the original font image, so at that point in time you could copy paste from the original into the Blender usable image.

Apparently I can’t successfully compile and install PIL on either mac or windows, which is all I have, so it looks like I’ll never get to actually see the bitmap font creator at work. That pretty much aborts any chances of generating the appropriate dots to copy to the image.

I’m just going to go ahead and manually make text with python and added planes, since I could have had that long done by now.

Thanks for all the attempts to help me out though, I’m sorry your time was wasted :[