fixed format warnings
[swftools.git] / lib / pdf / GFXOutputDev.cc
index 84a4635..b450e54 100644 (file)
@@ -1442,10 +1442,13 @@ void GFXOutputDev::drawChar(GfxState *state, double x, double y,
     gfxmatrix_t m = this->current_font_matrix;
     this->transformXY(state, x-originX, y-originY, &m.tx, &m.ty);
     //m.tx += originX; m.ty += originY;
-
-    msg("<debug> drawChar(%f,%f,c='%c' (%d), u=%d <%d>) CID=%d render=%d glyphid=%d font=%08x",m.tx,m.ty,(charid&127)>=32?charid:'?', charid, u, uLen, font->isCIDFont(), render, glyphid, current_gfxfont);
     
-    if((render == RENDER_FILL && !config_drawonlyshapes) || render == RENDER_INVISIBLE) {
+    msg("<debug> drawChar(%f,%f,c='%c' (%d), u=%d <%d>) CID=%d render=%d glyphid=%d font=%08x",m.tx,m.ty,(charid&127)>=32?charid:'?', charid, u, uLen, font->isCIDFont(), render, glyphid, current_gfxfont);
+
+    if((render == RENDER_FILL && !config_drawonlyshapes) ||
+       (render == RENDER_FILLSTROKE && state->getTransformedLineWidth()<1.0) ||
+       (render == RENDER_INVISIBLE)) {
+
        int space = this->current_fontinfo->space_char;
        if(config_extrafontdata && space>=0 && m.m00 && !m.m01) {
            /* space char detection */
@@ -1454,10 +1457,11 @@ void GFXOutputDev::drawChar(GfxState *state, double x, double y,
               !last_char_was_space) {
                double expected_x = last_char_x + current_gfxfont->glyphs[last_char].advance*m.m00;
                int space = this->current_fontinfo->space_char;
-               if(m.tx - expected_x >= m.m00*64) {
-                   msg("<debug> There's a %f (%f) pixel gap between char %d and char %d, I'm inserting a space here", 
+               float width = this->current_fontinfo->average_advance;
+               if(m.tx - expected_x >= m.m00*width*4/10) {
+                   msg("<debug> There's a %f pixel gap between char %d and char %d (expected no more than %f), I'm inserting a space here", 
                            m.tx-expected_x, 
-                           (m.tx-expected_x)/m.m00,
+                           width*m.m00*4/10,
                            last_char, glyphid);
                    gfxmatrix_t m2 = m;
                    m2.tx = expected_x + (m.tx - expected_x - current_gfxfont->glyphs[space].advance*m.m00)/2;
@@ -1478,6 +1482,7 @@ void GFXOutputDev::drawChar(GfxState *state, double x, double y,
            msg("<notice> Some texts will be rendered as shape");
            gfxglobals->textmodeinfo = 1;
        }
+
        gfxline_t*glyph = current_gfxfont->glyphs[glyphid].line;
        gfxline_t*tglyph = gfxline_clone(glyph);
        gfxline_transform(tglyph, &m);
@@ -1561,10 +1566,11 @@ GBool GFXOutputDev::beginType3Char(GfxState *state, double x, double y, double d
 
        gfxmatrix_t m = this->current_font_matrix;
        this->transformXY(state, 0, 0, &m.tx, &m.ty);
-       m.m00*=INTERNAL_FONT_SIZE;
+
+       /*m.m00*=INTERNAL_FONT_SIZE;
        m.m01*=INTERNAL_FONT_SIZE;
        m.m10*=INTERNAL_FONT_SIZE;
-       m.m11*=INTERNAL_FONT_SIZE;
+       m.m11*=INTERNAL_FONT_SIZE;*/
 
        if(!current_fontinfo || (unsigned)charid >= current_fontinfo->num_glyphs || !current_fontinfo->glyphs[charid]) {
            msg("<error> Invalid charid %d for font", charid);
@@ -1658,12 +1664,6 @@ void GFXOutputDev::startPage(int pageNum, GfxState *state, double crop_x1, doubl
     states[statepos].dashStart = 0;
     
     this->last_char_gfxfont = 0;
-       
-    if(this->config_linkdatafile) {
-       FILE*fi = fopen(config_linkdatafile, "ab+");
-       fprintf(fi, "[page %d]\n", pageNum);
-       fclose(fi);
-    }
 }
 
 
@@ -1917,7 +1917,7 @@ void GFXOutputDev::restoreState(GfxState *state) {
       if(verbose) {
          int t;
          for(t=0;t<=statepos;t++) {
-             printf("%08x ", states[t].state);
+             printf("%08x ", (unsigned int)states[t].state);
          }
          printf("\n");
       }
@@ -2045,7 +2045,7 @@ void GFXOutputDev::updateFont(GfxState *state)
     current_gfxfont = this->current_fontinfo->getGfxFont();
     device->addfont(device, current_gfxfont);
     free(id);
-
+    
     updateFontMatrix(state);
 }
 
@@ -2391,38 +2391,18 @@ void GFXOutputDev::drawGeneralImage(GfxState *state, Object *ref, Stream *str,
       for(t=0;t<256;t++) {
          pixBuf[0] = t;
          colorMap->getRGB(pixBuf, &rgb);
-
-         {/*if(maskColors && *maskColors==t) {
-             msg("<notice> Color %d is transparent", t);
-             if (imgData->maskColors) {
-               *alpha = 0;
-               for (i = 0; i < imgData->colorMap->getNumPixelComps(); ++i) {
-                 if (pix[i] < imgData->maskColors[2*i] ||
-                     pix[i] > imgData->maskColors[2*i+1]) {
-                   *alpha = 1;
-                   break;
-                 }
-               }
-             } else {
-               *alpha = 1;
-             }
-             if(!*alpha) {
-                   pal[t].r = 0;
-                   pal[t].g = 0;
-                   pal[t].b = 0;
-                   pal[t].a = 0;
-             }
-         } else {*/
-             pal[t].r = (unsigned char)(colToByte(rgb.r));
-             pal[t].g = (unsigned char)(colToByte(rgb.g));
-             pal[t].b = (unsigned char)(colToByte(rgb.b));
-             pal[t].a = 255;//(U8)(rgb.b * 255 + 0.5);
-         }
+         pal[t].r = (unsigned char)(colToByte(rgb.r));
+         pal[t].g = (unsigned char)(colToByte(rgb.g));
+         pal[t].b = (unsigned char)(colToByte(rgb.b));
+         pal[t].a = 255;//(U8)(rgb.b * 255 + 0.5);
       }
       for (y = 0; y < height; ++y) {
        for (x = 0; x < width; ++x) {
          imgStr->getPixel(pixBuf);
          pic[width*y+x] = pal[pixBuf[0]];
+         if(maskColors && *maskColors==pixBuf[0]) {
+             pic[width*y+x].a = 0;
+         }
        }
       }
       if(maskbitmap) {
@@ -2696,9 +2676,6 @@ void GFXOutputDev::endTransparencyGroup(GfxState *state)
 
     dbg("endTransparencyGroup this->device now back to %08x (destroying %08x)", states[statepos].olddevice, this->device);
     
-    while(statepos && !states[statepos].olddevice)
-       --statepos;
-   
     this->device = states[statepos].olddevice;
     if(!this->device) {
        msg("<error> Invalid state nesting");