minor fixes: swf_SetBits(), cleanup shape struct, fixed dumpfont
[swftools.git] / lib / example / dumpfont.c
index 986f853..1481ed6 100644 (file)
@@ -25,7 +25,7 @@
 #include <unistd.h>
 #include "../rfxswf.h"
 
-#define PRINTABLE(a) ((a>='A')&&(a<='Z'))||((a>='a')&&(a<='z'))||((a>='0')&&(a<='9'))
+#define PRINTABLE(a) (((a>0x20)&&(a<0xff)&&(a!='\\'))?a:0x20)
 
 SWF swf;
 
@@ -68,13 +68,13 @@ void DumpFont(SWFFONT * f,char * name)
   printf("  f->glyph    = (SWFGLYPH*)malloc(sizeof(SWFGLYPH)*%d);\n",f->numchars);
   printf("  f->glyph2ascii = (U16*)malloc(sizeof(U16)*%d);\n",f->numchars);
   printf("  f->ascii2glyph = (int*)malloc(sizeof(int)*%d);\n",f->maxascii);
-  printf("  memset(f->ascii2glyph, -1, sizeof(int)*%d)\n\n", f->maxascii);
+  printf("  memset(f->ascii2glyph, -1, sizeof(int)*%d);\n\n", f->maxascii);
 
   for (i=0;i<f->numchars;i++)
     if (f->glyph[i].shape)
     { printf("  addGlyph(f,%3i, 0x%02x,%4i, &Glyphs_%s[0x%04x],%4i); // %c\n",
              i, f->glyph2ascii[i], f->glyph[i].advance, name, gpos[i],
-             f->glyph[i].shape->bitlen,(i!='\\')?i:0x20);
+             f->glyph[i].shape->bitlen,PRINTABLE(f->glyph2ascii[i]));
     }
 
   printf("  return f;\n}\n\n");