From e343e192de76238b5606bb93affa9e4ccb40a2c2 Mon Sep 17 00:00:00 2001 From: Ryan Fox Date: Mon, 24 Jun 2013 16:09:58 -0400 Subject: [PATCH 4/4] There are several instances where double values from Poppler were being truncated and stuff into ints. The double precision is necessary to get the correct positioning and sizes, so let's restore them. --- utils/HtmlFonts.cc | 4 ++-- utils/HtmlFonts.h | 14 +++++++------- utils/HtmlOutputDev.cc | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/utils/HtmlFonts.cc b/utils/HtmlFonts.cc index 472c9ef..4745b3b 100644 --- a/utils/HtmlFonts.cc +++ b/utils/HtmlFonts.cc @@ -84,7 +84,7 @@ GooString *HtmlFontColor::toString() const{ return GooString::format("rgba({0:ud}, {1:ud}, {2:ud}, {3:.2f})", r, g, b, trans); } -HtmlFont::HtmlFont(GfxFont *font, int _size, GfxRGB stroke, double strokeTrans, GfxRGB fill, double fillTrans, int _render){ +HtmlFont::HtmlFont(GfxFont *font, double _size, GfxRGB stroke, double strokeTrans, GfxRGB fill, double fillTrans, int _render){ //if (col) color=HtmlFontColor(col); //else color=HtmlFontColor(); strokeColor=HtmlFontColor(stroke, strokeTrans); @@ -304,7 +304,7 @@ GooString* HtmlFontAccu::CSStyle(int i, int j){ std::vector::iterator g=accu->begin(); g+=i; HtmlFont font=*g; - GooString *Size=GooString::fromInt(font.getSize()); + GooString *Size=GooString::fromDouble(font.getSize(), 5); GooString *fillColorStr=font.getFillColor().toString(); GooString *strokeColorStr=font.getStrokeColor().toString(); int render = font.getRender(); diff --git a/utils/HtmlFonts.h b/utils/HtmlFonts.h index c150955..b8436ce 100644 --- a/utils/HtmlFonts.h +++ b/utils/HtmlFonts.h @@ -61,8 +61,8 @@ class HtmlFontColor{ class HtmlFont{ private: - unsigned int size; - int lineSize; + double size; + double lineSize; GBool italic; GBool bold; GBool rotOrSkewed; @@ -76,7 +76,7 @@ class HtmlFont{ public: HtmlFont(){FontName=NULL; rotOrSkewed = gFalse;} - HtmlFont(GfxFont *font, int _size, GfxRGB stroke, double strokeTrans, GfxRGB fill, double fillTrans, int _render); + HtmlFont(GfxFont *font, double _size, GfxRGB stroke, double strokeTrans, GfxRGB fill, double fillTrans, int _render); HtmlFont(const HtmlFont& x); HtmlFont& operator=(const HtmlFont& x); HtmlFontColor getFillColor() const {return fillColor;} @@ -88,9 +88,9 @@ public: GBool isBold() const {return bold;} GBool isRotOrSkewed() const { return rotOrSkewed; } int getRender() const {return render;} - unsigned int getSize() const {return size;} - int getLineSize() const {return lineSize;} - void setLineSize(int _lineSize) { lineSize = _lineSize; } + double getSize() const {return size;} + double getLineSize() const {return lineSize;} + void setLineSize(double _lineSize) { lineSize = _lineSize; } void setRotMat(const double * const mat) { rotOrSkewed = gTrue; memcpy(rotSkewMat, mat, sizeof(rotSkewMat)); } const double *getRotMat() const { return rotSkewMat; } @@ -101,7 +101,7 @@ public: GBool isEqual(const HtmlFont& x) const; GBool isEqualIgnoreBold(const HtmlFont& x) const; static GooString* simple(HtmlFont *font, Unicode *content, int uLen); - void print() const {printf("font: %s %d %s%spos: %d\n", FontName->getCString(), size, bold ? "bold " : "", italic ? "italic " : "", pos);}; + void print() const {printf("font: %s %g %s%spos: %d\n", FontName->getCString(), size, bold ? "bold " : "", italic ? "italic " : "", pos);}; }; class HtmlFontAccu{ diff --git a/utils/HtmlOutputDev.cc b/utils/HtmlOutputDev.cc index d644cdf..3d5004d 100644 --- a/utils/HtmlOutputDev.cc +++ b/utils/HtmlOutputDev.cc @@ -764,8 +764,8 @@ void HtmlPage::dumpAsXML(FILE* f,int page){ for(HtmlString *tmp=yxStrings;tmp;tmp=tmp->yxNext){ if (tmp->htext){ - fprintf(f,"yMin),xoutRound(tmp->xMin)); - fprintf(f,"width=\"%d\" height=\"%d\" ",xoutRound(tmp->xMax-tmp->xMin),xoutRound(tmp->yMax-tmp->yMin)); + fprintf(f,"yMin,tmp->xMin); + fprintf(f,"width=\"%g\" height=\"%g\" ",tmp->xMax-tmp->xMin,tmp->yMax-tmp->yMin); fprintf(f,"font=\"%d\">", tmp->fontpos); fputs(tmp->htext->getCString(),f); fputs("\n",f); -- 1.7.9.5