X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;ds=sidebyside;f=pdf2swf%2Fswfoutput.cc;h=f8554611e60710db9b2a062a688cc65f763353c1;hb=1af0478a84d39d07423587378385149169bbfd28;hp=728b2b2f3720fde37b245e361a07a01907d2834c;hpb=c26c4103d3b4ad7aa85513d2dd5a125c2773b818;p=swftools.git diff --git a/pdf2swf/swfoutput.cc b/pdf2swf/swfoutput.cc index 728b2b2..f855461 100644 --- a/pdf2swf/swfoutput.cc +++ b/pdf2swf/swfoutput.cc @@ -59,6 +59,7 @@ struct fontlist_t fontlist_t*next; }; +double config_dumpfonts=0; double config_ppmsubpixels=0; double config_jpegsubpixels=0; int config_opennewwindow=1; @@ -73,6 +74,7 @@ int config_splinemaxerror=1; int config_fontsplinemaxerror=1; int config_filloverlap=0; int config_protect=0; +int config_bboxvars=0; float config_minlinewidth=0.05; double config_caplinewidth=1; @@ -713,6 +715,9 @@ static void putcharacter(struct swfoutput*obj, int fontid, int charid, int x,int If we set it to low, however, the char positions will be inaccurate */ #define FONT_INTERNAL_SIZE 4 +static int font_active = 0; +static char* font_active_filename = 0; + /* process a character. */ static int drawchar(struct swfoutput*obj, SWFFONT *swffont, char*character, int charnr, int u, swfmatrix*m, gfxcolor_t*col) { @@ -723,6 +728,16 @@ static int drawchar(struct swfoutput*obj, SWFFONT *swffont, char*character, int } int charid = getCharID(swffont, charnr, character, u); + if(font_active) { + char buf[1024]; + sprintf(buf, "%s.usage", font_active_filename); + FILE*fi = fopen(buf, "ab+"); + if(fi) { + fprintf(fi, "%d %d %d %s\n", charnr, u, charid, character); + fclose(fi); + } else + msg(" Couldn't write to %s", buf); + } if(charid<0) { msg(" Didn't find character '%s' (c=%d,u=%d) in current charset (%s, %d characters)", @@ -866,11 +881,11 @@ int getCharID(SWFFONT *font, int charnr, char *charname, int u) return -1; } - /* set's the t1 font index of the font to use for swfoutput_drawchar(). */ void swfoutput_setfont(struct swfoutput*obj, char*fontid, char*filename) { swfoutput_internal*i = (swfoutput_internal*)obj->internal; + font_active = 0; fontlist_t*last=0,*iterator; if(!fontid) { msg(" No fontid"); @@ -902,6 +917,11 @@ void swfoutput_setfont(struct swfoutput*obj, char*fontid, char*filename) swf_SetLoadFontParameters(64,/*skip unused*/0,/*full unicode*/1); SWFFONT*swffont = swf_LoadFont(filename); + if(config_dumpfonts) { + font_active = 1; + font_active_filename = strdup(filename); + } + if(swffont == 0) { msg(" Couldn't load font %s (%s)", fontid, filename); swffont = swf_LoadFont(0); @@ -927,6 +947,10 @@ void swfoutput_setfont(struct swfoutput*obj, char*fontid, char*filename) swffont->encoding = 255; } } + + if(swffont->encoding != FONT_ENCODING_UNICODE && swffont->encoding != 255) { + msg(" Non-unicode mapping for font %s (%s)", fontid, filename); + } swf_FontSetID(swffont, getNewID(obj)); @@ -1374,6 +1398,22 @@ static void endshape(swfoutput*obj) }*/ } +void wipeSWF(SWF*swf) +{ + TAG*tag = swf->firstTag; + while(tag) { + TAG*next = tag->next; + if(tag->id != ST_SETBACKGROUNDCOLOR && + tag->id != ST_END && + tag->id != ST_DOACTION && + tag->id != ST_SHOWFRAME) { + swf_DeleteTag(tag); + } + tag = next; + } +} + + void swfoutput_finalize(struct swfoutput*obj) { swfoutput_internal*i = (swfoutput_internal*)obj->internal; @@ -1381,6 +1421,32 @@ void swfoutput_finalize(struct swfoutput*obj) if(i->tag && i->tag->id == ST_END) return; //already done + if(config_bboxvars) { + TAG* tag = swf_InsertTag(i->swf.firstTag, ST_DOACTION); + ActionTAG*a = 0; + a = action_PushString(a, "xmin"); + a = action_PushFloat(a, i->swf.movieSize.xmin / 20.0); + a = action_SetVariable(a); + a = action_PushString(a, "ymin"); + a = action_PushFloat(a, i->swf.movieSize.ymin / 20.0); + a = action_SetVariable(a); + a = action_PushString(a, "xmax"); + a = action_PushFloat(a, i->swf.movieSize.xmax / 20.0); + a = action_SetVariable(a); + a = action_PushString(a, "ymax"); + a = action_PushFloat(a, i->swf.movieSize.ymax / 20.0); + a = action_SetVariable(a); + a = action_PushString(a, "width"); + a = action_PushFloat(a, (i->swf.movieSize.xmax - i->swf.movieSize.xmin) / 20.0); + a = action_SetVariable(a); + a = action_PushString(a, "height"); + a = action_PushFloat(a, (i->swf.movieSize.ymax - i->swf.movieSize.ymin) / 20.0); + a = action_SetVariable(a); + a = action_End(a); + swf_ActionSet(tag, a); + swf_ActionFree(a); + } + if(i->frameno == i->lastframeno) // fix: add missing pagefeed swfoutput_pagefeed(obj); @@ -1431,20 +1497,6 @@ void swfoutput_getdimensions(struct swfoutput*obj, int*x1, int*y1, int*x2, int*y if(y2) *y2 = i->swf.movieSize.ymax/20; } -void wipeSWF(SWF*swf) -{ - TAG*tag = swf->firstTag; - while(tag) { - TAG*next = tag->next; - if(tag->id != ST_SETBACKGROUNDCOLOR && - tag->id != ST_END && - tag->id != ST_SHOWFRAME) { - swf_DeleteTag(tag); - } - tag = next; - } -} - int swfoutput_save(struct swfoutput* obj, char*filename) { swfoutput_internal*i = (swfoutput_internal*)obj->internal; @@ -1967,6 +2019,8 @@ void swfoutput_setparameter(char*name, char*value) config_storeallcharacters = atoi(value); } else if(!strcmp(name, "enablezlib")) { config_enablezlib = atoi(value); + } else if(!strcmp(name, "bboxvars")) { + config_bboxvars = atoi(value); } else if(!strcmp(name, "insertstop")) { config_insertstoptag = atoi(value); } else if(!strcmp(name, "protected")) { @@ -1977,6 +2031,8 @@ void swfoutput_setparameter(char*name, char*value) config_minlinewidth = atof(value); } else if(!strcmp(name, "caplinewidth")) { config_caplinewidth = atof(value); + } else if(!strcmp(name, "dumpfonts")) { + config_dumpfonts = atoi(value); } else if(!strcmp(name, "jpegquality")) { int val = atoi(value); if(val<0) val=0;