Well today, I thought it was time to add a new font to my graphics library! Its still very alpha. The new font is complete freeware and is names “Share TechMono” (http://goo.gl/flXU7B). I rendered it using GLCD font creator (http://goo.gl/vmnf5u). The problem with this software however is it spits the data out into bytes and generally scales the fonts to arbritary vertical pixels. I had to wrangle with the font size a bit to make it fit perfectly into 16bits! Another problem lay in converting the output hex bytes into output hex half words. With a brainstorm with one of my work mates on ways to do it, I finally figured it out and made a very quick Matlab script which searches through the array (imported as a string), and replaces the “, 0x” every two hex words, converting a row of x hex bytes into a row of x/2 hex half words. For example:
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
0x0001, 0x0203, 0x0405, 0x0607
The problem here however lay in the arrangement of the bytes! The original byte order worked so the bottom half of the font was first, and the top half was second. I’m not too sure why it was this but I added a bit to my Matlab script to then swap the two hex bytes in a hex half word. For example, the above hex values would then become:
0x0100, 0x0302, 0x0504, 0x0706
I’d link the Matlab but it is of the poorest quality and probably wouldn’t be help to anyway!
With regards to my graphics library, the current smallest font size is actually 16×7, compared to the stock font of 8×5. I will be shrinking this in the future hopefully! This does mean however that as the original font scales in multiples of 8 (because of my interpolation algorithm), this font scales in multiples of 16!
Anyway, I’m sure you’re all bored of my rambling and would like to see a picture of the new sexy font!
My current thoughts on how to select different fonts lies in the previous “Size” parameter. Previously, this parameter would select the size of the stock font and print to the screen. I’ve now decided that this parameter will generally be called “Font”. If this value is <10, the stock font will be picked and the size will be equal to the value of “Font”. If the value is >10 but <20, the value will have 10 subtracted from it and the second font will be used where the newly subtracted value will be the size and so on until I run out of font space!
I’ll be adding more fonts until I start to run out of space so keep tuned!
The code including this font can be found on my github.