fixed format warnings
[swftools.git] / lib / pdf / GFXOutputDev.cc
index 2596d25..b450e54 100644 (file)
@@ -1457,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;
@@ -1916,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,8 +2046,6 @@ void GFXOutputDev::updateFont(GfxState *state)
     device->addfont(device, current_gfxfont);
     free(id);
     
-    device->addfont(device, current_gfxfont);
-
     updateFontMatrix(state);
 }
 
@@ -2392,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) {