fixed some compiler warnings
[swftools.git] / lib / gfxfont.c
index e6f96cb..920796d 100644 (file)
@@ -22,6 +22,8 @@
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 #include <assert.h>
+#include <stdio.h>
+#include <memory.h>
 #include "../config.h"
 #include "gfxdevice.h"
 #include "gfxtools.h"
@@ -393,7 +395,7 @@ gfxfont_t* gfxfont_load(const char*id, const char*filename, unsigned int flags,
                }
                l = l->next;
            }
-           if(!ok && !name) {
+           if(!ok && !hasname) {
                gfxline_free(font->glyphs[font->num_glyphs].line);
                font->glyphs[font->num_glyphs].line = 0;
                font->glyphs[font->num_glyphs].advance = 0;
@@ -492,7 +494,7 @@ gfxfont_t* gfxfont_load(const char*id, const char*filename, unsigned int flags,
 }
 #else
 
-gfxfont_t* gfxfont_load(char*id, char*filename, unsigned int flags, double quality)
+gfxfont_t* gfxfont_load(const char*id, const char*filename, unsigned int flags, double quality)
 {
     fprintf(stderr, "No freetype support compiled in! Not able to load %s\n", filename);
     return 0;
@@ -557,7 +559,22 @@ void gfxfont_fix_unicode(gfxfont_t*font)
            max = u;
     }
     free(used);
-    
+    if(font->unicode2glyph) {
+       free(font->unicode2glyph);
+    }
+    font->unicode2glyph = 0;
+    font->max_unicode = 0;
+}
+
+void gfxfont_add_unicode2glyph(gfxfont_t*font)
+{ 
+    int t;
+    int max = 0;
+    for(t=0;t<font->num_glyphs;t++) {
+       int u = font->glyphs[t].unicode;
+       if(u > max)
+           max = u;
+    }
     if(!font->unicode2glyph) {
        /* (re)generate unicode2glyph-to-glyph mapping table by reverse mapping
           the glyph unicode2glyph's indexes into the mapping table. For collisions,