From 4f2366641015f517c0e4f841b7ae6a9b90c7b184 Mon Sep 17 00:00:00 2001 From: Matthias Kramm Date: Tue, 16 Mar 2010 16:57:59 -0700 Subject: [PATCH] trivial bug fixes --- lib/filters/remove_font_transforms.c | 2 +- lib/gfxfont.c | 2 +- lib/pdf/pdf2jpeg.c | 30 ++++++++++++++---------------- lib/ttf.c | 2 +- lib/ttf.h | 2 +- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/lib/filters/remove_font_transforms.c b/lib/filters/remove_font_transforms.c index 84a873c..06e8031 100644 --- a/lib/filters/remove_font_transforms.c +++ b/lib/filters/remove_font_transforms.c @@ -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;tglyphs[t].line; diff --git a/lib/gfxfont.c b/lib/gfxfont.c index e99816c..119f003 100644 --- a/lib/gfxfont.c +++ b/lib/gfxfont.c @@ -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); diff --git a/lib/pdf/pdf2jpeg.c b/lib/pdf/pdf2jpeg.c index f354726..4a3fb16 100644 --- a/lib/pdf/pdf2jpeg.c +++ b/lib/pdf/pdf2jpeg.c @@ -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; diff --git a/lib/ttf.c b/lib/ttf.c index 3edcc21..93629f3 100644 --- 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; } diff --git a/lib/ttf.h b/lib/ttf.h index 9a76949..8d5ea61 100644 --- 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; -- 1.7.10.4