X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Ffilters%2Fremove_font_transforms.c;h=c94ee94976d73021731b71acf603df71a6ff8577;hp=c92816c47ec56816f914af6445d7ec595e175180;hb=a51d4f82e57c96baa125d0937870d1e4896d6ee3;hpb=61d532661dfc369cffa7b2c6cbf046f2d0d4ad29 diff --git a/lib/filters/remove_font_transforms.c b/lib/filters/remove_font_transforms.c index c92816c..c94ee94 100644 --- a/lib/filters/remove_font_transforms.c +++ b/lib/filters/remove_font_transforms.c @@ -137,7 +137,12 @@ static transformedfont_t* transformedfont_new(gfxfont_t*orig, mymatrix_t*m) transformedfont_t*f = rfx_calloc(sizeof(transformedfont_t)); f->orig = orig; f->matrix = *m; - f->used = malloc(sizeof(f->used[0])*orig->num_glyphs); + f->used = rfx_calloc(sizeof(f->used[0])*orig->num_glyphs); + int t; + for(t=0;tnum_glyphs;t++) { + if(orig->glyphs[t].unicode==32) + f->used[t]=1; //always preserve the space char in fonts + } return f; } @@ -145,7 +150,9 @@ static void pass1_drawchar(gfxfilter_t*f, gfxfont_t*font, int glyphnr, gfxcolor_ { internal_t*i = (internal_t*)f->internal; mymatrix_t m; - matrix_convert(matrix, font->id, &m, 0); + if(!font->id) + msg(" Font has no ID"); + matrix_convert(matrix, font->id?font->id:"unknown", &m, 0); transformedfont_t*fd = dict_lookup(i->matrices, &m); if(!fd) { fd = transformedfont_new(font, &m); @@ -212,7 +219,7 @@ static gfxresult_t* pass1_finish(gfxfilter_t*f, gfxdevice_t*out) fd->dx = -total.xmin; font->ascent = total.ymax; - font->descent = total.ymin; + font->descent = -total.ymin; for(t=0;tglyphs[t].line; @@ -246,7 +253,7 @@ static void pass2_drawchar(gfxfilter_t*f, gfxfont_t*font, int glyphnr, gfxcolor_ mymatrix_t m; gfxmatrix_t scalematrix; - matrix_convert(matrix, font->id, &m, &scalematrix); + matrix_convert(matrix, font->id?font->id:"unknown", &m, &scalematrix); transformedfont_t*d = dict_lookup(i->matrices, &m); scalematrix.tx -= d->dx*scalematrix.m00; out->drawchar(out, d->font, d->used[glyphnr], color, &scalematrix);