utils/HtmlFonts.cc | 14 ++++++-------- utils/HtmlFonts.h | 14 +++++++------- utils/HtmlOutputDev.cc | 9 ++++----- utils/HtmlOutputDev.h | 4 ++-- 4 files changed, 19 insertions(+), 22 deletions(-)
New commits: commit 7489b99bc0e8ee22538e5c4697f43181e74044c1 Author: Albert Astals Cid <[email protected]> Date: Sun Jan 5 22:49:15 2020 +0100 Make HtmlFontAccu::Get const diff --git a/utils/HtmlFonts.h b/utils/HtmlFonts.h index 195f46fa..c44ce6a1 100644 --- a/utils/HtmlFonts.h +++ b/utils/HtmlFonts.h @@ -104,7 +104,7 @@ public: HtmlFontAccu(const HtmlFontAccu &) = delete; HtmlFontAccu& operator=(const HtmlFontAccu &) = delete; int AddFont(const HtmlFont& font); - HtmlFont *Get(int i){ + const HtmlFont *Get(int i) const { return &accu[i]; } GooString* CSStyle(int i, int j = 0); diff --git a/utils/HtmlOutputDev.cc b/utils/HtmlOutputDev.cc index a8af0ea9..b8a69e34 100644 --- a/utils/HtmlOutputDev.cc +++ b/utils/HtmlOutputDev.cc @@ -489,7 +489,6 @@ static void CloseTags( GooString *htext, bool &finish_a, bool &finish_italic, bo // It may also strip out duplicate strings (if they are on top of each other); sometimes they are to create a font effect void HtmlPage::coalesce() { HtmlString *str1, *str2; - HtmlFont *hfont1, *hfont2; double space, horSpace, vertSpace, vertOverlap; bool addSpace, addLineBreak; int n, i; @@ -551,7 +550,7 @@ void HtmlPage::coalesce() { str1 = yxStrings; - hfont1 = getFont(str1); + const HtmlFont *hfont1 = getFont(str1); if( hfont1->isBold() ) str1->htext->insert(0,"<b>",3); if( hfont1->isItalic() ) @@ -564,7 +563,7 @@ void HtmlPage::coalesce() { curX = str1->xMin; curY = str1->yMin; while (str1 && (str2 = str1->yxNext)) { - hfont2 = getFont(str2); + const HtmlFont *hfont2 = getFont(str2); space = str1->yMax - str1->yMin; // the height of the font's bounding box horSpace = str2->xMin - str1->xMax; // if strings line up on left-hand side AND they are on subsequent lines, we need a line break diff --git a/utils/HtmlOutputDev.h b/utils/HtmlOutputDev.h index e5823d27..b724ec18 100644 --- a/utils/HtmlOutputDev.h +++ b/utils/HtmlOutputDev.h @@ -14,7 +14,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2006, 2007, 2009, 2012, 2018, 2019 Albert Astals Cid <[email protected]> +// Copyright (C) 2006, 2007, 2009, 2012, 2018-2020 Albert Astals Cid <[email protected]> // Copyright (C) 2008, 2009 Warren Toomey <[email protected]> // Copyright (C) 2009, 2011 Carlos Garcia Campos <[email protected]> // Copyright (C) 2009 Kovid Goyal <[email protected]> @@ -167,7 +167,7 @@ public: void conv(); private: - HtmlFont* getFont(HtmlString *hStr) { return fonts->Get(hStr->fontpos); } + const HtmlFont* getFont(HtmlString *hStr) const { return fonts->Get(hStr->fontpos); } double fontSize; // current font size bool rawOrder; // keep strings in content stream order commit 6b1ee539705f1ddf8e252f1589866862ad688bc2 Author: Albert Astals Cid <[email protected]> Date: Sun Jan 5 22:43:52 2020 +0100 No need for HtmlFontAccu::accu to be a pointer at all diff --git a/utils/HtmlFonts.cc b/utils/HtmlFonts.cc index efd14cd2..964ab018 100644 --- a/utils/HtmlFonts.cc +++ b/utils/HtmlFonts.cc @@ -251,32 +251,30 @@ GooString* HtmlFont::HtmlFilter(const Unicode* u, int uLen) { } HtmlFontAccu::HtmlFontAccu(){ - accu=new std::vector<HtmlFont>(); } HtmlFontAccu::~HtmlFontAccu(){ - if (accu) delete accu; } int HtmlFontAccu::AddFont(const HtmlFont& font){ std::vector<HtmlFont>::iterator i; - for (i=accu->begin();i!=accu->end();++i) + for (i=accu.begin();i!=accu.end();++i) { if (font.isEqual(*i)) { - return (int)(i-(accu->begin())); + return (int)(i-(accu.begin())); } } - accu->push_back(font); - return (accu->size()-1); + accu.push_back(font); + return (accu.size()-1); } // get CSS font definition for font #i GooString* HtmlFontAccu::CSStyle(int i, int j){ GooString *tmp=new GooString(); - std::vector<HtmlFont>::iterator g=accu->begin(); + std::vector<HtmlFont>::iterator g=accu.begin(); g+=i; HtmlFont font=*g; GooString *colorStr=font.getColor().toString(); diff --git a/utils/HtmlFonts.h b/utils/HtmlFonts.h index 88cc1e8e..195f46fa 100644 --- a/utils/HtmlFonts.h +++ b/utils/HtmlFonts.h @@ -96,7 +96,7 @@ public: class HtmlFontAccu{ private: - std::vector<HtmlFont> *accu; + std::vector<HtmlFont> accu; public: HtmlFontAccu(); @@ -105,10 +105,10 @@ public: HtmlFontAccu& operator=(const HtmlFontAccu &) = delete; int AddFont(const HtmlFont& font); HtmlFont *Get(int i){ - return &(*accu)[i]; + return &accu[i]; } GooString* CSStyle(int i, int j = 0); - int size() const {return accu->size();} + int size() const {return accu.size();} }; #endif commit cb5bece4f51040cf1d3be5a32af83c989d9c7885 Author: Albert Astals Cid <[email protected]> Date: Sun Jan 5 22:41:32 2020 +0100 pdftohtml: Don't substract -2 to font size without any reason diff --git a/utils/HtmlFonts.cc b/utils/HtmlFonts.cc index a21e0ac2..efd14cd2 100644 --- a/utils/HtmlFonts.cc +++ b/utils/HtmlFonts.cc @@ -117,7 +117,7 @@ HtmlFont::HtmlFont(GfxFont *font, int _size, GfxRGB rgb){ lineSize = -1; - size=(_size-1); + size=_size; italic = false; bold = false; rotOrSkewed = false; diff --git a/utils/HtmlOutputDev.cc b/utils/HtmlOutputDev.cc index c86587ef..a8af0ea9 100644 --- a/utils/HtmlOutputDev.cc +++ b/utils/HtmlOutputDev.cc @@ -17,7 +17,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2013, 2016-2019 Albert Astals Cid <[email protected]> +// Copyright (C) 2005-2013, 2016-2020 Albert Astals Cid <[email protected]> // Copyright (C) 2008 Kjartan Maraas <[email protected]> // Copyright (C) 2008 Boris Toloknov <[email protected]> // Copyright (C) 2008 Haruyuki Kawabe <[email protected]> @@ -183,7 +183,7 @@ HtmlString::HtmlString(GfxState *state, double fontSize, HtmlFontAccu* _fonts) : yMax = y - descent * fontSize; GfxRGB rgb; state->getFillRGB(&rgb); - HtmlFont hfont=HtmlFont(font, static_cast<int>(fontSize-1), rgb); + HtmlFont hfont=HtmlFont(font, static_cast<int>(fontSize), rgb); if (isMatRotOrSkew(state->getTextMat())) { double normalizedMatrix[4]; memcpy(normalizedMatrix, state->getTextMat(), sizeof(normalizedMatrix)); commit fb9ada7648cb3adb0b8791bab098de1e89c75226 Author: Albert Astals Cid <[email protected]> Date: Sun Jan 5 22:40:12 2020 +0100 pdftohtml: Make HtmlFont::size an int It comes from a double so it could potentially be negative diff --git a/utils/HtmlFonts.h b/utils/HtmlFonts.h index 33b555d5..88cc1e8e 100644 --- a/utils/HtmlFonts.h +++ b/utils/HtmlFonts.h @@ -18,7 +18,7 @@ // under GPL version 2 or later // // Copyright (C) 2010 OSSD CDAC Mumbai by Leena Chourey ([email protected]) and Onkar Potdar ([email protected]) -// Copyright (C) 2010, 2012, 2017, 2018 Albert Astals Cid <[email protected]> +// Copyright (C) 2010, 2012, 2017, 2018, 2020 Albert Astals Cid <[email protected]> // Copyright (C) 2011 Steven Murdoch <[email protected]> // Copyright (C) 2011 Joshua Richardson <[email protected]> // Copyright (C) 2012 Igor Slepchin <[email protected]> @@ -61,7 +61,7 @@ class HtmlFontColor{ class HtmlFont{ private: - unsigned int size; + int size; int lineSize; bool italic; bool bold; @@ -81,7 +81,7 @@ public: bool isItalic() const {return italic;} bool isBold() const {return bold;} bool isRotOrSkewed() const { return rotOrSkewed; } - unsigned int getSize() const {return size;} + int getSize() const {return size;} int getLineSize() const {return lineSize;} void setLineSize(int _lineSize) { lineSize = _lineSize; } void setRotMat(const double * const mat) _______________________________________________ poppler mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/poppler
