X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=pdf2swf%2Fswfoutput.cc;h=0e8b257bb781a5852d63fa634962763e3e58c60b;hb=7bd5bed8d9e02b50dd068502d4e80658992482b1;hp=9c66317438660a7176bb4c4d274c8776cccf0475;hpb=9aa850fb4c4b28c64d53e144b4a107d982917b2e;p=swftools.git diff --git a/pdf2swf/swfoutput.cc b/pdf2swf/swfoutput.cc index 9c66317..0e8b257 100644 --- a/pdf2swf/swfoutput.cc +++ b/pdf2swf/swfoutput.cc @@ -885,9 +885,14 @@ static void putcharacter(struct swfoutput*obj, int fontid, int charid, chardatapos++; } +struct fontlist_t +{ + SWFFONT *swffont; + fontlist_t*next; +} *fontlist = 0; /* process a character. */ -static void drawchar(struct swfoutput*obj, SWFFONT *swffont, char*character, int charnr, int u, swfmatrix*m) +static int drawchar(struct swfoutput*obj, SWFFONT *swffont, char*character, int charnr, int u, swfmatrix*m) { int usefonts=1; if(m->m12!=0 || m->m21!=0) @@ -897,6 +902,12 @@ static void drawchar(struct swfoutput*obj, SWFFONT *swffont, char*character, int if(!swffont) { msg(" Font is NULL"); + return 0; + } + + if(!usefonts) { + msg(" Non diagonal font matrix: %f %f", m->m11, m->m21); + msg(" | %f %f", m->m12, m->m22); } //if(usefonts && ! drawonlyshapes) @@ -905,17 +916,24 @@ static void drawchar(struct swfoutput*obj, SWFFONT *swffont, char*character, int int charid = getCharID(swffont, charnr, character, u); if(charid<0) { - msg(" Didn't find character '%s' (%d) in current charset (%s, %d characters)", - FIXNULL(character),charnr, FIXNULL((char*)swffont->name), swffont->numchars); - return; + msg(" Didn't find character '%s' (c=%d,u=%d) in current charset (%s, %d characters)", + FIXNULL(character),charnr, u, FIXNULL((char*)swffont->name), swffont->numchars); + /*fontlist_t*it = fontlist; + while(it) { + msg(" Font history: %s [%d]", it->swffont->name, getCharID(it->swffont, charnr, character, u)); + it = it->next; + }*/ + return 0; } + if(shapeid>=0) endshape(); if(textid<0) starttext(obj); - + putcharacter(obj, swffont->id, charid,(int)(m->m13*20),(int)(m->m23*20), (int)(m->m11+0.5)); + return 1; } /*else { @@ -1011,20 +1029,18 @@ int getCharID(SWFFONT *font, int charnr, char *charname, int u) msg(" u=%d, font->maxascii=%d ascci2glyph[%d]=%d",u,font->maxascii,u,font->ascii2glyph[u]); /* try to use the unicode id */ - if(u>=0 && umaxascii && font->ascii2glyph[u]>=0) + if(u>=0 && umaxascii && font->ascii2glyph[u]>=0) { return font->ascii2glyph[u]; + } } - if(charnr>=0 && charnrnumchars) + if(charnr>=0 && charnrnumchars) { return charnr; + } + return -1; } -struct fontlist_t -{ - SWFFONT *swffont; - fontlist_t*next; -} *fontlist = 0; /* set's the t1 font index of the font to use for swfoutput_drawchar(). */ void swfoutput_setfont(struct swfoutput*obj, char*fontid, char*filename) @@ -1053,11 +1069,13 @@ void swfoutput_setfont(struct swfoutput*obj, char*fontid, char*filename) return; } - /* TODO: sometimes, scale has to be 64, and sometimes 32. - It's probably font format related */ - swf_SetLoadFontParameters(32, 0); + SWFFONT*swffont = swf_LoadFont(filename); + + if(swffont == 0) { + msg(" Couldn't load font %s (%s)", fontid, filename); + swffont = swf_LoadFont(0); + } - SWFFONT *swffont = swf_LoadFont(filename); swf_FontSetID(swffont, ++currentswfid); if(screenloglevel >= LOGLEVEL_DEBUG) { @@ -1121,7 +1139,7 @@ void swfoutput_setfontmatrix(struct swfoutput*obj,double m11,double m12, } /* draws a character at x,y. */ -void swfoutput_drawchar(struct swfoutput* obj,double x,double y,char*character, int charnr, int u) +int swfoutput_drawchar(struct swfoutput* obj,double x,double y,char*character, int charnr, int u) { swfmatrix m; m.m11 = obj->fontm11; @@ -1130,7 +1148,7 @@ void swfoutput_drawchar(struct swfoutput* obj,double x,double y,char*character, m.m22 = obj->fontm22; m.m13 = x; m.m23 = y; - drawchar(obj, obj->swffont, character, charnr, u, &m); + return drawchar(obj, obj->swffont, character, charnr, u, &m); } /* initialize the swf writer */