X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2Fswfoutput.cc;h=f84ebee32795b465c8875141bffa4fe1095f857d;hb=71e57080c599ffd3ca6565e6b152a2f3fc137c62;hp=3fd1379082a7d8aef9f83e06c82789fd794d5fce;hpb=e448c7a56df8e289c9dbd5b8d87753addd541091;p=swftools.git diff --git a/pdf2swf/swfoutput.cc b/pdf2swf/swfoutput.cc index 3fd1379..f84ebee 100644 --- a/pdf2swf/swfoutput.cc +++ b/pdf2swf/swfoutput.cc @@ -27,10 +27,14 @@ extern "C" { #include "../lib/log.h" #include "../lib/rfxswf.h" } +#define standardEncodingSize 335 +extern char *standardEncodingNames[standardEncodingSize]; +int opennewwindow=0; int ignoredraworder=0; int drawonlyshapes=0; int jpegquality=85; +int storeallcharacters=0; static int flag_protected = 0; typedef unsigned char u8; @@ -333,7 +337,7 @@ void putcharacters(TAG*tag) } if(charstorepos && pass==1) { - tag->bitcount = 0; + tag->writeBit = 0; // Q&D swf_SetBits(tag, 0, 1); // GLYPH Record swf_SetBits(tag, charstorepos, 7); // number of glyphs int s; @@ -366,7 +370,7 @@ void putcharacters(TAG*tag) if(lastfontid != chardata[t].fontid || lastsize != chardata[t].size) newfont = &font; - tag->bitcount = 0; + tag->writeBit = 0; // Q&D swf_TextSetInfoRecord(tag, newfont, chardata[t].size, newcolor, newx,newy); } @@ -515,6 +519,9 @@ SWFFont::SWFFont(char*name, int id, char*filename) outline = (T1_OUTLINE**)malloc(t*sizeof(T1_OUTLINE*)); charname = (char**)malloc(t*sizeof(char*)); + width = (int*)malloc(t*sizeof(int)); + memset(width, 0, t*sizeof(int)); + memset(charname, 0, t*sizeof(char*)); used = (char*)malloc(t*sizeof(char)); char2swfcharid = (U16*)malloc(t*2); swfcharid2char = (U16*)malloc(t*2); @@ -549,6 +556,7 @@ SWFFont::SWFFont(char*name, int id, char*filename) for(s=0;soutline[outlinepos] = T1_CopyOutline(T1_GetCharOutline(id, s, 100.0, 0)); + this->width[outlinepos] = T1_GetCharWidth(id, s); this->charname[outlinepos] = strdup(T1_GetCharName(id, s)); outlinepos++; } @@ -561,7 +569,19 @@ SWFFont::SWFFont(char*name, int id, char*filename) SWFFont::~SWFFont() { int t,usednum=0; - int*ptr = (int*)malloc(swfcharpos*sizeof(int)); + int*ptr; + + if(storeallcharacters) + { + int t; + for(t=0;tcharnum;t++) + { + if(this->charname[t]) + getSWFCharID(this->charname[t]); + } + } + + ptr = (int*)malloc(swfcharpos*sizeof(int)); for(t=0;tswfid); + if(this->fontid) { + swf_SetU8(ftag, strlen(this->fontid)); + swf_SetBlock(ftag, (U8*)this->fontid, strlen(this->fontid)); + } else { + swf_SetU8(ftag, 0); + } + swf_SetU8(ftag, 0); //flags + for(t=0;tcharname[this->swfcharid2char[t]]; + for(s=0;s<256;s++) { + if(standardEncodingNames[s] && + !strcmp(name,standardEncodingNames[s])) + break; + } + swf_SetU8(ftag, (U8)s); + } } free(ptr); @@ -607,6 +648,7 @@ SWFFont::~SWFFont() for(t=0;t=0) + endshape(); + if(textid>=0) + endtext(); + + actions = swf_ActionStart(); + if(opennewwindow) + action_GetUrl(url, "_parent"); + else + action_GetUrl(url, "_this"); + action_End(); + swf_ActionEnd(); + + drawlink(obj, actions, points); +} +void swfoutput_linktopage(struct swfoutput*obj, int page, swfcoord*points) +{ + ActionTAG* actions; + + if(shapeid>=0) + endshape(); + if(textid>=0) + endtext(); + + actions = swf_ActionStart(); + action_GotoFrame(page); + action_End(); + swf_ActionEnd(); + + drawlink(obj, actions, points); +} + +void drawlink(struct swfoutput*obj, ActionTAG*actions, swfcoord*points) +{ + RGBA rgb; + SRECT r; + int lsid=0; + int fsid; + struct plotxy p1,p2,p3,p4; + int myshapeid; + int myshapeid2; + double xmin,ymin; + double xmax=xmin=points[0].x,ymax=ymin=points[0].y; + int t; + int buttonid = ++currentswfid; + for(t=1;t<4;t++) + { + if(points[t].x>xmax) xmax=points[t].x; + if(points[t].y>ymax) ymax=points[t].y; + if(points[t].x