From b8573ee9e8a629c9a19f614ca3c4d64c93901eab Mon Sep 17 00:00:00 2001 From: kramm Date: Sun, 25 Jul 2004 09:08:06 +0000 Subject: [PATCH] swfoutput_drawchar now returns success or failure. --- pdf2swf/SWFOutputDev.cc | 39 +++++++++++++++------------------------ pdf2swf/swfoutput.cc | 13 +++++++------ pdf2swf/swfoutput.h | 2 +- 3 files changed, 23 insertions(+), 31 deletions(-) diff --git a/pdf2swf/SWFOutputDev.cc b/pdf2swf/SWFOutputDev.cc index 6dafd03..f6274bb 100644 --- a/pdf2swf/SWFOutputDev.cc +++ b/pdf2swf/SWFOutputDev.cc @@ -636,7 +636,6 @@ void SWFOutputDev::beginString(GfxState *state, GString *s) swfoutput_setfontmatrix(&output, m11, -m21, m12, -m22); } -int charcounter = 0; void SWFOutputDev::drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, @@ -649,7 +648,7 @@ void SWFOutputDev::drawChar(GfxState *state, double x, double y, GfxFont*font = state->getFont(); if(font->getType() == fontType3) { - /* type 3 chars are passed primarily as graphics */ + /* type 3 chars are passed as graphics */ return; } double x1,y1; @@ -661,37 +660,29 @@ void SWFOutputDev::drawChar(GfxState *state, double x, double y, if(_u) u = *_u; - msg(" drawChar(%f,%f,%f,%f,c='%c' (%d),u=%d) CID=%d\n",x,y,dx,dy,c,c,u, font->isCIDFont()); + msg(" drawChar(%f,%f,%f,%f,c='%c' (%d),u=%d <%d>) CID=%d\n",x,y,dx,dy,c,c,u, uLen, font->isCIDFont()); - if(font->isCIDFont()) { + /* find out the character name */ + char*name=0; + if(font->isCIDFont() && u) { GfxCIDFont*cfont = (GfxCIDFont*)font; - char*name=0; - if(u) { - int t; - for(t=0;tgetEncoding(); - if(enc && enc[c]) - swfoutput_drawchar(&output, x1, y1, enc[c], c, u); - else { - swfoutput_drawchar(&output, x1, y1, 0, c, u); - } + name = enc[c]; } + + int ret = swfoutput_drawchar(&output, x1, y1, name, c, u); } void SWFOutputDev::endString(GfxState *state) diff --git a/pdf2swf/swfoutput.cc b/pdf2swf/swfoutput.cc index 9c66317..7fc1b3a 100644 --- a/pdf2swf/swfoutput.cc +++ b/pdf2swf/swfoutput.cc @@ -887,7 +887,7 @@ static void putcharacter(struct swfoutput*obj, int fontid, int charid, /* 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) @@ -905,9 +905,9 @@ 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); + return 0; } if(shapeid>=0) endshape(); @@ -916,6 +916,7 @@ static void drawchar(struct swfoutput*obj, SWFFONT *swffont, char*character, int putcharacter(obj, swffont->id, charid,(int)(m->m13*20),(int)(m->m23*20), (int)(m->m11+0.5)); + return 1; } /*else { @@ -1121,7 +1122,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 +1131,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 */ diff --git a/pdf2swf/swfoutput.h b/pdf2swf/swfoutput.h index 0b4ceed..0e1ed48 100644 --- a/pdf2swf/swfoutput.h +++ b/pdf2swf/swfoutput.h @@ -119,7 +119,7 @@ void swfoutput_setstrokecolor(struct swfoutput*, unsigned char r, unsigned char void swfoutput_setfontmatrix(struct swfoutput*,double,double,double,double); void swfoutput_setlinewidth(struct swfoutput*, double linewidth); -void swfoutput_drawchar(struct swfoutput*,double x,double y,char*a, int charnr, int u); +int swfoutput_drawchar(struct swfoutput*,double x,double y,char*a, int charnr, int u); void swfoutput_drawpath(struct swfoutput*, SWF_OUTLINE*outline, struct swfmatrix*m); #define LINE_CAP_BUTT 0 #define LINE_CAP_ROUND 1 -- 1.7.10.4