X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=lib%2Fmodules%2Fswftext.c;h=76162e765e608a1d5f2249d06c86fed61a3b657a;hb=dfd8a7513517382f581d82581152f66a3d6c1faa;hp=869098909a6d52f173d058d1953df586a7661c29;hpb=e86d3573f78de7a1e0cde393190372e6085ce217;p=swftools.git diff --git a/lib/modules/swftext.c b/lib/modules/swftext.c index 8690989..76162e7 100644 --- a/lib/modules/swftext.c +++ b/lib/modules/swftext.c @@ -592,7 +592,7 @@ static void font_freename(SWFFONT*f) } } -int swf_FontReduce(SWFFONT * f) +int swf_FontReduce_old(SWFFONT * f) { int i, j; int max_unicode = 0; @@ -635,6 +635,41 @@ int swf_FontReduce(SWFFONT * f) return j; } +int swf_FontReduce(SWFFONT * f) +{ + int i; + int max_unicode = 0; + int max_glyph = 0; + if ((!f) || (!f->use) || f->use->is_reduced) + return -1; + + for (i = 0; i < f->numchars; i++) { + if(!f->use->chars[i]) { + f->glyph2ascii[i] = 0; + if(f->glyph[i].shape) { + swf_ShapeFree(f->glyph[i].shape); + f->glyph[i].shape = 0; + f->glyph[i].advance = 0; + } + } else { + max_glyph = i+1; + } + } + for (i = 0; i < f->maxascii; i++) { + if(!f->use->chars[f->ascii2glyph[i]]) { + f->ascii2glyph[i] = -1; + } else { + max_unicode = i+1; + } + } + f->maxascii = max_unicode; + f->numchars = max_glyph; + font_freelayout(f); + font_freeglyphnames(f); + font_freename(f); + return 0; +} + void swf_FontSort(SWFFONT * font) { int i, j, k; @@ -741,7 +776,7 @@ int swf_FontUseGlyph(SWFFONT * f, int glyph) { if (!f->use) swf_FontInitUsage(f); - if(glyph < 0 || glyph > f->numchars) + if(glyph < 0 || glyph >= f->numchars) return -1; f->use->chars[glyph] = 1; return 0;