I am trying to use a small 5x7 bitmap font in BDF format and when I use ftrasterize to convert it to a C file I have two problems:
the name of the bitmap array and font structure name have an invalid character (0x15) eg. if I use /ftrasterize.exe -v -f 5x7test -s F0 5x7.bdf then I get the names:
g_sFont[0x15]x7test0 and g_pui8[0x15]x7test0Data where [0x15] is the invalid character. Looking at the source code for ftrasterize, I can see that when I use the F0 option for the fixed font size it uses the pParams->iSize variable which for the fixed font option is the selected size index of 0. When the C file is created it uses this variable to create the font data array name with :
fprintf(pFile, "static const uint8_t g_pui8%s%d%s%sData[%d] =\n",
pcCapFilename, pParams->iSize, pParams->bBold ? "b" : "",
pParams->bItalic ? "i" : "", iOpt);
and the tFont name
fprintf(pFile, "const tFont g_sFont%s%d%s%s =\n", pcCapFilename,
pParams->iSize, pParams->bBold ? "b" : "",
pParams->bItalic ? "i" : "");
and reference to the data pointer at the bottom of the structure
fprintf(pFile, " g_pui8%s%d%s%sData\n", pcCapFilename,
pParams->iSize, pParams->bBold ? "b" : "",
pParams->bItalic ? "i" : "");
Unfortunately the value of iSize is not the font width but rather the size index. I'm not sure why it converts this as the 0x15 character, but it is obviously a bug when you are using a fixed font index option.
The other issue I am having is when I use the C file and print a string of characters, there is no pixel space between them. The glyphs of the font are 5 pixels wide with each character being 4 pixels wide and the fifth column being blank to provide a space between characters. However, it appears that the character encoding of ftrasterize doesn't allow for this unused pixel and the maximum width of the characters is spec'd as 4 not 5. I assume that this is why there is no space between them when they are displayed as a string. I have done a verbose listing :
ftrasterize.exe -v -f 5x7test -s F0 5x7.bdf
FTRasterize: Generate a TivaWare GrLib-compatible font.
Copyright 2008-2011 Texas Instruments Incorporated.
Command line arguments parsed.
Generating a narrow format font.
Encoding characters 32 to 126. Using tFont format.
Selected size index 0 (5 x 7).
Rendering individual character glyphs...
Forcing character 0x20 to be a space.
Character 0x21: 5 x 7, pitch 1, top 6
Character 0x21: xMin 2, xMax 2
Character 0x22: 5 x 7, pitch 1, top 6
Character 0x22: xMin 1, xMax 3
...
Character 0x7e: 5 x 7, pitch 1, top 6
Character 0x7e: xMin 0, xMax 3
Finding maximum character dimensions...
Maximum values - Width 4, YMax 0, YMin 6
Compressing glyphs...
Error compressing glyph. pucData 0x00000000, iMaxX 0
Error on compressing glyph 20!
Compressed glyph 0x21. Width 1, 4 bytes of data.
Compressed glyph 0x22. Width 3, 7 bytes of data.
Compressed glyph 0x23. Width 5, 11 bytes of data.
...
Compressed glyph 0x7d. Width 3, 9 bytes of data.
Compressed glyph 0x7e. Width 4, 7 bytes of data.
Writing output file...
Finished.
When I use the -n option I get this:
ftrasterize.exe -v -n -f 5x7test -s F0 5x7.bdf
FTRasterize: Generate a TivaWare GrLib-compatible font.
Copyright 2008-2011 Texas Instruments Incorporated.
Command line arguments parsed.
Generating a narrow format font.
Encoding characters 32 to 126. Using tFont format.
Selected size index 0 (5 x 7).
Rendering individual character glyphs...
Character 0x20: 5 x 7, pitch 1, top 6
Character 0x20: xMin 1000000, xMax 0
Set char 0x20 width to 5 pixels.
Character 0x21: 5 x 7, pitch 1, top 6
Character 0x21: xMin 2, xMax 2
...
Character 0x7e: 5 x 7, pitch 1, top 6
Character 0x7e: xMin 0, xMax 3
Finding maximum character dimensions...
Maximum values - Width 5, YMax 0, YMin 6
Compressing glyphs...
Compressed glyph 0x20. Width 6, 5 bytes of data.
Compressed glyph 0x21. Width 1, 4 bytes of data.
Compressed glyph 0x22. Width 3, 7 bytes of data.
...
Compressed glyph 0x7d. Width 3, 9 bytes of data.
Compressed glyph 0x7e. Width 4, 7 bytes of data.
Writing output file...
Finished.
This gives me a maximum font width of 6 in the C file, but I still don't get a space between characters. I don't understand the issue here unless, the encoding is incorrect. When I don't specify the -n option, I get a maximum width of 4 characters. I notice that after running this again after using the n option, the C file now says I have a maximum character width of 5 !
Can someone please explain how I can fix the problem of no space between the characters ?
Thanks.
Jeff