trivial bug fixes
authorMatthias Kramm <kramm@quiss.org>
Tue, 16 Mar 2010 23:57:59 +0000 (16:57 -0700)
committerMatthias Kramm <kramm@quiss.org>
Tue, 16 Mar 2010 23:57:59 +0000 (16:57 -0700)
lib/filters/remove_font_transforms.c
lib/gfxfont.c
lib/pdf/pdf2jpeg.c
lib/ttf.c
lib/ttf.h

index 84a873c..06e8031 100644 (file)
@@ -217,7 +217,7 @@ static gfxresult_t* pass1_finish(gfxfilter_t*f, gfxdevice_t*out)
        fd->dx = -total.xmin;
 
        font->ascent = total.ymax;
-       font->descent = total.ymin;
+       font->descent = -total.ymin;
 
        for(t=0;t<count;t++) {
            gfxline_t*line = font->glyphs[t].line;
index e99816c..119f003 100644 (file)
@@ -697,7 +697,7 @@ ttf_t* gfxfont_to_ttf(gfxfont_t*font)
     }
        
     ttf->ascent = font->ascent;
-    ttf->descent = font->descent;
+    ttf->descent = -font->descent;
     ttf->lineGap = 0;
 
     ttf->full_name = strdup(font->id);
index f354726..4a3fb16 100644 (file)
@@ -79,11 +79,9 @@ int main(int argc, char *argv[]) {
   GString *ownerPW, *userPW;
   SplashColor paperColor;
   SplashOutputDev *splashOut;
-  SplashBitmap*bitmap = 0;
   GBool ok;
   int exitCode;
   int pg;
-  double r;
 
   exitCode = 99;
 
@@ -132,22 +130,22 @@ int main(int argc, char *argv[]) {
   
   splashOut->startDoc(doc->getXRef());
 
-  r = resolution;
-  if(width) {
-    int old_width = doc->getPageCropWidth(page);
-    r = 72.0*width/old_width;
-  }
-
-  doc->displayPage(splashOut, page, r, r, 0, gFalse, gTrue, gFalse);
-  bitmap = splashOut->getBitmap();
-  if(bitmap) {
-    Guchar*rgb = bitmap->getDataPtr();
-    int width = bitmap->getWidth();
-    int height = bitmap->getHeight();
-    jpeg_save(rgb, width, height, quality, output);
+  if(page>=1 && page<=doc->getNumPages()) {
+      double r = resolution;
+      if(width) {
+       int old_width = doc->getPageCropWidth(page);
+       r = 72.0*width/old_width;
+      }
+      doc->displayPage(splashOut, page, r, r, 0, gFalse, gTrue, gFalse);
+      SplashBitmap*bitmap = splashOut->getBitmap();
+      if(bitmap) {
+       Guchar*rgb = bitmap->getDataPtr();
+       int width = bitmap->getWidth();
+       int height = bitmap->getHeight();
+       jpeg_save(rgb, width, height, quality, output);
+      }
   }
   delete splashOut;
 
   exitCode = 0;
 
index 3edcc21..93629f3 100644 (file)
--- a/lib/ttf.c
+++ b/lib/ttf.c
@@ -404,7 +404,7 @@ static table_os2_t*os2_new(ttf_t*ttf)
        os2->yStrikeoutSize = ttf->head->units_per_em / 10;
        os2->yStrikeoutPosition = ymid;
        os2->usWinAscent = ttf->ascent;
-       os2->usWinDescent = -ttf->descent;
+       os2->usWinDescent = ttf->descent>0?0:-ttf->descent;
        os2->sxHeight = ymid;
        os2->sCapHeight = height*2/3;
     }
index 9a76949..8d5ea61 100644 (file)
--- a/lib/ttf.h
+++ b/lib/ttf.h
@@ -187,7 +187,7 @@ typedef struct _ttf {
     char is_vertical;
 
     S16 ascent;
-    S16 descent;
+    S16 descent; // ymin, *not* negative ymin
     S16 lineGap;
 
     int num_glyphs;