[poppler] 2 commits - glib/poppler-structure-element.cc poppler/FontInfo.cc poppler/GfxFont.h poppler/GlobalParams.cc poppler/PSOutputDev.cc poppler/PSOutputDev.h utils/HtmlFonts.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Thu Apr 5 10:58:59 UTC 2018


 glib/poppler-structure-element.cc |    2 +-
 poppler/FontInfo.cc               |    3 ++-
 poppler/GfxFont.h                 |    2 +-
 poppler/GlobalParams.cc           |   16 +++++++++-------
 poppler/PSOutputDev.cc            |    6 ++++--
 poppler/PSOutputDev.h             |    3 ++-
 utils/HtmlFonts.cc                |    3 ++-
 7 files changed, 21 insertions(+), 14 deletions(-)

New commits:
commit f75c0f5c3f9d63334cc21e0ab68f1af45d0037cc
Author: Albert Astals Cid <albert.astals.cid at kdab.com>
Date:   Thu Apr 5 12:58:34 2018 +0200

    Make GfxFont::getName const

diff --git a/glib/poppler-structure-element.cc b/glib/poppler-structure-element.cc
index a905fa46..38a6f62f 100644
--- a/glib/poppler-structure-element.cc
+++ b/glib/poppler-structure-element.cc
@@ -930,7 +930,7 @@ text_span_poppler_text_span (const TextSpan& span)
       {
         // GfxFont sometimes does not have a family name but there
         // is always a font name that can be used as fallback.
-        GooString *font_name = span.getFont ()->getFamily ();
+        const GooString *font_name = span.getFont ()->getFamily ();
         if (font_name == nullptr)
           font_name = span.getFont ()->getName ();
 
diff --git a/poppler/FontInfo.cc b/poppler/FontInfo.cc
index 15019eba..18f21f40 100644
--- a/poppler/FontInfo.cc
+++ b/poppler/FontInfo.cc
@@ -12,6 +12,7 @@
 // Copyright (C) 2010, 2013 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2011 Carlos Garcia Campos <carlosgc at gnome.org>
 // Copyright (C) 2012 Fabio D'Urso <fabiodurso at hotmail.it>
+// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info at kdab.com>. Work sponsored by the LiMux project of the city of Munich
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -153,7 +154,7 @@ void FontInfoScanner::scanFonts(XRef *xrefA, Dict *resDict, GooList *fontsList)
 }
 
 FontInfo::FontInfo(GfxFont *font, XRef *xref) {
-  GooString *origName;
+  const GooString *origName;
 
   fontRef = *font->getID();
 
diff --git a/poppler/GfxFont.h b/poppler/GfxFont.h
index b3ad420c..09d54244 100644
--- a/poppler/GfxFont.h
+++ b/poppler/GfxFont.h
@@ -209,7 +209,7 @@ public:
 
   // Get the original font name (ignornig any munging that might have
   // been done to map to a canonical Base-14 font name).
-  GooString *getName() { return name; }
+  const GooString *getName() const { return name; }
 
   // Get font type.
   GfxFontType getType() { return type; }
diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc
index c04aee1b..cbb15eb1 100644
--- a/poppler/GlobalParams.cc
+++ b/poppler/GlobalParams.cc
@@ -263,7 +263,7 @@ public:
   ~SysFontList();
   SysFontList(const SysFontList &) = delete;
   SysFontList& operator=(const SysFontList &) = delete;
-  SysFontInfo *find(GooString *name, GBool isFixedWidth, GBool exact);
+  SysFontInfo *find(const GooString *name, GBool isFixedWidth, GBool exact);
 
 #ifdef _WIN32
   void scanWindowsFonts(GooString *winFontDir);
@@ -289,7 +289,7 @@ SysFontList::~SysFontList() {
   deleteGooList(fonts, SysFontInfo);
 }
 
-SysFontInfo *SysFontList::find(GooString *name, GBool fixedWidth, GBool exact) {
+SysFontInfo *SysFontList::find(const GooString *name, GBool fixedWidth, GBool exact) {
   GooString *name2;
   GBool bold, italic, oblique;
   SysFontInfo *fi;
@@ -1108,7 +1108,7 @@ GooString *GlobalParams::findSystemFontFile(GfxFont *font,
   SysFontInfo *fi = nullptr;
   FcPattern *p=nullptr;
   GooString *path = nullptr;
-  GooString *fontName = font->getName();
+  const GooString *fontName = font->getName();
   GooString substituteName;
   if (!fontName) return nullptr;
   lockGlobalParams;
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index f20f0783..3aab7de7 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -31,6 +31,7 @@
 // Copyright (C) 2014 Till Kamppeter <till.kamppeter at gmail.com>
 // Copyright (C) 2015 Marek Kasik <mkasik at redhat.com>
 // Copyright (C) 2016 Caolán McNamara <caolanm at redhat.com>
+// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info at kdab.com>. Work sponsored by the LiMux project of the city of Munich
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -2866,7 +2867,8 @@ void PSOutputDev::setupType3Font(GfxFont *font, GooString *psName,
 // Make a unique PS font name, based on the names given in the PDF
 // font object, and an object ID (font file object for 
 GooString *PSOutputDev::makePSFontName(GfxFont *font, Ref *id) {
-  GooString *psName, *s;
+  GooString *psName;
+  const GooString *s;
 
   if ((s = font->getEmbeddedFontName())) {
     psName = filterPSName(s);
@@ -7478,7 +7480,7 @@ void PSOutputDev::writePSName(const char *s) {
   }
 }
 
-GooString *PSOutputDev::filterPSName(GooString *name) {
+GooString *PSOutputDev::filterPSName(const GooString *name) {
   GooString *name2;
   char buf[8];
   int i;
diff --git a/poppler/PSOutputDev.h b/poppler/PSOutputDev.h
index 330b81b3..b85c28d8 100644
--- a/poppler/PSOutputDev.h
+++ b/poppler/PSOutputDev.h
@@ -24,6 +24,7 @@
 // Copyright (C) 2010 Hib Eris <hib at hiberis.nl>
 // Copyright (C) 2011, 2014, 2017 Adrian Johnson <ajohnson at redneon.com>
 // Copyright (C) 2012 Fabio D'Urso <fabiodurso at hotmail.it>
+// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info at kdab.com>. Work sponsored by the LiMux project of the city of Munich
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -422,7 +423,7 @@ private:
 		    double *x1, double *y1);
 #endif
   void cvtFunction(Function *func, GBool invertPSFunction = gFalse);
-  GooString *filterPSName(GooString *name);
+  GooString *filterPSName(const GooString *name);
 
   // Write the document-level setup.
   void writeDocSetup(PDFDoc *doc, Catalog *catalog, const std::vector<int> &pages, GBool duplexA);
diff --git a/utils/HtmlFonts.cc b/utils/HtmlFonts.cc
index 53d53245..efb584b5 100644
--- a/utils/HtmlFonts.cc
+++ b/utils/HtmlFonts.cc
@@ -27,6 +27,7 @@
 // Copyright (C) 2012 Luis Parravicini <lparravi at gmail.com>
 // Copyright (C) 2013 Julien Nabet <serval2412 at yahoo.fr>
 // Copyright (C) 2017 Jason Crain <jason at inspiresomeone.us>
+// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info at kdab.com>. Work sponsored by the LiMux project of the city of Munich
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -111,7 +112,7 @@ HtmlFont::HtmlFont(GfxFont *font, int _size, GfxRGB rgb){
   //if (col) color=HtmlFontColor(col); 
   //else color=HtmlFontColor();
   color=HtmlFontColor(rgb);
-  GooString* ftname=font->getName();
+  const GooString* ftname=font->getName();
   if (!ftname) ftname = getDefaultFont();
 
   GooString *fontname = nullptr;
commit a669ad5cfb28cdfcfe38bbce39fbf8c6fc3102d9
Author: Albert Astals Cid <albert.astals.cid at kdab.com>
Date:   Thu Apr 5 12:55:39 2018 +0200

    buildFcPattern: Don't modify the actual name of the font
    
    When doing the '-' to ' ' replacement to build the fc pattern

diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc
index 50b7eee2..c04aee1b 100644
--- a/poppler/GlobalParams.cc
+++ b/poppler/GlobalParams.cc
@@ -37,6 +37,7 @@
 // Copyright (C) 2013, 2014 Jason Crain <jason at aquaticape.us>
 // Copyright (C) 2017 Christoph Cullmann <cullmann at kde.org>
 // Copyright (C) 2017 Jean Ghali <jghali at libertysurf.fr>
+// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info at kdab.com>. Work sponsored by the LiMux project of the city of Munich
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -953,7 +954,7 @@ static const char *getFontLang(GfxFont *font)
   return lang;
 }
 
-static FcPattern *buildFcPattern(GfxFont *font, GooString *base14Name)
+static FcPattern *buildFcPattern(GfxFont *font, const GooString *base14Name)
 {
   int weight = -1,
       slant = -1,
@@ -965,12 +966,13 @@ static FcPattern *buildFcPattern(GfxFont *font, GooString *base14Name)
   FcPattern *p;
 
   // this is all heuristics will be overwritten if font had proper info
-  name = (base14Name == nullptr) ? font->getName()->getCString() : base14Name->getCString();
-  
+  GooString copiedNameGooString(((base14Name == nullptr) ? font->getName() : base14Name)->getCString());
+  name = copiedNameGooString.getCString();
+
   modifiers = strchr (name, ',');
   if (modifiers == nullptr)
     modifiers = strchr (name, '-');
-  
+
   // remove the - from the names, for some reason, Fontconfig does not
   // understand "MS-Mincho" but does with "MS Mincho"
   int len = strlen(name);


More information about the poppler mailing list