swfoutput_drawchar now returns success or failure.
authorkramm <kramm>
Sun, 25 Jul 2004 09:08:06 +0000 (09:08 +0000)
committerkramm <kramm>
Sun, 25 Jul 2004 09:08:06 +0000 (09:08 +0000)
pdf2swf/SWFOutputDev.cc
pdf2swf/swfoutput.cc
pdf2swf/swfoutput.h

index 6dafd03..f6274bb 100644 (file)
@@ -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("<debug> drawChar(%f,%f,%f,%f,c='%c' (%d),u=%d) CID=%d\n",x,y,dx,dy,c,c,u, font->isCIDFont());
+    msg("<debug> 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;t<sizeof(nameToUnicodeTab)/sizeof(nameToUnicodeTab[0]);t++)
-               /* todo: should be precomputed */
-               if(nameToUnicodeTab[t].u == u) {
-                   name = nameToUnicodeTab[t].name;
-                   break;
-               }
-       }
-
-       if(name)
-          swfoutput_drawchar(&output, x1, y1, name, c, u);
-       else {
-          swfoutput_drawchar(&output, x1, y1, 0, c, u);
+       int t;
+       for(t=0;t<sizeof(nameToUnicodeTab)/sizeof(nameToUnicodeTab[0]);t++) {
+           /* todo: should be precomputed */
+           if(nameToUnicodeTab[t].u == u) {
+               name = nameToUnicodeTab[t].name;
+               break;
+           }
        }
     } else {
        Gfx8BitFont*font8;
        font8 = (Gfx8BitFont*)font;
        char**enc=font8->getEncoding();
-
        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) 
index 9c66317..7fc1b3a 100644 (file)
@@ -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("<warning> Didn't find character '%s' (%d) in current charset (%s, %d characters)", 
-                   FIXNULL(character),charnr, FIXNULL((char*)swffont->name), swffont->numchars);
-           return;
+           msg("<warning> 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 */
index 0b4ceed..0e1ed48 100644 (file)
@@ -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