X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fmodules%2Fswftext.c;h=76162e765e608a1d5f2249d06c86fed61a3b657a;hb=1d75a2772012bc5cbf238f7d363c650daa6f4c6a;hp=9a97d87048c19bdb817a886784b77ae2aa2a829c;hpb=d3e97bc274ac9534c72c29fa466f89fe4459f6e2;p=swftools.git diff --git a/lib/modules/swftext.c b/lib/modules/swftext.c index 9a97d87..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; @@ -1015,7 +1050,7 @@ int swf_TextSetInfoRecord(TAG * t, SWFFONT * font, U16 size, RGBA * color, int d swf_SetRGB(t, color); } if (dx) { - if(dx == SET_TO_ZERO) { + if(dx != SET_TO_ZERO) { if(dx>32767 || dx<-32768) fprintf(stderr, "Warning: Horizontal char position overflow: %d\n", dx); swf_SetS16(t, dx); @@ -1024,7 +1059,7 @@ int swf_TextSetInfoRecord(TAG * t, SWFFONT * font, U16 size, RGBA * color, int d } } if (dy) { - if(dy == SET_TO_ZERO) { + if(dy != SET_TO_ZERO) { if(dy>32767 || dy<-32768) fprintf(stderr, "Warning: Vertical char position overflow: %d\n", dy); swf_SetS16(t, dy);