X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2Fswfoutput.cc;h=0d0246b755b62260abe474ccafc255a36965c50f;hb=73a238a8ad83ebb3fc209e0451d68275d2668add;hp=17e0fd2b58bf54821361a658711d4efa0aafa249;hpb=b9042754dba87cf5c924274c221b265a3e6c54fd;p=swftools.git diff --git a/pdf2swf/swfoutput.cc b/pdf2swf/swfoutput.cc index 17e0fd2..0d0246b 100644 --- a/pdf2swf/swfoutput.cc +++ b/pdf2swf/swfoutput.cc @@ -170,8 +170,6 @@ static void swf_startframe(gfxdevice_t*dev, int width, int height); static void swf_endframe(gfxdevice_t*dev); static gfxresult_t* swf_finish(gfxdevice_t*driver); -int getCharID(SWFFONT *font, int charnr, char *charname, int u); - static swfoutput_internal* init_internal_struct() { swfoutput_internal*i = (swfoutput_internal*)malloc(sizeof(swfoutput_internal)); @@ -646,11 +644,8 @@ static void putcharacter(gfxdevice_t*dev, int fontid, int charid, int x,int y, i If we set it to low, however, the char positions will be inaccurate */ #define FONT_INTERNAL_SIZE 4 -static int font_active = 0; -static char* font_active_filename = 0; - /* process a character. */ -static int drawchar(gfxdevice_t*dev, SWFFONT *swffont, char*character, int charnr, int u, swfmatrix*m, gfxcolor_t*col) +static int drawchar(gfxdevice_t*dev, SWFFONT *swffont, int charid, swfmatrix*m, gfxcolor_t*col) { swfoutput_internal*i = (swfoutput_internal*)dev->internal; if(!swffont) { @@ -658,21 +653,8 @@ static int drawchar(gfxdevice_t*dev, SWFFONT *swffont, char*character, int charn return 0; } - int charid = getCharID(swffont, charnr, character, u); - if(font_active) { - char buf[1024]; - sprintf(buf, "%s.usage", font_active_filename); - FILE*fi = fopen(buf, "ab+"); - if(fi) { - fprintf(fi, "%d %d %d %s\n", charnr, u, charid, character); - fclose(fi); - } else - msg(" Couldn't write to %s", buf); - } - - if(charid<0) { - 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); + if(charid<0 || charid>=swffont->numchars) { + msg(" No character %d in font %s ", charid, FIXNULL((char*)swffont->name)); return 0; } /*if(swffont->glyph[charid].shape->bitlen <= 16) { @@ -681,7 +663,6 @@ static int drawchar(gfxdevice_t*dev, SWFFONT *swffont, char*character, int charn return 0; }*/ - if(i->shapeid>=0) endshape(dev); if(i->textid<0) @@ -732,52 +713,6 @@ static void endtext(gfxdevice_t*dev) i->textid = -1; } -int getCharID(SWFFONT *font, int charnr, char *charname, int u) -{ - int t; - if(charname && font->glyphnames) { - for(t=0;tnumchars;t++) { - if(font->glyphnames[t] && !strcmp(font->glyphnames[t],charname)) { - msg(" Char [%d,>%s<,%d] maps to %d\n", charnr, charname, u, t); - return t; - } - } - /* if we didn't find the character, maybe - we can find the capitalized version */ - for(t=0;tnumchars;t++) { - if(font->glyphnames[t] && !strcasecmp(font->glyphnames[t],charname)) { - msg(" Char [%d,>>%s<<,%d] maps to %d\n", charnr, charname, u, t); - return t; - } - } - } - - if(u>0 && font->encoding != 255) { - /* try to use the unicode id */ - if(u>=0 && umaxascii && font->ascii2glyph[u]>=0) { - msg(" Char [%d,%s,>%d<] maps to %d\n", charnr, charname, u, font->ascii2glyph[u]); - return font->ascii2glyph[u]; - } - } - - if(font->encoding != FONT_ENCODING_UNICODE) { - /* the following only works if the font encoding - is US-ASCII based. It's needed for fonts which return broken unicode - indices */ - if(charnr>=0 && charnrmaxascii && font->ascii2glyph[charnr]>=0) { - msg(" Char [>%d<,%s,%d] maps to %d\n", charnr, charname, u, font->ascii2glyph[charnr]); - return font->ascii2glyph[charnr]; - } - } - - if(charnr>=0 && charnrnumchars) { - msg(" Char [>%d<,%s,%d] maps to %d\n", charnr, charname, u, charnr); - return charnr; - } - - return -1; -} - /* set's the matrix which is to be applied to characters drawn by swfoutput_drawchar() */ static void swfoutput_setfontmatrix(gfxdevice_t*dev,double m11,double m21, double m12,double m22) @@ -1771,7 +1706,7 @@ static ArtVpath* gfxline_to_ArtVpath(gfxline_t*line) double x=0,y=0; /* factor which determines into how many line fragments a spline is converted */ - double subfraction = 1.2;//0.3 + double subfraction = 2.4;//0.3 l2 = line; while(l2) { @@ -1922,8 +1857,6 @@ static int add_image(swfoutput_internal*i, gfximage_t*img, int targetwidth, int return -1; /* TODO: cache images */ - *newwidth = sizex; - *newheight = sizey; if(newsizex Scaling %dx%d image to %dx%d", sizex, sizey, newsizex, newsizey); @@ -1931,7 +1864,9 @@ static int add_image(swfoutput_internal*i, gfximage_t*img, int targetwidth, int *newwidth = sizex = newsizex; *newheight = sizey = newsizey; mem = newpic; - + } else { + *newwidth = newsizex = sizex; + *newheight = newsizey = sizey; } int num_colors = swf_ImageGetNumberOfPaletteEntries(mem,sizex,sizey,0); @@ -2400,5 +2335,5 @@ static void swf_drawchar(gfxdevice_t*dev, char*fontid, int glyph, gfxcolor_t*col m.m22 = i->fontm22; m.m31 = matrix->tx; m.m32 = matrix->ty; - drawchar(dev, i->swffont, 0, glyph, -1, &m, color); + drawchar(dev, i->swffont, glyph, &m, color); }