Bitmap Font Generator Github

Bitmap Font Generator About. FOSS and cross-platform alternative to Glyph Designer made with Qt. Renders specified characters with a font to one (or multiple) textures, applying several neat effects in the process and creates a lookup file containing each character's position and dimension in the textures. This is a post about several bitmap fonts I modify from M+, Tewi, Lemon, & Siji. At first I modify them because I can’t find any bitmap font that suitable for my personal preferences. I want a small bitmap font that can fit in 6x10 bounding box, but placed inside 6x12 bounding box for extra line spacing. Image2cpp is a simple tool to change images into byte arrays (or your array back into an image) for use with Arduino and (monochrome) displays such as OLEDs.

A collection of monospaced, bitmap fonts in BDF format that origin from IBMtext mode and system fonts. They include extended latin, greek, cyrillic andhebrew scripts and several extra characters, for a total of 782 glyphs each.The fonts are in BDF 2.1 format and fully compatible with applications thatmake use of either Xft or XLFD.

In order to install the fonts with default settings, run (if necessary asroot):

The default behaviour of configure is to look for sources in ./bdf, compilefonts in ./pcf, and install the fonts in /usr/local/share/fonts/misc.configure automatically creates objdir if it does not exist.

AUR Package

If you use Arch Linux, there is an AUR package for these fonts namedibm-fonts. You may use yourfavourite AUR helper or proceed with manual installation as describedhere.

You can pass several command line arguments to configure:

If srcdir is set and is a relative path, its parent directory will be$(prefix)/src. If objdir is set and is a relative path, its parentdirectory will be $(prefix)/obj. If installdir is set and is a relativepath, its parent directory will be $(prefix)/share/fonts. If you don't wantthis behaviour simply use absolute paths instead of relative ones.

From the directory you cloned this repository into, run:

After installation or removal, it is important to update the font cache toreflect changes. For applications that use fontconfig, simply run:

Letting older applications like xfontsel detect the changes is morecomplicated. First, check that the installation directory (I will assume it's/usr/local/share/fonts/misc for the sake of the example) is in the X fontpath. You can verify that by running:

If it is not in the font path, you need to instruct X to read your fontdirectory by adding a FontPath entry under the Files section in/etc/X11/xorg.conf (if the file does not exists, create it):

After making sure the installation directory is in the font path, run:

You can check whether the font is detected by X by running either xfontsel orxlsfonts.

IBM BIOS 8x8


XLFD name: -ibm-bios-normal-r-normal--8-60-96-96-c-80-iso10646-1
Filename: ib8x8u.bdf

IBM BIOS 16x8


XLFD Name: -ibm-bios-normal-r-expanded--8-60-96-96-c-160-iso10646-1
Filename: ib16x8u.bdf

IBM BIOS 16x16


XLFD Name: -ibm-bios-normal-r-normal--16-120-96-96-c-160-iso10646-1
Filename: ib16x16u.bdf

IBM BIOS 8x16

Generator


XLFD Name: -ibm-bios-normal-r-condensed--16-120-96-96-c-80-iso10646-1
Filename: ib8x16u.bdf

IBM CGA 8x8


XLFD Name: -ibm-cga-normal-r-normal--8-60-96-96-c-80-iso10646-1
Filename: ic8x8u.bdf

IBM CGA 16x16


XLFD Name: -ibm-cga-normal-r-normal--16-120-96-96-c-160-iso10646-1
Filename: ic16x16u.bdf

IBM CGA 8x16


XLFD Name: -ibm-cga-normal-r-condensed--16-120-96-96-c-80-iso10646-1
Filename: ic8x16u.bdf

Bitmap

IBM CGA Light 8x8

Bitmap Font Generator Github


XLFD Name: -ibm-cga-light-r-normal--8-60-96-96-c-80-iso10646-1
Filename: icl8x8u.bdf

IBM CGA Light 16x16


XLFD Name: -ibm-cga-light-r-normal--16-120-96-96-c-160-iso10646-1
Filename: icl16x16u.bdf

IBM CGA Light 8x16


XLFD Name: -ibm-cga-light-r-condensed--16-120-96-96-c-80-iso10646-1
Filename: icl8x16u.bdf

IBM EGA 8x14


XLFD Name: -ibm-ega-normal-r-normal--14-100-96-96-c-80-iso10646-1
Filename: ie8x14u.bdf

IBM EGA 16x14


XLFD Name: -ibm-ega-normal-r-expanded--14-100-96-96-c-160-iso10646-1
Filename: ie16x14u.bdf

IBM EGA 9x14


XLFD Name: -ibm-ega-normal-r-normal--14-100-96-96-c-90-iso10646-1
Filename: ie9x14u.bdf

IBM EGA 18x14


XLFD Name: -ibm-ega-normal-r-expanded--14-100-96-96-c-180-iso10646-1
Filename: ie18x14u.bdf

IBM MDA 9x14


XLFD Name: -ibm-mda-normal-r-normal--14-100-96-96-c-90-iso10646-1
Filename: im9x14u.bdf

IBM VGA 8x16


XLFD Name: -ibm-vga-normal-r-normal--16-120-96-96-c-80-iso10646-1
Filename: iv8x16u.bdf

IBM VGA 16x16


XLFD Name: -ibm-vga-normal-r-expanded--16-120-96-96-c-160-iso10646-1
Filename: iv16x16u.bdf

IBM VGA 9x16


XLFD Name: -ibm-vga-normal-r-normal--16-120-96-96-c-90-iso10646-1
Filename: iv9x16u.bdf

IBM VGA 18x16


XLFD Name: -ibm-vga-normal-r-expanded--16-120-96-96-c-180-iso10646-1
Filename: iv18x16u.bdf

VileR from The Ultimate Oldschool PC Font Packfor his pixel-perfect reproductions of these old system fonts. I used hisPxPlus fonts as a base.

Font to bitmap

The Dot Factory is a small open source tool (MIT licensed) intended to generate the required C language information to store many fonts and images, as efficiently as possible, on a microcontroller. These fonts are then uploaded via the LCD driver (see the Drivers and Modules page for a few) to the actual dot matrix LCD. It is written in C# for Visual Studio 2008 and has been tested on Windows XP, 2003, Vista, 7 and Linux via Mono.

Working with dot matrix LCDs with microcontrollers, while not difficult, is tedious. The actual LCD controller allows us to upload simple visual data (dot on or dot off) into the LCD’s dot matrix, but not much else. It is up to our software to decide what to upload when we want to draw lines, circles and more importantly – text.

While there are software graphic libraries that allow us to generate a character “on the fly” using vector graphics (the character is described as a series of drawing commands that allow scaling and decoration) – these are much too complex and large to integrate in a microcontroller environment. Consequently, we must store the exact appearance of a character as a series of 1s and 0s, equivalent to a “dot on” “dot off” on the LCD, and upload this as a bitmap when we want to display text. While it is possible to generate this manually, it is desired to have a tool to do our grunt work by converting windows fonts (given a size and decoration) into a series of bitmaps.

Using The Dot Factory

TDF is comprised of two panes – the input pane on the left (what you want to generate) and the output pane on the right (the generated output, in C code). The input pane can accept either a font of your choice (for writing text to the LCD) or an image. When generating a font, you have the option of either generating all the available letters (by selecting “All” in the Insert Text box and clicking the plus button) or by typing in which letters, numbers or symbols you are actually using in your application (for example: 0123abcd). If you are writing a simple application that has only a few sentences, you can type them wholly in this box without fear of duplicating letters – TDF takes care of that by discarding any duplicates. This way only the letters you use will take up space.

Once you have completed setting up what it is you’d like to generate (be it an image or font), select the output method in the output pane. If you are using the LCD drivers on this website, you want it to generate an MSb first output, otherwise images will come out wrong. If you have a compiler that supports the “0b” binary specifier, you can select “binary” rather than “hex”. This will allow you to visually see the pixels you will set and allow for manual touch up by the user without having to calculate hex and experimentation. Click generate and your C code will be outputted to the text box below. Copy paste this into your application (it is recommended to put this in a separate module, not your LCD driver module, for organizational reasons).

Bitmap Font Generator Github

Note that 5×7 and 5×8 fonts cannot be generated using this tool. While some TTF fonts can render characters this small they are usually distorted to the point of uselessness. You can download a ready made five by seven font here. I ripped this font from text file a while ago, so apologies to the uncredited author.

What does it generate?
For font generation, three entities are generated.

  • The character bitmap array: This holds the actual characters as a bitmap (only the characters selected in the input pane). Each byte represents a single vertical page sent to the LCD. All vertical padding is removed from the characters
  • The character descriptor array: Allows O(1) mapping between a character’s ASCII value and required meta information about the character – namely its width in bits and its offset into the character bitmap array. When the LCD driver needs to find where character X is located in the bitmap array, it will jump to index [X - font.startCharacter] in the descriptor array. The startCharacter is the first character (that is, the character with the lowest ASCII value) used for this font. By defining a startCharacter we can reduce the number of elements in the descriptor array.
  • The font information: This element is essentially the font descriptor for this font. It holds information regarding this font like the name of the character bitmap and descriptor arrays, the font start character and how many pixels wide a space character is for this font. The LCD driver will replace the space character with empty pixels (this saves both processing time, space in the character bitmap array and space in the character descriptor array – since the space is the first ASCII character and is commonly used).

The generated structures are generated with documentation, but you may want to see a sample bitmapDb header file for detailed info on the character descriptor array and font information structures. For image generation, only the image’s bitmap array and size descriptors are generated. Note that the height value is pixels (bits) and width values are in pages.

Revision history

I usually release versions according to user demand. If you think TDF can use whatever feature, drop me a line. When enough users request something I invest the time to add it.

  • Version 0.1.4 (2jun12): Support for “Column Major” mode where each byte represents a column rather than a row – contribution by Paul Ryland
  • Version 0.1.3 (31mar12): Linux support with Mono – contribution by mru00
  • Version 0.1.2 (29may11): Fixed width/height being swapped. Added support for configuring image descriptor format (bits/bytes). Thanks geo for the heads up and suggestion
  • Version 0.1.1 (25may11): Added support for multiple descriptor arrays with a double lookup. Before this version TheDotFactory could generate Unicode characters but the lookup tables were usually too huge to be of any use. Using this feature, a double lookup is employed, allowing for fast lookups for characters residing at disparate ranges. See the video for an explanation (will be posted in the next few days). In addition to this, added support for specifying character ranges instead of inputing the actual characters. For example, <<100-120>> will generate characters for ASCII characters 100 to 120. Thanks a bunch to Archis Bhave for inputs and testing. Source is now distributed via github.
  • Version 0.1.0 (15dec10): Added support to format the generated variable names (thanks SpiralBrain), added end character indication to font information (thanks Nick Jensen), added the ability to save to clipboard from File menu and added the ability to save the source/header to file via file menu (don’t remember who, but someone wondered why this wasn’t in. I personally think all fonts should be in a single module and so I opted for copy/paste, but to each his own)
  • Version 0.0.9 (06jun10): Fixed a bug that prevents the space character from being generated (broken in 0.0.8 – thanks Thomas Kibalo)
  • Version 0.0.8 (29may10): Fixed two unreported crashes (clicking generate without entering any text and when a newline existed in generated text), added the ability to copy the outputted text by using a context menuVersion 0.0.7 (28may10): Added ability to select whether character descriptor array is to be created and which character will be used to visualize the font (thanks Christian Treczoks), syntax coloring automatically disabled when generating large amounts of text (will be fixed properly next version), properly handled bitmaps with no black pixels in them (displays error instead of a crash), some minor cosmetics
  • Version 0.0.6 (03mar10): Bug fix for image generation (tried to save a temporary file for debugging in a custom directory) – thanks to Nir Shemeshfor pointhing this out!
  • Version 0.0.5 (23dec09): Added support for rotation (90 degree increments), space character generation, width (bit/byte) selection of character width and font height, optional generation of character height/width and font height, structures are now generated with documention, input text and font is persisted throughout invokations of the application, persistent preset management – add, edit, delete output configuration presets
  • Version 0.0.4 (31jul09): Added a space to end of comments in the char descriptor array to prevent preprocessor misinterpreting ‘’ as a newline
  • Version 0.0.3 (30jul09): Added output configuration: hex/binary, MSb First/LSb first, configurable padding removal, comment control, flip X/Y and more
  • Version 0.0.2 (28jul09): Vista support
  • Version 0.0.1 (25jul09): Initial release (flip not supported, output format not supported, not tested on Vista)

Download

To run this executable, you must have the .NET framework installed. The stable binary has been in the wild for a month at least with no major bugs reported. Non stable binary contains new features and bug fixes (see revision history).

  • Latest binary (0.1.4): Windows 7/Vista/XP/2003, requires .NET framework 3.5

Bitmap Font Creator

Up to date source can be found at Github.