X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fmodules%2Fswftext.c;h=76162e765e608a1d5f2249d06c86fed61a3b657a;hb=1d75a2772012bc5cbf238f7d363c650daa6f4c6a;hp=1a9b59fc66e3821ef1ea8f563ce6bf428476793c;hpb=18f4b1c670a1c55cdb33daa77fb2085454a5a125;p=swftools.git diff --git a/lib/modules/swftext.c b/lib/modules/swftext.c index 1a9b59f..76162e7 100644 --- a/lib/modules/swftext.c +++ b/lib/modules/swftext.c @@ -101,7 +101,7 @@ int swf_FontIsBold(SWFFONT * f) static const int WRITEFONTID = 0x4e46; // font id for WriteFont and ReadFont -int swf_FontEnumerate(SWF * swf, void (*FontCallback) (void*, U16, U8 *, void*self), void*self) +int swf_FontEnumerate(SWF * swf, void (*FontCallback) (void*, U16, U8 *), void*self) { int n; TAG *t; @@ -129,7 +129,7 @@ int swf_FontEnumerate(SWF * swf, void (*FontCallback) (void*, U16, U8 *, void*se s[l] = 0; } - (FontCallback) (self, id, s, self); + (FontCallback) (self, id, s); swf_RestoreTagPos(t); } @@ -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;