X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2FSWFOutputDev.cc;h=10e0ffe4ce43afaff2890b4ab3324301a7f8e514;hb=07acff35bba49807c780b18aa2ed11d7417409d7;hp=251cd04a676d4af960138e2ed66dfe2a84e28744;hpb=a99083c972c3464b16cb2d488f7e8b2519c48c41;p=swftools.git diff --git a/pdf2swf/SWFOutputDev.cc b/pdf2swf/SWFOutputDev.cc index 251cd04..10e0ffe 100644 --- a/pdf2swf/SWFOutputDev.cc +++ b/pdf2swf/SWFOutputDev.cc @@ -442,6 +442,14 @@ T1_OUTLINE* gfxPath_to_T1_OUTLINE(GfxState*state, GfxPath*path) bezierpathsegment*outline = start = new bezierpathsegment(); int cpos = 0; double lastx=0,lasty=0; + if(!num) { + logf(" empty path"); + outline->type = T1_PATHTYPE_MOVE; + outline->dest.x = 0; + outline->dest.y = 0; + outline->link = 0; + return (T1_OUTLINE*)outline; + } for(t = 0; t < num; t++) { GfxSubpath *subpath = path->getSubpath(t); int subnum = subpath->getNumPoints(); @@ -881,7 +889,7 @@ int SWFOutputDev::searchT1Font(char*name) } if(fontname && !strcmp(name, fontname)) { - logf(" Extra font %s is being used.\n", fontname); + logf(" Extra font %d, \"%s\" is being used.\n", i, fontname); return i; } fontname = T1_GetFontFileName(i); @@ -889,7 +897,7 @@ int SWFOutputDev::searchT1Font(char*name) fontname = strrchr(fontname,'/')+1; if(strstr(fontname, name)) { - logf(" Extra font %s is being used.\n", fontname); + logf(" Extra font %d, \"%s\" is being used.\n", i, fontname); return i; } } @@ -965,8 +973,30 @@ char*SWFOutputDev::writeEmbeddedFontToFile(XRef*ref, GfxFont*font) refObj.fetch(ref, &strObj); refObj.free(); strObj.streamReset(); - while ((c = strObj.streamGetChar()) != EOF) { - fputc(c, f); + int f4[4]; + char f4c[4]; + int t; + for(t=0;t<4;t++) { + f4[t] = strObj.streamGetChar(); + f4c[t] = (char)f4[t]; + if(f4[t] == EOF) + break; + } + if(t==4) { + if(!strncmp(f4c, "true", 4)) { + /* some weird TTF fonts don't start with 0,1,0,0 but with "true". + Change this on the fly */ + f4[0] = f4[2] = f4[3] = 0; + f4[1] = 1; + } + fputc(f4[0], f); + fputc(f4[1], f); + fputc(f4[2], f); + fputc(f4[3], f); + + while ((c = strObj.streamGetChar()) != EOF) { + fputc(c, f); + } } strObj.streamClose(); strObj.free(); @@ -1019,6 +1049,7 @@ char* SWFOutputDev::substituteFont(GfxFont*gfxFont, char* oldname) /* ------------------------------ V1 */ char*fontname = "Times-Roman"; + logf(" substituteFont(,%s)", FIXNULL(oldname)); this->t1id = searchT1Font(fontname); if(substitutepos>=sizeof(substitutesource)/sizeof(char*)) { logf(" Too many fonts in file."); @@ -1231,12 +1262,15 @@ void SWFOutputDev::updateFont(GfxState *state) if(fontname) { int newt1id = searchT1Font(fontname); if(newt1id<0) { + showFontError(gfxFont,1); fontname = substituteFont(gfxFont, fontname); } else this->t1id = newt1id; } - else + else { + showFontError(gfxFont,1); fontname = substituteFont(gfxFont, fontname); + } } if(t1id<0) {