Font and Bitmap Generator (LCD Font and bitmap to C code)
.
Info
A great (free) font to C code converter can be found at: http://www.mugui.de/bin/menu.php?link=eigenschaften&lang=en
Free registration is needed to activate the full version.
This program has following interesting features:
- Conversion of Windows fonts.
- Conversion of small bitmaps.
- User configurable output through xsl.
- Proportional and monospaced fonts.
- ....
(see above link for a description of all features).
modified xsl output files usable with mbed
I included example fonts generated with this program.
In the program, tab 'Group attributes' - 'Byte orientation' was set to 'Horizontal Left'.
When using these fonts, make sure you read/write the bits in each byte left to right.
Otherwise the font will be mirrored (perhaps also a neat feature).
Have Fun...
Adding 16-bit output
Edit (march 2014)
The ZIP file
containing the modified XSL output files has been updated with an additional file to create 16-bit output (based on the trial code mentioned below).
The code below is a trial to concatenate 2 consecutive bytes.
Test this code by opening any Tryit Editor
window at w3schools (eg : http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=cdcatalog_ex3) OR xsltransform.net
(runs fine in Chrome, not in IE10).
First, erase the content of the XML and XSLT code windows.
Next, copy the content of the 2 listings below into their corresponding window.
Finally, click on the Edit and Click Me
button to see the result.
Listing 1
Replace the contents of the XML Code window with this listing.
<?xml version="1.0" encoding="utf-8"?> <project> <version>0.1.0.2</version> <projectname>TaleGator</projectname> <group> <bytesperbitmap>0</bytesperbitmap> <numberofbitmaps>244</numberofbitmaps> <startcharacter>0</startcharacter> <width>16</width> <height>15</height> <groupname>SegoeUI</groupname> <designer>Imported System Font</designer> <date>06 Mar 2014</date> <description>Imported System Font</description> <byteorientation>verticalBottom</byteorientation> <ascenderheight>1</ascenderheight> <descenderheight>1</descenderheight> <proportional>True</proportional> <bitmap> <bitmapwidth>16</bitmapwidth> <bitmapheight>15</bitmapheight> <bytesperbitmap>32</bytesperbitmap> <bytesperbitmapline>2</bytesperbitmapline> <byte>0x00</byte> <byte>0x01</byte> <byte>0x02</byte> <byte>0x03</byte> <byte>0x04</byte> <byte>0x05</byte> <byte>0x06</byte> <byte>0x07</byte> <byte>0x08</byte> <byte>0x09</byte> <byte>0x0A</byte> <byte>0x0B</byte> <byte>0x0C</byte> <byte>0x0D</byte> <byte>0x0E</byte> <byte>0x0F</byte> <byte>0x10</byte> <byte>0x11</byte> <byte>0x12</byte> <byte>0x13</byte> <byte>0x14</byte> <byte>0x15</byte> <byte>0x16</byte> <byte>0x17</byte> <byte>0x18</byte> <byte>0x19</byte> <byte>0x1A</byte> <byte>0x1B</byte> <byte>0x1C</byte> <byte>0x1D</byte> <byte>0x1E</byte> <byte>0x1F</byte> </bitmap> </group> </project>
Listing 2
Note : The double if at the end checks for an uneven number of bytes to pad the last byte with '00'.
You can test this by adding a single <byte>0x20</byte>
at the end of the </bitmap> list.
Replace the contents of the XSLT Code window with this listing.
<?xml version="1.0" encoding="ISO-8859-1"?> <!-- Edited by XMLSpy® --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <xsl:for-each select="project/group/bitmap/byte"> <xsl:choose> <xsl:when test="position() mod 2 = 1"> <xsl:value-of select="." /> </xsl:when> <xsl:otherwise> <xsl:value-of select="substring(., 3, 2)"/> <xsl:if test="position()!=last()"> <xsl:text> ,</xsl:text> </xsl:if> </xsl:otherwise> </xsl:choose> <xsl:if test="position()=last()"> <xsl:if test="position() mod 2 = 1"> <xsl:text>00</xsl:text> </xsl:if> </xsl:if> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet>
This is the output.
0x0001 ,0x0203 ,0x0405 ,0x0607 ,0x0809 ,0x0A0B ,0x0C0D ,0x0E0F ,0x1011 ,0x1213 ,0x1415 ,0x1617 ,0x1819 ,0x1A1B ,0x1C1D ,0x1E1F
10 comments on Font and Bitmap Generator (LCD Font and bitmap to C code):
Please log in to post comments.
Need help with XSLT V1.0 conversion.
Very nice, flexible font & bitmap generator!
I have used Frank Vannieuwkerke's transformation file however I would like to create output files that result in uint16_t 16-bit data font files rather than the 8-bit unsigned integer char files it currently provides. I have no previous experience with XSLT transformations however upon studying the architecture, I have learned enough to get me into trouble and stuck only partially meeting my objective. A 16-bit font file structure would reduce overhead processing for my application leaving resources to focus more on other processing requirements instead of assembling 8-bit data into 16-bit font conversions.The schema of the temporary XML file output of the program which the XSL transformation stylesheet would be based upon is here: /media/uploads/dtmort/testxmlout
I can manipulate some of the XSL stylesheet however I am out of my element attempting concatenation of the hexadecimal 'byte' elements into half as many 16-bit 'words' as well as the recursive index generation to match.
Having zero experience with this leaves me at a deficit. Any help is appreciated.