masterzorag's Activity

Sunday, May 3, 2015

X-BitMap fonts

Was looking at a raw C way to print to screen painting by pixel (to raw framebuffers) when, evaluating conversion from TrueTypeFont to a well suited, handy format I faced X-BitMaps images.

So, I've spended some bytes writing a script that convert an ASCII code range of ttf labels into xbm glyphs: genXBMfonts uses ImageMagick's convert tool to write single 16x16 pixel, 1bpp XBM images, as C header of 32 chars.

xbm_dump called by genXBMfonts, (XBM is an image)
After that, I can copy my definition header in my project, and without the need of external library to include I can address text to glyph bits[], decode back (bit)checking and print text addressing the destination pixel:
 
When painting on raw framebuffer we have control on color, as well.
initiated public repository: https://github.com/masterzorag/xbm_tools

About portability, this is a sample psl1ght app including the same C header definition, running on the ps3: