After my blog post on e-ink displaysI wanted to go into more detail on how I generated the bitmap fonts I used. In this blog post, I'll show how to generate bitmap fonts from fonts you can get online, and a brief intro on how to use them.
I know there are a few tools out there for generating this kind of thing, but this was a custom thing for my microcontroller and I like doing and learning things myself! There are quite a few sites with freely downloadable fonts that make great pixel fonts FontGal. Before we can use this in a microcontroller, we need to turn the bitmap font into a C header file, so it can be compiled into the firmware.
Since the bitmap font is black and white, the most efficient way to store it is an array of 6 bytes, with each byte representing one vertical column of pixels 8 pixels high. The resulting header file looks something like this:. This is a fairly standard way of representing fonts, though it does pose a limitation in that characters can only be 8 pixels high, and it makes it somewhat difficult to represent variable-width characters since each char must have exactly 6 bytes.
It's fairly easy to draw fonts stored like this. First we convert the ASCII character to an index by subtracting the offset of the first character in the font.
We also replace any invalid characters with space, to prevent the code from trying to draw characters that aren't defined! It is possible to extend this code to support variable-width characters, or dynamically selectable fonts using pointersbut that's a bit trickier to implement. An archive of my processed fonts is available here: fonts. As always, if you want to know more or need some help, feel free to contact me or leave a comment! Bitmap Fonts There are quite a few sites with freely downloadable fonts that make great pixel fonts FontGal.
C Header Before we can use this in a microcontroller, we need to turn the bitmap font into a C header file, so it can be compiled into the firmware.This program will allow you to generate bitmap fonts from TrueType fonts. The application generates both image files and character descriptions that can be read by a game for easy rendering of fonts. The program is freeware and open source, but a donation is greatly appreciated. The manual is installed with the tool, but for those who wish to take a look at it without installing the tool first it is also available here.
The manual describes both how to use the tool and the file format of the generated files. Online documentation Source code The source code is available under the widely known zlib license. The svn repository is hosted at SourceForge. If you want any support with the code, then please visit the forums.
Observation on virus alert Avira anti-virus has been known to give a virus alert when scanning bmfont. This is a false positive generated by their heuristic functions that tries to predict and catch unknown viruses. I've already reported this false positive to Avira a few times and each time they recognize it as a false positive, however for some reason the problem comes back months later presumably when they update the heuristic functions. If anyone has any idea what I need to change in the code to prevent this false alert I would very much like to know.
The following are some other tools that also generate output in the same format that I came up with for BMFont and that is widely used in the industry today. Downloads download installer for v1. Needs special shader to render with, but saves a lot of memory Anti-aliasing, both through Windows native font smoothing and super sampling Configurable padding and spacing between characters Select characters from text file, supports both UTF8 and UTF16 encoded files Generate bitmap font from command line Import colored images as characters, supports: bmp, jpg, tga, dds, png Optional outline to font characters Optional packing of characters with outline into 1 channel.
Needs special shader to unpack during rendering, but saves a lot of memory Use TrueType fonts directly from the file without installing them first Documentation The manual is installed with the tool, but for those who wish to take a look at it without installing the tool first it is also available here. Improved handling of out-of-memory conditions. Fixed crash that could occur when exporting unicode characters above 0x with kerning pairs.
Fixed crash when command line argument -c was a relative path and the configuration included font file or image files. Fixed crash when saving configuration file with added font file from the same directory.
Corrected the cell height when using fixed height and supersampling.
Subscribe to RSS
Fixed compatibility with Windows XP. Fixed scaling issues and cropping when using height scale with render from outline. Fixed application freeze when generating very large fonts. The source code is now available under the zlib license. Converted application to compile for Windows with Unicode to better support file and font names with international characters. Updated libpng to 1. Updated zlib to 1. Updated libjpeg to 9a. Updated libsquish to 1. Fixed a problem with exporting glyphs for some international languages.
Added support for Unicode 8. A 64bit build is now available to support huge bitmap fonts that require more than 2GB of memory to generate. The default glyph for invalid characters is now properly rasterized when not rendered from outline too. The status bar now shows the glyph id for the characters.
Added autofit that automatically determines the max font size that fits in defined texture size only available through commandline interface so far Fixed crash on startup if default font doesn't have the Unicode chars in range Added support for file paths with Unicode characters.This collection is here to remedy that, and to bring you pixel-perfect remakes of various type styles from text-mode era PCs - in modern, multi-platform, Unicode-compatible TrueType form plus straight bitmap versions.
Although the goal is to make it a complete resource, the main focus is on hardware character sets: the kind that's located in a ROM chip on the system board or graphics card, which is what you'd see by default when working in text or graphics mode. Software-loadable fonts are also within the scope of this collection if associated with a particular machine or display systemso some of these have also made it in. TrueType fonts have scalable outlines, but to reproduce oldschool raster characters, the outlines are designed to snap to the pixel grid at one particular font size.
Obviously this "native" size differs from font to font, but each font will look best at that native size or integer multiples thereof. This size depends on the original font's pixel dimensions, but scalable text is usually measured in points pt. The font metrics have been tuned so that the "native" point size is an integer in both systems, so with 96 DPI it'll be a multiple of 3and with 72 DPI a multiple of 4. On newfangled super-high-PPI displays scaling artifacts become less apparent, so you may be able to get away with arbitrary sizes.
All fonts replicate the original bitmap characters for modern square-pixel displays. However, the original fonts were mostly used in various non-square pixel resolutions, so aspect ratio is not preserved: most of these fonts will be somewhat squashed vertically, compared to their appearance on original hardware. Aspect-corrected variants may be added in the future. Fonts in this pack come in three variants. Each font has at least the first two:. They are exact duplicates of the original pixel fonts in outline form, and characters are Unicode-mapped for maximum compatibility see below for details.
Bitmap versions of the above. Available only in Windows. FON format for now, but other versions may be added at some point. On top of the CP range, these support extended Latin, Greek, Cyrillic and Hebrew scripts plus a bunch of additional glyphs and Unicode symbols. The extra characters were taken from international versions of the original hardware if availableor designed to closely follow the existing ones. A handful of the cp glyphs had to be remapped here's whybut they're all still around.
Since any TrueType font can and should include a Unicode character map, these are still Unicode fonts with multi-platform support - they just don't include a whole lot of the Unicode range. Mapping CP to Unicode isn't that simple, due to characters 00h-1Fh and 7Fh : they can be interpreted either as control codes, or as graphical symbols.
Trouble is, software that expects one of them may not always play nice with the other one. As a solution, these fonts cover both bases in one mapping: the ambiguous characters are duplicated so that your program will find them at either placement. Instead of just dropping the CP originals, I tried to retain them at remapped code points for the sake of completeness.
Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. I need to do some rudimentary text rendering to a pixel buffer, and I think that having a table indexed by char with the representation of the letters as a binary array would be more than enough Anybody knows about a free header as such?
I could go on with the rest of the alphabet, but then I wouldn't need to ask Update : I tried this approach and the characters come out fairly distorted. Possibly Nimbus is a poor font choice. Even though Nimbus-Mono-Regular is a monospace font, sometimes the character widths are off by a pixel. The convert option "-resize 7x13!
Again, this might be a problem specifically with the Nimbus font. I know you can save images as a c header file in gimp. Maybe you can find a tool which does the job on the command line. So you could automate the creation. ImageMagick can at least load ttf fonts. Loading a tga file is pretty simple. I wouldn't expect a crowdsourced font to look very nice. Learn more. C header file with bitmapped fonts Ask Question.
Asked 10 years, 2 months ago. Active 2 years, 8 months ago. Viewed 25k times. I would store 1 bit per pixel instead of 1 byte per pixel Active Oldest Votes. Go with the imagemagick approach. Brilliant, where did you get this from? I notice that lower scanlines come first and left pixels are in more significant bits. Silicon Graphics released that bit map here: courses.
Could you share the Gimp instructions for producing that code? That's exactly what I want to do to render fonts for a simple embedded system. Server down again. Dolphin Dolphin 4, 1 1 gold badge 26 26 silver badges 25 25 bronze badges.
Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown.Sometimes e. I mostly use xterm then, and I do it most often because I am logged in from remote, and ssh's Xforwarding is too slow. However, I find the standard nethack text-rendering a bit too oldfashioned, so I set out to do something about it. This font uses characters that are unprintable in an xterm, and also I have taken a liking to the X11 nethack tiles so I cannot quite get used to the look Tom's font gives.
I started mapping the charaters that are actually printable in an xterm, and it turns out that there are of them this amounts to the whole ISO character set. Then I noticed that when playing Nethack with colors enabled, some symbols are printed in a bold font.
The bold look is normally done by overstrike, i. However, if a font exists that is the bold counterpart to the font specified for the xterm, xterm will use this font instead. That means that all nethack symbols that are written with the bold font can actually have a totally different look, and this increases the number of possible tiles quite a lot.
Source-diving a little to find out which symbols are written in bold, I created two fonts based on the X11 tile set. In addition to tiles, the fonts contain an almost full set of the ASCII printable characters, except for some letters that are seldom or never used by Nethack other than in "graphical" context. I am quite pleased with the result. Here is screenshot:.
Quite tile-like isn't it?
Some tiles were difficult to convert into two-color characters, most notably I have had to reinvent the gold and the stairs symbols. Playing nethack with the font is a tiny bit confusing at first, because not all monsters and objects are what they seem. For instance, all tools look like a chest except yellow and white tools which look like a lamp.
THE OLDSCHOOL PC FONT RESOURCE
However, once you learn what color the different monsters are disenchanters are blue, for oneyou can most often spot the baddies in the crowd. One problem is that the 16x16 font requires a screen width ofwhich is not always available.
Therefore, I squeezed the font down to 12x12, while trying to retain the same look and feel as the old font had. The screenshot then looks like this:. It looks almost the same, doesn't it, and it only requires a screen width of pixels. Full fontal views taken from the bdfedit font editing program by Thomas Fine :.
Download the following files: nethack Add this to your. The normal xterm colors are not the best for playing nethack.Actually, I just wanted to get some practice in coding user-controls.
I started playing with Rectangles and Brushes and Pens in the onPaint method until I got the idea to set up my own dot-matrix control. A dot-matrix is used to display text and signs in dot-matrix style like LC displays do.
As a spin-off product of this matrix, I got an editor to build a char-set for the matrix. The dot-matrix is built by 16 rows, each containing 16 dots.
To be more precise, 16x16 rectangles. Each rectangle might be filled completely or just with circle shape. As I needed at least some properties for each of the dots rectanglesI started with my own rectangle -class.
Let's call it RectangleXT. Having this done, I could start building the matrix. Well, there are quite some things done in the onPaint method. There are some properties of the rectangles we have to deal with. With an array of 16 integer values, we're now able to define all 16 rows of the matrix. This is done with:. But how about some more letters? OK, take some piece of paper and a pen and start calculating letter " B ". Way too much work, you say? You're right.
I wouldn't have it done this way either. That's why I implemented the ' TeachMode '. In the demo app, you can enable TeachMode with a checkbox. In TeachModeyou can click on the dots in the Matrix to get them enabled or disabled. Keeping the left mouse button pressed, you can easily draw a line. With the right mouse button, you can disable several dots in row. The TextBox below the matrix will show the int of your drawing. That's the way I set up a set of char s to display.Rinky-Dink Electronics, Henning Karlsen.
All Rights Reserved. Select category:. Development Boards. Display Modules. LED Resistor. PCB Trace Width. Resistor Voltage Divider. Converters UTFT. Font Maker. RGB Renderer. UTFT Fonts.
PCBs Shields. Text LCD. Jumbo 7-Segment. Then click here. They will not work with any of my other display libraries. Click on the image to see a full-size version of the font. Click on the download-icon next to the font name to download it. Fonts submitted by users are marked with the icon.
I have not tested these fonts so there may be bugs that I am not aware of.
I am also not responible for any copyright infringements incurred by these fonts. The fonts have been divided into four categories. To use the font you simply copy the downloaded file to your sketch folder.