summaryrefslogtreecommitdiff
path: root/tools/genfont/genfont.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/genfont/genfont.c')
-rw-r--r--tools/genfont/genfont.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/tools/genfont/genfont.c b/tools/genfont/genfont.c
index 7553e4c..775d142 100644
--- a/tools/genfont/genfont.c
+++ b/tools/genfont/genfont.c
@@ -7,7 +7,9 @@
* This file is released under the GNU General Public License. Refer
* to the COPYING file distributed with this package.
*
- * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
+ * (c) 2004-2010 Andreas Regel <andreas.regel AT powarman.de>
+ * (c) 2010-2011 Wolfgang Astleitner <mrwastl AT users sourceforge net>
+ * Andreas 'randy' Weinberger
*/
#include <getopt.h>
@@ -17,6 +19,8 @@
#include <glcdgraphics/bitmap.h>
#include <glcdgraphics/font.h>
+#include <glcdgraphics/image.h>
+#include <glcdgraphics/pbm.h>
static const char *prgname = "genfont";
static const char *version = "0.0.2";
@@ -136,13 +140,14 @@ int main(int argc, char *argv[])
fprintf(descFile, "spacebetween:%d\n", 0);
fprintf(descFile, "spacewidth:%d\n", 0);
- for (unsigned int i = 0; i < 256; i++)
+ for (uint32_t i = 0; i < 256; i++)
{
- const GLCD::cBitmap * charBitmap = font.GetCharacter((char) i);
+ const GLCD::cBitmap * charBitmap = font.GetCharacter(i);
+
if (charBitmap == NULL)
continue;
- bitmap->DrawBitmap(posX, posY, *charBitmap, GLCD::clrBlack);
+ bitmap->DrawBitmap(posX, posY, *charBitmap);
fprintf(descFile, "%d %d ", posX, i);
posX += charBitmap->Width();
if ((i % 32) == 31)
@@ -156,9 +161,23 @@ int main(int argc, char *argv[])
if (posX > 0) // write last end marker
fprintf(descFile, "%d\n", posX);
fileName = outputName + ".pbm";
- bitmap->SavePBM(fileName);
- delete bitmap;
+
+ GLCD::cPBMFile pbm;
+ GLCD::cImage* image = new GLCD::cImage();
+
+ if (!image)
+ return 3;
+
+ image->AddBitmap(bitmap);
+
+ if (pbm.Save(*image, fileName) == false) {
+ fprintf(stderr, "Cannot save file: %s\n",fileName.c_str());
+ delete image;
+ return 2;
+ }
+
fclose(descFile);
+ delete image;
}
fprintf(stdout, "Font successfully generated.\n");