X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2Fswfoutput.cc;h=5e5e4da03bd07d9b7f6db9a7bb3a556914001671;hb=962d892041da5c8a2d4ab9329f4b0dbb471b4917;hp=172b52bc275dd473a273cd604ad68102d7bb9bd1;hpb=c8e0d0bd8cc515f60ab6a1248caf6fdc8945d89e;p=swftools.git diff --git a/pdf2swf/swfoutput.cc b/pdf2swf/swfoutput.cc index 172b52b..5e5e4da 100644 --- a/pdf2swf/swfoutput.cc +++ b/pdf2swf/swfoutput.cc @@ -817,8 +817,12 @@ static void putcharacters(TAG*tag) if(lastx != chardata[t].x || lasty != chardata[t].y) { - newx=chardata[t].x; - newy=chardata[t].y; + newx = chardata[t].x; + newy = chardata[t].y; + if(newx == 0) + newx = SET_TO_ZERO; + if(newy == 0) + newy = SET_TO_ZERO; } if(!colorcompare(&color, &chardata[t].color)) { @@ -888,9 +892,18 @@ static void drawchar(struct swfoutput*obj, SWFFont*font, char*character, int cha if(m->m11 != m->m22) usefonts=0; + if(!font) { + msg(" Font is NULL"); + } + 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) @@ -904,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; } @@ -978,17 +991,23 @@ SWFFont::SWFFont(char*name, int id, char*filename) this->fontid = strdup(name); this->t1id = id; - char**a= T1_GetAllCharNames(id); + char**charnamebase= T1_GetAllCharNames(id); + char**a= charnamebase; 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; @@ -998,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*)); @@ -1020,7 +1048,7 @@ SWFFont::SWFFont(char*name, int id, char*filename) t=0; while(*a) { - map[t] = *a; + map[t] = strdup(*a); a++; t++; if(t==256 || !*a) { @@ -1035,6 +1063,12 @@ SWFFont::SWFFont(char*name, int id, char*filename) int ret = T1_ReencodeFont(id, map); if(ret) fprintf(stderr,"Can't reencode font: (%s) ret:%d\n",filename, ret); + /* Deleting the font invalidates the charname array, + so we have to ask for it again now. + We continue at the position we were, hoping the font + didn't shrink in the meantime or something. + */ + a = T1_GetAllCharNames(id) + (a - charnamebase); } // parsecharacters @@ -1047,6 +1081,9 @@ SWFFont::SWFFont(char*name, int id, char*filename) this->charname[outlinepos] = strdup(name); outlinepos++; } + + for(s=0;sstandardtable && 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; } @@ -1207,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)