I made this little plug-in for the Gimp because I needed to generate a fixed-width font bitmap (what I have called a Bitmap Font) to load and use in an application of mine. I then thought that maybe someone would like to learn how to make plug-ins for the Gimp with Python, as I did, so that’s why I’m posting it here.
It turns out to be very simple. Your plug-ins need to be placed in your user’s directory for the Gimp. In my case, that is ~/.gimp-2.6/plug-ins. When the program starts up, it will scan that folder, looking for any possible plug-ins there.
In my case, I decided I wanted to place the plug-in in the File menu, under Create:

That is done with the register function at the end of the code, amongst other configuration settings for the window that shows up if you select my plug-in:
register(
"sole_generate_bitmap_font",
"Generate bitmap font",
"Generate bitmap font",
"Soledad Penades",
"Soledad Penades",
"2009",
"<Image>/File/Create/_Generate Bitmap Font",
"",
[
(PF_FONT, "Font", "Font", "04b03"),
(PF_SPINNER, "Font_Size", "Size", 8, (0, 1000, 1)),
(PF_RADIO, "orientation", "Orientation", "horizontal",
(("_horizontal", "horizontal"), ("_vertical", "vertical"))
)
],
[],
sole_generate_bitmap_font)
The plug-in, as it is, offers only few configuration options but if you want more, they can be added very easily. There’s a but: the only thing I couldn’t manage to do is to remove the “Input image” and “Input drawable” options (note they aren’t specified in my code either, it seems they are added automatically).
Once you press ‘OK’, it will create a new document with the selected font. This is an example:

Now, that isn’t a fixed width font. When this texture is used for writing texts, it produces text that can be read but feels weird, because that font has not been designed to be used with fixed widths. Anyway, you get the idea. I’m still looking for a fixed width font that I like and find easy to read, so that’s why I’m using this one for the example. It is the classic 04b_03 by 04.
You can take a look at the full source code here. Enjoy it!

pera
bravo \o/ es bastante util; hay un lugar donde podrias publicar esto: http://registry.gimp.org/forum
sole
Buena idea, le echo un vistazo! thanks!
newt
if orientation == “horizontal”:
height = font_size +(font_size/2)
sole
Hey newt, what do you exactly want to do with that change?
sam
looks like a useful plugin, but i am simple to silly to install it.
Would you be so kind to help me?
I work under Debian lenny with gimp-2.4, after i put the plug-in to /home/[user-name]/.gimp-2.4/plug-ins and “chmod +x sole_generate_bitmap_font.py”, gimp doesn’t show me the menu File>Create>Generate Bitmap Font
p.s. sorry for my poor english ;-)
sole
Oh sorry about that. Did you try closing Gimp and opening it again?
I can’t remember exactly – maybe I didn’t test it with 2.4 and something is wrong with the code, and won’t work unless you use 2.6.
Can’t think of anything else… Maybe trying to execute gimp from a terminal and see if it outputs any error message?
sam
i now compile gimp 2.6, maybe it works then… i found a quit good tutorial to do this on: “http://zahlenzerkleinerer.de/tag/the-gimp”(in german)
sole
Alright! Good luck on that! :) Hope it works then!
sam
now it works! great tool, thank you very much for programming this!
sole
Great to hear that, I’m very glad you like it! Thanks to you for using it :-)
michu
hey, great plugin, thanks! i did some minor changes and published it here: http://www.neophob.com/serendipity/index.php?/archives/173-Create-a-fixed-size-font-image.html