X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2Fswfoutput.cc;h=98701b02c42804abca74fab04270b6bd84682194;hb=a6f4bf74f964e101e25f0234ebcb3c3dde175df4;hp=63c33cb9a53f3bf644a249edfe86b6b586a3cda7;hpb=15c29a9ed6fcebd52ca0561f01af5ccb85a47a0e;p=swftools.git diff --git a/pdf2swf/swfoutput.cc b/pdf2swf/swfoutput.cc index 63c33cb..98701b0 100644 --- a/pdf2swf/swfoutput.cc +++ b/pdf2swf/swfoutput.cc @@ -899,6 +899,11 @@ static void drawchar(struct swfoutput*obj, SWFFont*font, char*character, int cha if(usefonts && ! drawonlyshapes) { int charid = font->getSWFCharID(character, charnr); + if(charid<0) { + msg(" Didn't find character '%s' (%d) in current charset (%s)", + FIXNULL(character),charnr, FIXNULL(font->getName())); + return; + } if(shapeid>=0) endshape(); if(textid<0) @@ -912,8 +917,8 @@ static void drawchar(struct swfoutput*obj, SWFFont*font, char*character, int cha char* charname = character; if(!outline) { - msg(" Didn't find %s in current charset (%s)", - FIXNULL(character),FIXNULL(font->getName())); + msg(" Didn't find character '%s' (%d) in current charset (%s)", + FIXNULL(character),charnr,FIXNULL(font->getName())); return; } @@ -991,13 +996,18 @@ SWFFont::SWFFont(char*name, int id, char*filename) int t, outlinepos=0; char*map[256]; + char*null = 0; + if(!a) + a=&null; + t=0; while(a[t]) t++; this->charnum = t; - if(!charnum) - return; + if(!charnum) { + this->standardtablesize = 0; + } msg(" Font %s(%d): Storing %d outlines.\n", FIXNULL(name), id, charnum); this->standardtablesize = 256; @@ -1007,9 +1017,18 @@ SWFFont::SWFFont(char*name, int id, char*filename) for(t = 0; t < this->standardtablesize; t++) { char*name = T1_GetCharName(id,t); - if(!name) - name = ""; + char chh[2] = ""; + chh[0] = t; + if(!name || !strstr(name, "notdef")) { + if(t + } + } standardtable[t] = strdup(name); + msg(" Char %d is named %s\n", t, name); } outline = (T1_OUTLINE**)malloc(charnum*sizeof(T1_OUTLINE*)); @@ -1068,7 +1087,6 @@ SWFFont::SWFFont(char*name, int id, char*filename) t=0; } } - printf("done\n"); } /* free all tables, write out definefont tags */ @@ -1153,7 +1171,8 @@ SWFFont::~SWFFont() } free(ptr); - free(outline); + if(outline) + free(outline); for(t=0;tstandardtable && charnr>=0 && charnr < this->standardtablesize) { - return getOutline(this->standardtable[charnr], -1); + T1_OUTLINE*ret = getOutline(this->standardtable[charnr], -1); + if(ret) return ret; } - msg(" Didn't find character '%s' in font '%s'", FIXNULL(name), this->name); return 0; } @@ -1226,10 +1245,10 @@ int SWFFont::getSWFCharID(char*name, int charnr) /* if we didn't find it by name, use the names of the first 256 (or so) characters of the font to try a new name based on charnr */ if(this->standardtable && charnr>=0 && charnr < this->standardtablesize) { - return getSWFCharID(this->standardtable[charnr], -1); + int ret = getSWFCharID(this->standardtable[charnr], -1); + if(ret) return ret; } - msg(" Didn't find character '%s' in font '%s'", FIXNULL(name), this->name); - return 0; + return -1; } int SWFFont::getWidth(char*name) @@ -1333,15 +1352,15 @@ void swfoutput_drawchar(struct swfoutput* obj,double x,double y,char*character, } /* initialize the swf writer */ -void swfoutput_init(struct swfoutput* obj, char*_filename, int _sizex, int _sizey) +void swfoutput_init(struct swfoutput* obj, char*_filename, int x1, int y1, int x2, int y2) { GLYPH *glyph; RGBA rgb; SRECT r; memset(obj, 0, sizeof(struct swfoutput)); filename = _filename; - sizex = _sizex; - sizey = _sizey; + sizex = x2; + sizey = y2; msg(" initializing swf output for size %d*%d\n", sizex,sizey); @@ -1351,18 +1370,48 @@ void swfoutput_init(struct swfoutput* obj, char*_filename, int _sizex, int _size swf.fileVersion = flashversion; swf.frameRate = 0x0040; // 1 frame per 4 seconds - swf.movieSize.xmax = 20*sizex; - swf.movieSize.ymax = 20*sizey; + swf.movieSize.xmin = 20*x1; + swf.movieSize.ymin = 20*y1; + swf.movieSize.xmax = 20*x2; + swf.movieSize.ymax = 20*y2; + + depth = 1; swf.firstTag = swf_InsertTag(NULL,ST_SETBACKGROUNDCOLOR); tag = swf.firstTag; - rgb.r = 0xff; - rgb.g = 0xff; - rgb.b = 0xff; + rgb.a = rgb.r = rgb.g = rgb.b = 0xff; swf_SetRGB(tag,&rgb); - if(flag_protected) // good practice! /r + + if(1)/* add white rectangle */ + { + SRECT r; + SHAPE* s; + int ls1=0,fs1=0; + int shapeid = ++currentswfid; + r.xmin = x1*20; + r.ymin = y1*20; + r.xmax = x2*20; + r.ymax = y2*20; + tag = swf_InsertTag(tag, ST_DEFINESHAPE); + swf_ShapeNew(&s); + fs1 = swf_ShapeAddSolidFillStyle(s, &rgb); + swf_SetU16(tag,shapeid); + swf_SetRect(tag,&r); + swf_SetShapeHeader(tag,s); + swf_ShapeSetAll(tag,s,x1*20,y1*20,ls1,fs1,0); + swf_ShapeSetLine(tag,s,20*(x2-x1),0); + swf_ShapeSetLine(tag,s,0,20*(y2-y1)); + swf_ShapeSetLine(tag,s,20*(x1-x2),0); + swf_ShapeSetLine(tag,s,0,20*(y1-y2)); + swf_ShapeSetEnd(tag); + swf_ShapeFree(s); + tag = swf_InsertTag(tag, ST_PLACEOBJECT2); + swf_ObjectPlace(tag,shapeid,depth++,0,0,0); + } + + if(flag_protected) tag = swf_InsertTag(tag, ST_PROTECT); - depth = 1; + startdepth = depth; }