X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=lib%2Fgfxfont.c;h=c60c86b5c578aa3fd7306818f78a4b819a9f3b6e;hb=328cd76b365ba8ea45127e06bb4bf87d6da0709b;hp=12e6725e8061688d3c3ed0e4003a9f832d70aa3b;hpb=76d7de03a9ce370259976be5412508b9182b5bb3;p=swftools.git diff --git a/lib/gfxfont.c b/lib/gfxfont.c index 12e6725..c60c86b 100644 --- a/lib/gfxfont.c +++ b/lib/gfxfont.c @@ -104,25 +104,6 @@ static FT_Outline_Funcs outline_functions = static FT_Library ftlibrary = 0; -gfxline_t * clonePath(gfxline_t*line) -{ - gfxline_t*dest = 0; - gfxline_t*pos = 0; - while(line) { - gfxline_t*n = rfx_calloc(sizeof(gfxline_t)); - *n = *line; - n->next = 0; - if(!pos) { - dest = pos = n; - } else { - pos->next = n; - pos = n; - } - line = line->next; - } - return dest; -} - static gfxglyph_t cloneGlyph(gfxglyph_t*src) { gfxglyph_t dest; @@ -131,7 +112,7 @@ static gfxglyph_t cloneGlyph(gfxglyph_t*src) dest.name = strdup(src->name); dest.advance = src->advance; dest.unicode = src->unicode; - dest.line = clonePath(src->line); + dest.line = gfxline_clone(src->line); return dest; } @@ -141,7 +122,23 @@ static void glyph_clear(gfxglyph_t*g) if(g->name) { free(g->name); g->name = 0; } - gfxline_free(g->line); + gfxline_free(g->line);g->line = 0; +} + +void gfxfont_free(gfxfont_t*font) +{ + int t; + for(t=0;tnum_glyphs;t++) { + glyph_clear(&font->glyphs[t]); + } + if(font->glyphs) { + free(font->glyphs);font->glyphs = 0; + } + font->num_glyphs = 0; + if(font->unicode2glyph) { + free(font->unicode2glyph);font->unicode2glyph = 0; + } + free(font); } gfxfont_t* gfxfont_load(char*filename) @@ -194,9 +191,9 @@ gfxfont_t* gfxfont_load(char*filename) //font->glyphnames = rfx_calloc(face->num_glyphs*sizeof(char*)); } - name = FT_Get_Postscript_Name(face); + /*name = FT_Get_Postscript_Name(face); if(name && *name) - font->name = strdup(name); + font->name = strdup(name);*/ while(1) { @@ -235,7 +232,6 @@ gfxfont_t* gfxfont_load(char*filename) font->max_unicode = 65535; font->unicode2glyph = rfx_calloc(font->max_unicode*sizeof(int)); - glyph2unicode = (int*)rfx_calloc(face->num_glyphs*sizeof(int)); for(t=0;tmax_unicode;t++) { int g = FT_Get_Char_Index(face, t); @@ -253,8 +249,6 @@ gfxfont_t* gfxfont_load(char*filename) font->num_glyphs = 0; - glyph2glyph = (int*)rfx_calloc(face->num_glyphs*sizeof(int)); - for(t=0; t < face->num_glyphs; t++) { FT_Glyph glyph; FT_BBox bbox; @@ -348,7 +342,7 @@ gfxfont_t* gfxfont_load(char*filename) FT_Done_Face(face); FT_Done_FreeType(ftlibrary);ftlibrary=0; - + if(!isunicode && font->num_glyphs>0) { /* if the encoding isn't unicode, remap the font so that the encoding equals the char position, and