fofi/FoFiTrueType.cc         |   18 ++---
 fofi/FoFiTrueType.h          |    5 -
 poppler/CairoFontEngine.cc   |   27 +++-----
 poppler/GfxFont.cc           |  132 +++++++++++++++++++++----------------------
 poppler/GfxFont.h            |   25 +++++---
 poppler/PSOutputDev.cc       |   54 ++++++-----------
 poppler/PSOutputDev.h        |    6 -
 poppler/SplashOutputDev.cc   |   26 +++-----
 qt5/src/QPainterOutputDev.cc |   18 ++---
 qt6/src/QPainterOutputDev.cc |   18 ++---
 splash/SplashFTFontEngine.cc |    3 
 splash/SplashFontFile.cc     |    2 
 splash/SplashFontFile.h      |    2 
 13 files changed, 159 insertions(+), 177 deletions(-)

New commits:
commit 4d3c2cb33bb0b71697fee27fc0ed6da4ba81bb53
Author: Oliver Sander <oliver.san...@tu-dresden.de>
Date:   Fri Dec 31 11:29:16 2021 +0100

    Remove a bit of duplicate code

diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index e99985d4..0c04cae4 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -726,20 +726,16 @@ std::optional<GfxFontLoc> GfxFont::locateFont(XRef *xref, 
PSOutputDev *ps)
                 return std::move(fontLoc); // std::move only required to 
please g++-7
             }
         } else {
+            GfxFontLoc fontLoc;
+            fontLoc.setPath(path);
+            fontLoc.locType = gfxFontLocExternal;
             if (sysFontType == sysFontTTF || sysFontType == sysFontTTC) {
-                GfxFontLoc fontLoc;
-                fontLoc.locType = gfxFontLocExternal;
                 fontLoc.fontType = fontTrueType;
-                fontLoc.setPath(path);
-                return std::move(fontLoc); // std::move only required to 
please g++-7
             } else if (sysFontType == sysFontPFA || sysFontType == sysFontPFB) 
{
-                GfxFontLoc fontLoc;
-                fontLoc.locType = gfxFontLocExternal;
                 fontLoc.fontType = fontType1;
-                fontLoc.setPath(path);
                 fontLoc.fontNum = fontNum;
-                return std::move(fontLoc); // std::move only required to 
please g++-7
             }
+            return std::move(fontLoc); // std::move only required to please 
g++-7
         }
         delete path;
     }
commit 953c9c762f346236d856327833f3a550b993138a
Author: Oliver Sander <oliver.san...@tu-dresden.de>
Date:   Thu Dec 30 10:46:46 2021 +0100

    Let FoFiTrueType::make and ...::load return std::unique_ptr
    
    Because these methods do release the object ownership.

diff --git a/fofi/FoFiTrueType.cc b/fofi/FoFiTrueType.cc
index ce592b8c..d1ab233f 100644
--- a/fofi/FoFiTrueType.cc
+++ b/fofi/FoFiTrueType.cc
@@ -450,33 +450,31 @@ static const char *macGlyphNames[258] = { ".notdef",
 // FoFiTrueType
 //------------------------------------------------------------------------
 
-FoFiTrueType *FoFiTrueType::make(const char *fileA, int lenA, int faceIndexA)
+std::unique_ptr<FoFiTrueType> FoFiTrueType::make(const char *fileA, int lenA, 
int faceIndexA)
 {
-    FoFiTrueType *ff;
-
-    ff = new FoFiTrueType(fileA, lenA, false, faceIndexA);
+    // Cannot use std::make_unique, because the constructor is private
+    auto ff = new FoFiTrueType(fileA, lenA, false, faceIndexA);
     if (!ff->parsedOk) {
         delete ff;
         return nullptr;
     }
-    return ff;
+    return std::unique_ptr<FoFiTrueType>(ff);
 }
 
-FoFiTrueType *FoFiTrueType::load(const char *fileName, int faceIndexA)
+std::unique_ptr<FoFiTrueType> FoFiTrueType::load(const char *fileName, int 
faceIndexA)
 {
-    FoFiTrueType *ff;
     char *fileA;
     int lenA;
 
     if (!(fileA = FoFiBase::readFile(fileName, &lenA))) {
         return nullptr;
     }
-    ff = new FoFiTrueType(fileA, lenA, true, faceIndexA);
+    // Cannot use std::make_unique, because the constructor is private
+    auto ff = new FoFiTrueType(fileA, lenA, true, faceIndexA);
     if (!ff->parsedOk) {
-        delete ff;
         return nullptr;
     }
-    return ff;
+    return std::unique_ptr<FoFiTrueType>(ff);
 }
 
 FoFiTrueType::FoFiTrueType(const char *fileA, int lenA, bool freeFileDataA, 
int faceIndexA) : FoFiBase(fileA, lenA, freeFileDataA)
diff --git a/fofi/FoFiTrueType.h b/fofi/FoFiTrueType.h
index b90ae2be..908438c0 100644
--- a/fofi/FoFiTrueType.h
+++ b/fofi/FoFiTrueType.h
@@ -29,6 +29,7 @@
 #define FOFITRUETYPE_H
 
 #include <cstddef>
+#include <memory>
 #include <unordered_map>
 #include <string>
 #include "FoFiBase.h"
@@ -46,10 +47,10 @@ class POPPLER_PRIVATE_EXPORT FoFiTrueType : public FoFiBase
 {
 public:
     // Create a FoFiTrueType object from a memory buffer.
-    static FoFiTrueType *make(const char *fileA, int lenA, int faceIndexA = 0);
+    static std::unique_ptr<FoFiTrueType> make(const char *fileA, int lenA, int 
faceIndexA = 0);
 
     // Create a FoFiTrueType object from a file on disk.
-    static FoFiTrueType *load(const char *fileName, int faceIndexA = 0);
+    static std::unique_ptr<FoFiTrueType> load(const char *fileName, int 
faceIndexA = 0);
 
     ~FoFiTrueType() override;
 
diff --git a/poppler/CairoFontEngine.cc b/poppler/CairoFontEngine.cc
index c39a3a55..4d98d0f2 100644
--- a/poppler/CairoFontEngine.cc
+++ b/poppler/CairoFontEngine.cc
@@ -351,7 +351,6 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont 
*gfxFont, XRef *xref, FT_Li
     std::optional<GfxFontLoc> fontLoc;
     char **enc;
     const char *name;
-    FoFiTrueType *ff;
     FoFiType1C *ff1c;
     Ref ref;
     FT_Face face;
@@ -436,6 +435,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont 
*gfxFont, XRef *xref, FT_Li
                 memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(), n * 
sizeof(int));
             }
         } else {
+            std::unique_ptr<FoFiTrueType> ff;
             if (font_data != nullptr) {
                 ff = FoFiTrueType::make(font_data, font_data_len);
             } else {
@@ -443,13 +443,13 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont 
*gfxFont, XRef *xref, FT_Li
             }
             if (!ff)
                 goto err2;
-            codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n);
-            delete ff;
+            codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff.get(), &n);
         }
         codeToGIDLen = n;
         /* Fall through */
     case fontTrueType:
-    case fontTrueTypeOT:
+    case fontTrueTypeOT: {
+        std::unique_ptr<FoFiTrueType> ff;
         if (font_data != nullptr) {
             ff = FoFiTrueType::make(font_data, font_data_len);
         } else {
@@ -461,16 +461,15 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont 
*gfxFont, XRef *xref, FT_Li
         }
         /* This might be set already for the CIDType2 case */
         if (fontType == fontTrueType || fontType == fontTrueTypeOT) {
-            codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff);
+            codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff.get());
             codeToGIDLen = 256;
         }
-        delete ff;
         if (!_ft_new_face(lib, fileNameC, font_data, font_data_len, &face, 
&font_face)) {
             error(errSyntaxError, -1, "could not create truetype face\n");
             goto err2;
         }
         break;
-
+    }
     case fontCIDType0:
     case fontCIDType0C:
 
@@ -509,6 +508,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont 
*gfxFont, XRef *xref, FT_Li
 
         if (!codeToGID) {
             if (!useCIDs) {
+                std::unique_ptr<FoFiTrueType> ff;
                 if (font_data != nullptr) {
                     ff = FoFiTrueType::make(font_data, font_data_len);
                 } else {
@@ -518,7 +518,6 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont 
*gfxFont, XRef *xref, FT_Li
                     if (ff->isOpenTypeCFF()) {
                         codeToGID = ff->getCIDToGIDMap((int *)&codeToGIDLen);
                     }
-                    delete ff;
                 }
             }
         }
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index d014f471..fb4af2e2 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -2405,7 +2405,6 @@ void PSOutputDev::setupEmbeddedOpenTypeT1CFont(GfxFont 
*font, Ref *id, GooString
 {
     char *fontBuf;
     int fontLen;
-    FoFiTrueType *ffTT;
     int i;
 
     // check if font is already embedded
@@ -2432,11 +2431,10 @@ void PSOutputDev::setupEmbeddedOpenTypeT1CFont(GfxFont 
*font, Ref *id, GooString
 
     // convert it to a Type 1 font
     if ((fontBuf = font->readEmbFontFile(xref, &fontLen))) {
-        if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) {
+        if (std::unique_ptr<FoFiTrueType> ffTT = FoFiTrueType::make(fontBuf, 
fontLen)) {
             if (ffTT->isOpenTypeCFF()) {
                 ffTT->convertToType1(psName->c_str(), nullptr, true, 
outputFunc, outputStream);
             }
-            delete ffTT;
         }
         gfree(fontBuf);
     }
@@ -2449,7 +2447,6 @@ void PSOutputDev::setupEmbeddedTrueTypeFont(GfxFont 
*font, Ref *id, GooString *p
 {
     char *fontBuf;
     int fontLen;
-    FoFiTrueType *ffTT;
     int *codeToGID;
 
     // beginning comment
@@ -2460,8 +2457,8 @@ void PSOutputDev::setupEmbeddedTrueTypeFont(GfxFont 
*font, Ref *id, GooString *p
 
     // convert it to a Type 42 font
     if ((fontBuf = font->readEmbFontFile(xref, &fontLen))) {
-        if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) {
-            codeToGID = ((Gfx8BitFont *)font)->getCodeToGIDMap(ffTT);
+        if (std::unique_ptr<FoFiTrueType> ffTT = FoFiTrueType::make(fontBuf, 
fontLen)) {
+            codeToGID = ((Gfx8BitFont *)font)->getCodeToGIDMap(ffTT.get());
             ffTT->convertToType42(psName->c_str(), ((Gfx8BitFont 
*)font)->getHasEncoding() ? ((Gfx8BitFont *)font)->getEncoding() : nullptr, 
codeToGID, outputFunc, outputStream);
             if (codeToGID) {
                 if (font8InfoLen >= font8InfoSize) {
@@ -2472,7 +2469,6 @@ void PSOutputDev::setupEmbeddedTrueTypeFont(GfxFont 
*font, Ref *id, GooString *p
                 font8Info[font8InfoLen].codeToGID = codeToGID;
                 ++font8InfoLen;
             }
-            delete ffTT;
         }
         gfree(fontBuf);
     }
@@ -2483,7 +2479,6 @@ void PSOutputDev::setupEmbeddedTrueTypeFont(GfxFont 
*font, Ref *id, GooString *p
 
 void PSOutputDev::setupExternalTrueTypeFont(GfxFont *font, const GooString 
*fileName, GooString *psName)
 {
-    FoFiTrueType *ffTT;
     int *codeToGID;
 
     // beginning comment
@@ -2493,8 +2488,8 @@ void PSOutputDev::setupExternalTrueTypeFont(GfxFont 
*font, const GooString *file
     embFontList->append("\n");
 
     // convert it to a Type 42 font
-    if ((ffTT = FoFiTrueType::load(fileName->c_str()))) {
-        codeToGID = ((Gfx8BitFont *)font)->getCodeToGIDMap(ffTT);
+    if (std::unique_ptr<FoFiTrueType> ffTT = 
FoFiTrueType::load(fileName->c_str())) {
+        codeToGID = ((Gfx8BitFont *)font)->getCodeToGIDMap(ffTT.get());
         ffTT->convertToType42(psName->c_str(), ((Gfx8BitFont 
*)font)->getHasEncoding() ? ((Gfx8BitFont *)font)->getEncoding() : nullptr, 
codeToGID, outputFunc, outputStream);
         if (codeToGID) {
             if (font8InfoLen >= font8InfoSize) {
@@ -2505,7 +2500,6 @@ void PSOutputDev::setupExternalTrueTypeFont(GfxFont 
*font, const GooString *file
             font8Info[font8InfoLen].codeToGID = codeToGID;
             ++font8InfoLen;
         }
-        delete ffTT;
     }
 
     // ending comment
@@ -2524,7 +2518,6 @@ void PSOutputDev::updateFontMaxValidGlyph(GfxFont *font, 
int maxValidGlyph)
 
 void PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont *font, const GooString 
*fileName, GooString *psName, bool needVerticalMetrics)
 {
-    FoFiTrueType *ffTT;
     int *codeToGID;
     int codeToGIDLen;
 
@@ -2536,7 +2529,7 @@ void PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont 
*font, const GooString *f
 
     // convert it to a Type 0 font
     //~ this should use fontNum to load the correct font
-    if ((ffTT = FoFiTrueType::load(fileName->c_str()))) {
+    if (std::unique_ptr<FoFiTrueType> ffTT = 
FoFiTrueType::load(fileName->c_str())) {
 
         // check for embedding permission
         if (ffTT->getEmbeddingRights() >= 1) {
@@ -2549,7 +2542,7 @@ void PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont 
*font, const GooString *f
                     memcpy(codeToGID, ((GfxCIDFont *)font)->getCIDToGID(), 
codeToGIDLen * sizeof(int));
                 }
             } else {
-                codeToGID = ((GfxCIDFont *)font)->getCodeToGIDMap(ffTT, 
&codeToGIDLen);
+                codeToGID = ((GfxCIDFont *)font)->getCodeToGIDMap(ffTT.get(), 
&codeToGIDLen);
             }
             if (ffTT->isOpenTypeCFF()) {
                 ffTT->convertToCIDType0(psName->c_str(), codeToGID, 
codeToGIDLen, outputFunc, outputStream);
@@ -2566,7 +2559,6 @@ void PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont 
*font, const GooString *f
         } else {
             error(errSyntaxError, -1, "TrueType font '{0:s}' does not allow 
embedding", font->getName() ? font->getName()->c_str() : "(unnamed)");
         }
-        delete ffTT;
     }
 
     // ending comment
@@ -2625,7 +2617,6 @@ void PSOutputDev::setupEmbeddedCIDTrueTypeFont(GfxFont 
*font, Ref *id, GooString
 {
     char *fontBuf;
     int fontLen;
-    FoFiTrueType *ffTT;
 
     // beginning comment
     writePSFmt("%%BeginResource: font {0:t}\n", psName);
@@ -2635,7 +2626,7 @@ void PSOutputDev::setupEmbeddedCIDTrueTypeFont(GfxFont 
*font, Ref *id, GooString
 
     // convert it to a Type 0 font
     if ((fontBuf = font->readEmbFontFile(xref, &fontLen))) {
-        if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) {
+        if (std::unique_ptr<FoFiTrueType> ffTT = FoFiTrueType::make(fontBuf, 
fontLen)) {
             if (level >= psLevel3) {
                 // Level 3: use a CID font
                 ffTT->convertToCIDType2(psName->c_str(), ((GfxCIDFont 
*)font)->getCIDToGID(), ((GfxCIDFont *)font)->getCIDToGIDLen(), 
needVerticalMetrics, outputFunc, outputStream);
@@ -2645,7 +2636,6 @@ void PSOutputDev::setupEmbeddedCIDTrueTypeFont(GfxFont 
*font, Ref *id, GooString
                 ffTT->convertToType0(psName->c_str(), ((GfxCIDFont 
*)font)->getCIDToGID(), ((GfxCIDFont *)font)->getCIDToGIDLen(), 
needVerticalMetrics, &maxValidGlyph, outputFunc, outputStream);
                 updateFontMaxValidGlyph(font, maxValidGlyph);
             }
-            delete ffTT;
         }
         gfree(fontBuf);
     }
@@ -2658,7 +2648,6 @@ void PSOutputDev::setupEmbeddedOpenTypeCFFFont(GfxFont 
*font, Ref *id, GooString
 {
     char *fontBuf;
     int fontLen;
-    FoFiTrueType *ffTT;
     int i;
 
     // check if font is already embedded
@@ -2685,7 +2674,7 @@ void PSOutputDev::setupEmbeddedOpenTypeCFFFont(GfxFont 
*font, Ref *id, GooString
 
     // convert it to a Type 0 font
     if ((fontBuf = font->readEmbFontFile(xref, &fontLen))) {
-        if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) {
+        if (std::unique_ptr<FoFiTrueType> ffTT = FoFiTrueType::make(fontBuf, 
fontLen)) {
             if (ffTT->isOpenTypeCFF()) {
                 if (level >= psLevel3) {
                     // Level 3: use a CID font
@@ -2695,7 +2684,6 @@ void PSOutputDev::setupEmbeddedOpenTypeCFFFont(GfxFont 
*font, Ref *id, GooString
                     ffTT->convertToType0(psName->c_str(), ((GfxCIDFont 
*)font)->getCIDToGID(), ((GfxCIDFont *)font)->getCIDToGIDLen(), outputFunc, 
outputStream);
                 }
             }
-            delete ffTT;
         }
         gfree(fontBuf);
     }
diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index 4be799ce..c337e4e4 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -1828,7 +1828,6 @@ void SplashOutputDev::doUpdateFont(GfxState *state)
     SplashOutFontFileID *id = nullptr;
     SplashFontFile *fontFile;
     SplashFontSrc *fontsrc = nullptr;
-    FoFiTrueType *ff;
     char *tmpBuf;
     int tmpBufLen;
     const double *textMat;
@@ -1926,6 +1925,7 @@ reload:
             break;
         case fontTrueType:
         case fontTrueTypeOT: {
+            std::unique_ptr<FoFiTrueType> ff;
             if (fileName)
                 ff = FoFiTrueType::load(fileName->c_str());
             else
@@ -1933,8 +1933,7 @@ reload:
             int *codeToGID;
             const int n = ff ? 256 : 0;
             if (ff) {
-                codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff);
-                delete ff;
+                codeToGID = ((Gfx8BitFont 
*)gfxFont)->getCodeToGIDMap(ff.get());
                 // if we're substituting for a non-TrueType font, we need to 
mark
                 // all notdef codes as "do not draw" (rather than drawing 
TrueType
                 // notdef glyphs)
@@ -1996,6 +1995,7 @@ reload:
                     memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(), 
n * sizeof(int));
                 }
             } else {
+                std::unique_ptr<FoFiTrueType> ff;
                 if (fileName)
                     ff = FoFiTrueType::load(fileName->c_str());
                 else
@@ -2004,8 +2004,7 @@ reload:
                     error(errSyntaxError, -1, "Couldn't create a font for 
'{0:s}'", gfxFont->getName() ? gfxFont->getName()->c_str() : "(unnamed)");
                     goto err2;
                 }
-                codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n);
-                delete ff;
+                codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff.get(), 
&n);
             }
             if (!(fontFile = fontEngine->loadTrueTypeFont(id, fontsrc, 
codeToGID, n, faceIndex))) {
                 error(errSyntaxError, -1, "Couldn't create a font for 
'{0:s}'", gfxFont->getName() ? gfxFont->getName()->c_str() : "(unnamed)");
diff --git a/qt5/src/QPainterOutputDev.cc b/qt5/src/QPainterOutputDev.cc
index 1b3101dc..e0cf87fe 100644
--- a/qt5/src/QPainterOutputDev.cc
+++ b/qt5/src/QPainterOutputDev.cc
@@ -589,7 +589,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
         }
         case fontTrueType:
         case fontTrueTypeOT: {
-            auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::load(fontLoc->path.c_str())) : 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::make(tmpBuf.get(), tmpBufLen));
+            auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
FoFiTrueType::load(fontLoc->path.c_str()) : FoFiTrueType::make(tmpBuf.get(), 
tmpBufLen);
 
             m_codeToGIDCache[id] = (ff) ? ((Gfx8BitFont 
*)gfxFont)->getCodeToGIDMap(ff.get()) : nullptr;
 
@@ -624,7 +624,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
             int nCIDs = 0;
 
             if (!codeToGID && !m_useCIDs) {
-                auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::load(fontLoc->path.c_str())) : 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::make(tmpBuf.get(), tmpBufLen));
+                auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
FoFiTrueType::load(fontLoc->path.c_str()) : FoFiTrueType::make(tmpBuf.get(), 
tmpBufLen);
 
                 if (ff && ff->isOpenTypeCFF()) {
                     cidToGIDMap = ff->getCIDToGIDMap(&nCIDs);
@@ -646,7 +646,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
                     memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(), 
codeToGIDLen * sizeof(int));
                 }
             } else {
-                auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::load(fontLoc->path.c_str())) : 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::make(tmpBuf.get(), tmpBufLen));
+                auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
FoFiTrueType::load(fontLoc->path.c_str()) : FoFiTrueType::make(tmpBuf.get(), 
tmpBufLen);
                 if (!ff) {
                     return;
                 }
diff --git a/qt6/src/QPainterOutputDev.cc b/qt6/src/QPainterOutputDev.cc
index 1b3101dc..e0cf87fe 100644
--- a/qt6/src/QPainterOutputDev.cc
+++ b/qt6/src/QPainterOutputDev.cc
@@ -589,7 +589,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
         }
         case fontTrueType:
         case fontTrueTypeOT: {
-            auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::load(fontLoc->path.c_str())) : 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::make(tmpBuf.get(), tmpBufLen));
+            auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
FoFiTrueType::load(fontLoc->path.c_str()) : FoFiTrueType::make(tmpBuf.get(), 
tmpBufLen);
 
             m_codeToGIDCache[id] = (ff) ? ((Gfx8BitFont 
*)gfxFont)->getCodeToGIDMap(ff.get()) : nullptr;
 
@@ -624,7 +624,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
             int nCIDs = 0;
 
             if (!codeToGID && !m_useCIDs) {
-                auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::load(fontLoc->path.c_str())) : 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::make(tmpBuf.get(), tmpBufLen));
+                auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
FoFiTrueType::load(fontLoc->path.c_str()) : FoFiTrueType::make(tmpBuf.get(), 
tmpBufLen);
 
                 if (ff && ff->isOpenTypeCFF()) {
                     cidToGIDMap = ff->getCIDToGIDMap(&nCIDs);
@@ -646,7 +646,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
                     memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(), 
codeToGIDLen * sizeof(int));
                 }
             } else {
-                auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::load(fontLoc->path.c_str())) : 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::make(tmpBuf.get(), tmpBufLen));
+                auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
FoFiTrueType::load(fontLoc->path.c_str()) : FoFiTrueType::make(tmpBuf.get(), 
tmpBufLen);
                 if (!ff) {
                     return;
                 }
diff --git a/splash/SplashFTFontEngine.cc b/splash/SplashFTFontEngine.cc
index de0ca1ee..bbfe66f6 100644
--- a/splash/SplashFTFontEngine.cc
+++ b/splash/SplashFTFontEngine.cc
@@ -119,7 +119,6 @@ SplashFontFile 
*SplashFTFontEngine::loadCIDFont(SplashFontFileID *idA, SplashFon
 
 SplashFontFile *SplashFTFontEngine::loadOpenTypeCFFFont(SplashFontFileID *idA, 
SplashFontSrc *src, int *codeToGID, int codeToGIDLen)
 {
-    FoFiTrueType *ff;
     int *cidToGIDMap;
     int nCIDs;
     SplashFontFile *ret;
@@ -128,6 +127,7 @@ SplashFontFile 
*SplashFTFontEngine::loadOpenTypeCFFFont(SplashFontFileID *idA, S
     nCIDs = 0;
     if (!codeToGID) {
         if (!useCIDs) {
+            std::unique_ptr<FoFiTrueType> ff;
             if (src->isFile) {
                 ff = FoFiTrueType::load(src->fileName->c_str());
             } else {
@@ -137,7 +137,6 @@ SplashFontFile 
*SplashFTFontEngine::loadOpenTypeCFFFont(SplashFontFileID *idA, S
                 if (ff->isOpenTypeCFF()) {
                     cidToGIDMap = ff->getCIDToGIDMap(&nCIDs);
                 }
-                delete ff;
             }
         }
     }
commit 9389df54ca8f9c182153aa13eb1109ea98fb307c
Author: Oliver Sander <oliver.san...@tu-dresden.de>
Date:   Wed Dec 29 13:25:13 2021 +0100

    Allocate GfxFontLoc object on the stack
    
    Compared to the heap storage used previously, this saves one layer
    of indirection and the heap memory management.
    
    The new code uses C++17's std::optional class to model the
    'no fontLoc' value previously encoded by 'nullptr'.

diff --git a/poppler/CairoFontEngine.cc b/poppler/CairoFontEngine.cc
old mode 100755
new mode 100644
index b9a1ad60..c39a3a55
--- a/poppler/CairoFontEngine.cc
+++ b/poppler/CairoFontEngine.cc
@@ -31,6 +31,7 @@
 // Copyright (C) 2018 Adam Reichold <adam.reich...@t-online.de>
 // Copyright (C) 2019 Christian Persch <c...@src.gnome.org>
 // Copyright (C) 2020 Michal <sudols...@gmail.com>
+// Copyright (C) 2021 Oliver Sander <oliver.san...@tu-dresden.de>
 //
 // 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
@@ -347,7 +348,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont 
*gfxFont, XRef *xref, FT_Li
     int font_data_len;
     int i, n;
     GfxFontType fontType;
-    GfxFontLoc *fontLoc;
+    std::optional<GfxFontLoc> fontLoc;
     char **enc;
     const char *name;
     FoFiTrueType *ff;
@@ -533,12 +534,9 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont 
*gfxFont, XRef *xref, FT_Li
         break;
     }
 
-    delete fontLoc;
     return new CairoFreeTypeFont(ref, font_face, codeToGID, codeToGIDLen, 
substitute);
 
 err2:
-    /* hmm? */
-    delete fontLoc;
     gfree(codeToGID);
     gfree(font_data);
     fprintf(stderr, "some font thing failed\n");
diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index 3abde7a4..e99985d4 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -178,6 +178,10 @@ GfxFontLoc::GfxFontLoc()
 
 GfxFontLoc::~GfxFontLoc() = default;
 
+GfxFontLoc::GfxFontLoc(GfxFontLoc &&other) noexcept = default;
+
+GfxFontLoc &GfxFontLoc::operator=(GfxFontLoc &&other) noexcept = default;
+
 void GfxFontLoc::setPath(GooString *pathA)
 {
     path = pathA->toStr();
@@ -619,16 +623,15 @@ CharCodeToUnicode *GfxFont::readToUnicodeCMap(Dict 
*fontDict, int nBits, CharCod
     return ctu;
 }
 
-GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev *ps)
+std::optional<GfxFontLoc> GfxFont::locateFont(XRef *xref, PSOutputDev *ps)
 {
-    GfxFontLoc *fontLoc;
     SysFontType sysFontType;
     GooString *path, *base14Name;
     int substIdx, fontNum;
     bool embed;
 
     if (type == fontType3) {
-        return nullptr;
+        return std::nullopt;
     }
 
     //----- embedded font
@@ -665,36 +668,36 @@ GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev 
*ps)
                 }
             }
             if (embed) {
-                fontLoc = new GfxFontLoc();
-                fontLoc->locType = gfxFontLocEmbedded;
-                fontLoc->fontType = type;
-                fontLoc->embFontID = embFontID;
-                return fontLoc;
+                GfxFontLoc fontLoc;
+                fontLoc.locType = gfxFontLocEmbedded;
+                fontLoc.fontType = type;
+                fontLoc.embFontID = embFontID;
+                return std::move(fontLoc); // std::move only required to 
please g++-7
             }
         }
     }
 
     //----- PS passthrough
     if (ps && !isCIDFont() && ps->getFontPassthrough()) {
-        fontLoc = new GfxFontLoc();
-        fontLoc->locType = gfxFontLocResident;
-        fontLoc->fontType = fontType1;
-        fontLoc->setPath(name->copy());
-        return fontLoc;
+        GfxFontLoc fontLoc;
+        fontLoc.locType = gfxFontLocResident;
+        fontLoc.fontType = fontType1;
+        fontLoc.setPath(name->copy());
+        return std::move(fontLoc); // std::move only required to please g++-7
     }
 
     //----- PS resident Base-14 font
     if (ps && !isCIDFont() && ((Gfx8BitFont *)this)->base14) {
-        fontLoc = new GfxFontLoc();
-        fontLoc->locType = gfxFontLocResident;
-        fontLoc->fontType = fontType1;
-        fontLoc->path = ((Gfx8BitFont *)this)->base14->base14Name;
-        return fontLoc;
+        GfxFontLoc fontLoc;
+        fontLoc.locType = gfxFontLocResident;
+        fontLoc.fontType = fontType1;
+        fontLoc.path = ((Gfx8BitFont *)this)->base14->base14Name;
+        return std::move(fontLoc); // std::move only required to please g++-7
     }
 
     //----- external font file (fontFile, fontDir)
     if (name && (path = globalParams->findFontFile(name))) {
-        if ((fontLoc = getExternalFont(path, isCIDFont()))) {
+        if (std::optional<GfxFontLoc> fontLoc = getExternalFont(path, 
isCIDFont())) {
             return fontLoc;
         }
     }
@@ -703,7 +706,7 @@ GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev *ps)
     if (!ps && !isCIDFont() && ((Gfx8BitFont *)this)->base14) {
         base14Name = new GooString(((Gfx8BitFont *)this)->base14->base14Name);
         if ((path = globalParams->findBase14FontFile(base14Name, this))) {
-            if ((fontLoc = getExternalFont(path, false))) {
+            if (std::optional<GfxFontLoc> fontLoc = getExternalFont(path, 
false)) {
                 delete base14Name;
                 return fontLoc;
             }
@@ -715,27 +718,27 @@ GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev 
*ps)
     if ((path = globalParams->findSystemFontFile(this, &sysFontType, 
&fontNum))) {
         if (isCIDFont()) {
             if (sysFontType == sysFontTTF || sysFontType == sysFontTTC) {
-                fontLoc = new GfxFontLoc();
-                fontLoc->locType = gfxFontLocExternal;
-                fontLoc->fontType = fontCIDType2;
-                fontLoc->setPath(path);
-                fontLoc->fontNum = fontNum;
-                return fontLoc;
+                GfxFontLoc fontLoc;
+                fontLoc.locType = gfxFontLocExternal;
+                fontLoc.fontType = fontCIDType2;
+                fontLoc.setPath(path);
+                fontLoc.fontNum = fontNum;
+                return std::move(fontLoc); // std::move only required to 
please g++-7
             }
         } else {
             if (sysFontType == sysFontTTF || sysFontType == sysFontTTC) {
-                fontLoc = new GfxFontLoc();
-                fontLoc->locType = gfxFontLocExternal;
-                fontLoc->fontType = fontTrueType;
-                fontLoc->setPath(path);
-                return fontLoc;
+                GfxFontLoc fontLoc;
+                fontLoc.locType = gfxFontLocExternal;
+                fontLoc.fontType = fontTrueType;
+                fontLoc.setPath(path);
+                return std::move(fontLoc); // std::move only required to 
please g++-7
             } else if (sysFontType == sysFontPFA || sysFontType == sysFontPFB) 
{
-                fontLoc = new GfxFontLoc();
-                fontLoc->locType = gfxFontLocExternal;
-                fontLoc->fontType = fontType1;
-                fontLoc->setPath(path);
-                fontLoc->fontNum = fontNum;
-                return fontLoc;
+                GfxFontLoc fontLoc;
+                fontLoc.locType = gfxFontLocExternal;
+                fontLoc.fontType = fontType1;
+                fontLoc.setPath(path);
+                fontLoc.fontNum = fontNum;
+                return std::move(fontLoc); // std::move only required to 
please g++-7
             }
         }
         delete path;
@@ -760,16 +763,16 @@ GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev 
*ps)
         GooString substName(base14SubstFonts[substIdx]);
         if (ps) {
             error(errSyntaxWarning, -1, "Substituting font '{0:s}' for 
'{1:s}'", base14SubstFonts[substIdx], name ? name->c_str() : "null");
-            fontLoc = new GfxFontLoc();
-            fontLoc->locType = gfxFontLocResident;
-            fontLoc->fontType = fontType1;
-            fontLoc->path = substName.toStr();
-            fontLoc->substIdx = substIdx;
-            return fontLoc;
+            GfxFontLoc fontLoc;
+            fontLoc.locType = gfxFontLocResident;
+            fontLoc.fontType = fontType1;
+            fontLoc.path = substName.toStr();
+            fontLoc.substIdx = substIdx;
+            return std::move(fontLoc); // std::move only required to please 
g++-7
         } else {
             path = globalParams->findFontFile(&substName);
             if (path) {
-                if ((fontLoc = getExternalFont(path, false))) {
+                if (std::optional<GfxFontLoc> fontLoc = getExternalFont(path, 
false)) {
                     error(errSyntaxWarning, -1, "Substituting font '{0:s}' for 
'{1:s}'", base14SubstFonts[substIdx], name ? name->c_str() : "");
                     name = new GooString(base14SubstFonts[substIdx]);
                     fontLoc->substIdx = substIdx;
@@ -779,29 +782,28 @@ GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev 
*ps)
         }
 
         // failed to find a substitute font
-        return nullptr;
+        return std::nullopt;
     }
 
     // failed to find a substitute font
-    return nullptr;
+    return std::nullopt;
 }
 
-GfxFontLoc *GfxFont::locateBase14Font(const GooString *base14Name)
+std::optional<GfxFontLoc> GfxFont::locateBase14Font(const GooString 
*base14Name)
 {
     GooString *path;
 
     path = globalParams->findFontFile(base14Name);
     if (!path) {
-        return nullptr;
+        return std::nullopt;
     }
     return getExternalFont(path, false);
 }
 
-GfxFontLoc *GfxFont::getExternalFont(GooString *path, bool cid)
+std::optional<GfxFontLoc> GfxFont::getExternalFont(GooString *path, bool cid)
 {
     FoFiIdentifierType fft;
     GfxFontType fontType;
-    GfxFontLoc *fontLoc;
 
     fft = FoFiIdentifier::identifyFile(path->c_str());
     switch (fft) {
@@ -833,13 +835,13 @@ GfxFontLoc *GfxFont::getExternalFont(GooString *path, 
bool cid)
     }
     if (fontType == fontUnknownType || (cid ? (fontType < fontCIDType0) : 
(fontType >= fontCIDType0))) {
         delete path;
-        return nullptr;
+        return std::nullopt;
     }
-    fontLoc = new GfxFontLoc();
-    fontLoc->locType = gfxFontLocExternal;
-    fontLoc->fontType = fontType;
-    fontLoc->setPath(path);
-    return fontLoc;
+    GfxFontLoc fontLoc;
+    fontLoc.locType = gfxFontLocExternal;
+    fontLoc.fontType = fontType;
+    fontLoc.setPath(path);
+    return std::move(fontLoc); // std::move only required to please g++-7
 }
 
 char *GfxFont::readEmbFontFile(XRef *xref, int *len)
diff --git a/poppler/GfxFont.h b/poppler/GfxFont.h
index 0510acb1..e8cb4e3d 100644
--- a/poppler/GfxFont.h
+++ b/poppler/GfxFont.h
@@ -34,6 +34,8 @@
 #ifndef GFXFONT_H
 #define GFXFONT_H
 
+#include <optional>
+
 #include "goo/GooString.h"
 #include "Object.h"
 #include "CharTypes.h"
@@ -119,7 +121,9 @@ public:
     ~GfxFontLoc();
 
     GfxFontLoc(const GfxFontLoc &) = delete;
+    GfxFontLoc(GfxFontLoc &&) noexcept;
     GfxFontLoc &operator=(const GfxFontLoc &) = delete;
+    GfxFontLoc &operator=(GfxFontLoc &&other) noexcept;
 
     // Set the 'path' string from a GooString on the heap.
     // Ownership of the object is taken.
@@ -272,11 +276,11 @@ public:
     virtual int getWMode() { return 0; }
 
     // Locate the font file for this font.  If <ps> is not null, includes PS
-    // printer-resident fonts.  Returns NULL on failure.
-    GfxFontLoc *locateFont(XRef *xref, PSOutputDev *ps);
+    // printer-resident fonts.  Returns std::optional without a value on 
failure.
+    std::optional<GfxFontLoc> locateFont(XRef *xref, PSOutputDev *ps);
 
     // Locate a Base-14 font file for a specified font name.
-    static GfxFontLoc *locateBase14Font(const GooString *base14Name);
+    static std::optional<GfxFontLoc> locateBase14Font(const GooString 
*base14Name);
 
     // Read an external or embedded font file into a buffer.
     char *readEmbFontFile(XRef *xref, int *len);
@@ -308,7 +312,7 @@ protected:
     static GfxFontType getFontType(XRef *xref, Dict *fontDict, Ref *embID);
     void readFontDescriptor(XRef *xref, Dict *fontDict);
     CharCodeToUnicode *readToUnicodeCMap(Dict *fontDict, int nBits, 
CharCodeToUnicode *ctu);
-    static GfxFontLoc *getExternalFont(GooString *path, bool cid);
+    static std::optional<GfxFontLoc> getExternalFont(GooString *path, bool 
cid);
 
     const std::string tag; // PDF font tag
     const Ref id; // reference (used as unique ID)
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index 743a223e..d014f471 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -35,7 +35,7 @@
 // Copyright (C) 2018 Adam Reichold <adam.reich...@t-online.de>
 // Copyright (C) 2018 Philipp Knechtges <philipp-...@knechtges.com>
 // Copyright (C) 2019, 2021 Christian Persch <c...@src.gnome.org>
-// Copyright (C) 2019 Oliver Sander <oliver.san...@tu-dresden.de>
+// Copyright (C) 2019, 2021 Oliver Sander <oliver.san...@tu-dresden.de>
 // Copyright (C) 2020, 2021 Philipp Knechtges <philipp-...@knechtges.com>
 // Copyright (C) 2021 Hubert Figuiere <h...@figuiere.net>
 //
@@ -1947,7 +1947,6 @@ void PSOutputDev::setupFonts(Dict *resDict)
 
 void PSOutputDev::setupFont(GfxFont *font, Dict *parentResDict)
 {
-    GfxFontLoc *fontLoc;
     GooString *psName;
     char buf[16];
     bool subst;
@@ -1979,8 +1978,8 @@ void PSOutputDev::setupFont(GfxFont *font, Dict 
*parentResDict)
         psName = GooString::format("T3_{0:d}_{1:d}", font->getID()->num, 
font->getID()->gen);
         setupType3Font(font, psName, parentResDict);
     } else {
-        fontLoc = font->locateFont(xref, this);
-        if (fontLoc != nullptr) {
+        std::optional<GfxFontLoc> fontLoc = font->locateFont(xref, this);
+        if (fontLoc) {
             switch (fontLoc->locType) {
             case gfxFontLocEmbedded:
                 switch (fontLoc->fontType) {
@@ -2068,7 +2067,6 @@ void PSOutputDev::setupFont(GfxFont *font, Dict 
*parentResDict)
             } else {
                 error(errSyntaxError, -1, "Couldn't find a font to substitute 
for '{0:s}'", font->getName() ? font->getName()->c_str() : "(unnamed)");
             }
-            delete fontLoc;
             return;
         }
 
@@ -2091,8 +2089,6 @@ void PSOutputDev::setupFont(GfxFont *font, Dict 
*parentResDict)
                 xs = 1;
             }
         }
-
-        delete fontLoc;
     }
 
     // generate PostScript code to set up the font
diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index cbfb209d..4be799ce 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -42,7 +42,7 @@
 // Copyright (C) 2018, 2019 Stefan Brüns <stefan.bru...@rwth-aachen.de>
 // Copyright (C) 2018 Adam Reichold <adam.reich...@t-online.de>
 // Copyright (C) 2019 Christian Persch <c...@src.gnome.org>
-// Copyright (C) 2020 Oliver Sander <oliver.san...@tu-dresden.de>
+// Copyright (C) 2020, 2021 Oliver Sander <oliver.san...@tu-dresden.de>
 //
 // 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
@@ -1824,7 +1824,6 @@ void SplashOutputDev::updateFont(GfxState * /*state*/)
 void SplashOutputDev::doUpdateFont(GfxState *state)
 {
     GfxFont *gfxFont;
-    GfxFontLoc *fontLoc;
     GfxFontType fontType;
     SplashOutFontFileID *id = nullptr;
     SplashFontFile *fontFile;
@@ -1842,7 +1841,6 @@ void SplashOutputDev::doUpdateFont(GfxState *state)
     needFontUpdate = false;
     font = nullptr;
     tmpBuf = nullptr;
-    fontLoc = nullptr;
 
     if (!(gfxFont = state->getFont())) {
         goto err1;
@@ -1861,8 +1859,6 @@ void SplashOutputDev::doUpdateFont(GfxState *state)
     // check the font file cache
 reload:
     delete id;
-    delete fontLoc;
-    fontLoc = nullptr;
     if (fontsrc && !fontsrc->isFile) {
         fontsrc->unref();
         fontsrc = nullptr;
@@ -1874,7 +1870,8 @@ reload:
 
     } else {
 
-        if (!(fontLoc = gfxFont->locateFont((xref) ? xref : doc->getXRef(), 
nullptr))) {
+        std::optional<GfxFontLoc> fontLoc = gfxFont->locateFont((xref) ? xref 
: doc->getXRef(), nullptr);
+        if (!fontLoc) {
             error(errSyntaxError, -1, "Couldn't find a font for '{0:s}'", 
gfxFont->getName() ? gfxFont->getName()->c_str() : "(unnamed)");
             goto err2;
         }
@@ -2076,14 +2073,12 @@ reload:
         font = fontEngine->getFont(fontFile, mat, splash->getMatrix());
     }
 
-    delete fontLoc;
     if (fontsrc && !fontsrc->isFile)
         fontsrc->unref();
     return;
 
 err2:
     delete id;
-    delete fontLoc;
 err1:
     if (fontsrc && !fontsrc->isFile)
         fontsrc->unref();
diff --git a/qt5/src/QPainterOutputDev.cc b/qt5/src/QPainterOutputDev.cc
index ab7ac045..1b3101dc 100644
--- a/qt5/src/QPainterOutputDev.cc
+++ b/qt5/src/QPainterOutputDev.cc
@@ -23,7 +23,7 @@
 // Copyright (C) 2013 Thomas Freitag <thomas.frei...@alfa.de>
 // Copyright (C) 2013 Dominik Haumann <dhaum...@kde.org>
 // Copyright (C) 2013 Mihai Niculescu <q.qu...@gmail.com>
-// Copyright (C) 2017, 2018, 2020 Oliver Sander <oliver.san...@tu-dresden.de>
+// Copyright (C) 2017, 2018, 2020, 2021 Oliver Sander 
<oliver.san...@tu-dresden.de>
 // Copyright (C) 2017 Adrian Johnson <ajohn...@redneon.com>
 // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, 
<i...@kdab.com>. Work sponsored by the LiMux project of the city of Munich
 // Copyright (C) 2018 Adam Reichold <adam.reich...@t-online.de>
@@ -456,7 +456,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
         // New font: load it into the cache
         float fontSize = state->getFontSize();
 
-        std::unique_ptr<GfxFontLoc> fontLoc(gfxFont->locateFont(xref, 
nullptr));
+        std::optional<GfxFontLoc> fontLoc = gfxFont->locateFont(xref, nullptr);
 
         if (fontLoc) {
             // load the font from respective location
@@ -524,7 +524,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
         std::unique_ptr<char[], void (*)(char *)> tmpBuf(nullptr, [](char *b) 
{ free(b); });
         int tmpBufLen = 0;
 
-        std::unique_ptr<GfxFontLoc> fontLoc(gfxFont->locateFont(xref, 
nullptr));
+        std::optional<GfxFontLoc> fontLoc = gfxFont->locateFont(xref, nullptr);
         if (!fontLoc) {
             error(errSyntaxError, -1, "Couldn't find a font for '{0:s}'", 
gfxFont->getName() ? gfxFont->getName()->c_str() : "(unnamed)");
             return;
diff --git a/qt6/src/QPainterOutputDev.cc b/qt6/src/QPainterOutputDev.cc
index ab7ac045..1b3101dc 100644
--- a/qt6/src/QPainterOutputDev.cc
+++ b/qt6/src/QPainterOutputDev.cc
@@ -23,7 +23,7 @@
 // Copyright (C) 2013 Thomas Freitag <thomas.frei...@alfa.de>
 // Copyright (C) 2013 Dominik Haumann <dhaum...@kde.org>
 // Copyright (C) 2013 Mihai Niculescu <q.qu...@gmail.com>
-// Copyright (C) 2017, 2018, 2020 Oliver Sander <oliver.san...@tu-dresden.de>
+// Copyright (C) 2017, 2018, 2020, 2021 Oliver Sander 
<oliver.san...@tu-dresden.de>
 // Copyright (C) 2017 Adrian Johnson <ajohn...@redneon.com>
 // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, 
<i...@kdab.com>. Work sponsored by the LiMux project of the city of Munich
 // Copyright (C) 2018 Adam Reichold <adam.reich...@t-online.de>
@@ -456,7 +456,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
         // New font: load it into the cache
         float fontSize = state->getFontSize();
 
-        std::unique_ptr<GfxFontLoc> fontLoc(gfxFont->locateFont(xref, 
nullptr));
+        std::optional<GfxFontLoc> fontLoc = gfxFont->locateFont(xref, nullptr);
 
         if (fontLoc) {
             // load the font from respective location
@@ -524,7 +524,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
         std::unique_ptr<char[], void (*)(char *)> tmpBuf(nullptr, [](char *b) 
{ free(b); });
         int tmpBufLen = 0;
 
-        std::unique_ptr<GfxFontLoc> fontLoc(gfxFont->locateFont(xref, 
nullptr));
+        std::optional<GfxFontLoc> fontLoc = gfxFont->locateFont(xref, nullptr);
         if (!fontLoc) {
             error(errSyntaxError, -1, "Couldn't find a font for '{0:s}'", 
gfxFont->getName() ? gfxFont->getName()->c_str() : "(unnamed)");
             return;
commit 9451ca15dc63b908786e93f86f84862b11fc45dd
Author: Oliver Sander <oliver.san...@tu-dresden.de>
Date:   Fri Dec 31 11:32:20 2021 +0100

    Store 'path' as std::string in GfxFontLoc
    
    ...instead of as GooString*.  This avoids some heap allocations.
    
    To simplify interaction with the rest of the code, the GfxFontLoc
    class gets two new methods 'setPath' and 'pathAsGooString'.
    These methods are intended to be temporary.  Avoiding them now
    would mean having to change too much calling code.

diff --git a/poppler/CairoFontEngine.cc b/poppler/CairoFontEngine.cc
index e4885443..b9a1ad60 100755
--- a/poppler/CairoFontEngine.cc
+++ b/poppler/CairoFontEngine.cc
@@ -342,7 +342,6 @@ CairoFreeTypeFont::~CairoFreeTypeFont() { }
 
 CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, 
FT_Library lib, bool useCIDs)
 {
-    GooString *fileName;
     const char *fileNameC;
     char *font_data;
     int font_data_len;
@@ -364,7 +363,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont 
*gfxFont, XRef *xref, FT_Li
     codeToGIDLen = 0;
     font_data = nullptr;
     font_data_len = 0;
-    fileName = nullptr;
+    const GooString *fileName = nullptr;
     fileNameC = nullptr;
 
     bool substitute = false;
@@ -385,7 +384,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont 
*gfxFont, XRef *xref, FT_Li
 
         // external font
     } else { // gfxFontLocExternal
-        fileName = fontLoc->path;
+        fileName = fontLoc->pathAsGooString();
         fontType = fontLoc->fontType;
         substitute = true;
     }
diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index 5155a9c9..3abde7a4 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -172,16 +172,21 @@ static int readFromStream(void *data)
 
 GfxFontLoc::GfxFontLoc()
 {
-    path = nullptr;
     fontNum = 0;
     substIdx = -1;
 }
 
-GfxFontLoc::~GfxFontLoc()
+GfxFontLoc::~GfxFontLoc() = default;
+
+void GfxFontLoc::setPath(GooString *pathA)
 {
-    if (path) {
-        delete path;
-    }
+    path = pathA->toStr();
+    delete pathA;
+}
+
+const GooString *GfxFontLoc::pathAsGooString() const
+{
+    return (const GooString *)(&path);
 }
 
 //------------------------------------------------------------------------
@@ -618,7 +623,7 @@ GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev *ps)
 {
     GfxFontLoc *fontLoc;
     SysFontType sysFontType;
-    GooString *path, *base14Name, *substName;
+    GooString *path, *base14Name;
     int substIdx, fontNum;
     bool embed;
 
@@ -674,7 +679,7 @@ GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev *ps)
         fontLoc = new GfxFontLoc();
         fontLoc->locType = gfxFontLocResident;
         fontLoc->fontType = fontType1;
-        fontLoc->path = name->copy();
+        fontLoc->setPath(name->copy());
         return fontLoc;
     }
 
@@ -683,7 +688,7 @@ GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev *ps)
         fontLoc = new GfxFontLoc();
         fontLoc->locType = gfxFontLocResident;
         fontLoc->fontType = fontType1;
-        fontLoc->path = new GooString(((Gfx8BitFont 
*)this)->base14->base14Name);
+        fontLoc->path = ((Gfx8BitFont *)this)->base14->base14Name;
         return fontLoc;
     }
 
@@ -713,7 +718,7 @@ GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev *ps)
                 fontLoc = new GfxFontLoc();
                 fontLoc->locType = gfxFontLocExternal;
                 fontLoc->fontType = fontCIDType2;
-                fontLoc->path = path;
+                fontLoc->setPath(path);
                 fontLoc->fontNum = fontNum;
                 return fontLoc;
             }
@@ -722,13 +727,13 @@ GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev 
*ps)
                 fontLoc = new GfxFontLoc();
                 fontLoc->locType = gfxFontLocExternal;
                 fontLoc->fontType = fontTrueType;
-                fontLoc->path = path;
+                fontLoc->setPath(path);
                 return fontLoc;
             } else if (sysFontType == sysFontPFA || sysFontType == sysFontPFB) 
{
                 fontLoc = new GfxFontLoc();
                 fontLoc->locType = gfxFontLocExternal;
                 fontLoc->fontType = fontType1;
-                fontLoc->path = path;
+                fontLoc->setPath(path);
                 fontLoc->fontNum = fontNum;
                 return fontLoc;
             }
@@ -752,18 +757,17 @@ GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev 
*ps)
         if (isItalic()) {
             substIdx += 1;
         }
-        substName = new GooString(base14SubstFonts[substIdx]);
+        GooString substName(base14SubstFonts[substIdx]);
         if (ps) {
             error(errSyntaxWarning, -1, "Substituting font '{0:s}' for 
'{1:s}'", base14SubstFonts[substIdx], name ? name->c_str() : "null");
             fontLoc = new GfxFontLoc();
             fontLoc->locType = gfxFontLocResident;
             fontLoc->fontType = fontType1;
-            fontLoc->path = substName;
+            fontLoc->path = substName.toStr();
             fontLoc->substIdx = substIdx;
             return fontLoc;
         } else {
-            path = globalParams->findFontFile(substName);
-            delete substName;
+            path = globalParams->findFontFile(&substName);
             if (path) {
                 if ((fontLoc = getExternalFont(path, false))) {
                     error(errSyntaxWarning, -1, "Substituting font '{0:s}' for 
'{1:s}'", base14SubstFonts[substIdx], name ? name->c_str() : "");
@@ -834,7 +838,7 @@ GfxFontLoc *GfxFont::getExternalFont(GooString *path, bool 
cid)
     fontLoc = new GfxFontLoc();
     fontLoc->locType = gfxFontLocExternal;
     fontLoc->fontType = fontType;
-    fontLoc->path = path;
+    fontLoc->setPath(path);
     return fontLoc;
 }
 
diff --git a/poppler/GfxFont.h b/poppler/GfxFont.h
index f9263a59..0510acb1 100644
--- a/poppler/GfxFont.h
+++ b/poppler/GfxFont.h
@@ -121,14 +121,19 @@ public:
     GfxFontLoc(const GfxFontLoc &) = delete;
     GfxFontLoc &operator=(const GfxFontLoc &) = delete;
 
+    // Set the 'path' string from a GooString on the heap.
+    // Ownership of the object is taken.
+    void setPath(GooString *pathA);
+    const GooString *pathAsGooString() const;
+
     GfxFontLocType locType;
     GfxFontType fontType;
     Ref embFontID; // embedded stream obj ID
                    //   (if locType == gfxFontLocEmbedded)
-    GooString *path; // font file path
-                     //   (if locType == gfxFontLocExternal)
-                     // PS font name
-                     //   (if locType == gfxFontLocResident)
+    std::string path; // font file path
+                      //   (if locType == gfxFontLocExternal)
+                      // PS font name
+                      //   (if locType == gfxFontLocResident)
     int fontNum; // for TrueType collections
                  //   (if locType == gfxFontLocExternal)
     int substIdx; // substitute font index
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index 6c58daa3..743a223e 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -2031,25 +2031,25 @@ void PSOutputDev::setupFont(GfxFont *font, Dict 
*parentResDict)
                         //~ this won't work -- the PS font name won't match
                         psName = makePSFontName(font, font->getID());
                     }
-                    setupExternalType1Font(fontLoc->path, psName);
+                    setupExternalType1Font(fontLoc->pathAsGooString(), psName);
                     break;
                 case fontTrueType:
                 case fontTrueTypeOT:
                     psName = makePSFontName(font, font->getID());
-                    setupExternalTrueTypeFont(font, fontLoc->path, psName);
+                    setupExternalTrueTypeFont(font, 
fontLoc->pathAsGooString(), psName);
                     break;
                 case fontCIDType2:
                 case fontCIDType2OT:
                     psName = makePSFontName(font, font->getID());
                     //~ should check to see if font actually uses vertical mode
-                    setupExternalCIDTrueTypeFont(font, fontLoc->path, psName, 
true);
+                    setupExternalCIDTrueTypeFont(font, 
fontLoc->pathAsGooString(), psName, true);
                     break;
                 default:
                     break;
                 }
                 break;
             case gfxFontLocResident:
-                psName = fontLoc->path->copy();
+                psName = new GooString(fontLoc->path);
                 break;
             }
         }
diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index 02c6bd34..cbfb209d 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -1830,7 +1830,6 @@ void SplashOutputDev::doUpdateFont(GfxState *state)
     SplashFontFile *fontFile;
     SplashFontSrc *fontsrc = nullptr;
     FoFiTrueType *ff;
-    GooString *fileName;
     char *tmpBuf;
     int tmpBufLen;
     const double *textMat;
@@ -1842,7 +1841,6 @@ void SplashOutputDev::doUpdateFont(GfxState *state)
 
     needFontUpdate = false;
     font = nullptr;
-    fileName = nullptr;
     tmpBuf = nullptr;
     fontLoc = nullptr;
 
@@ -1882,6 +1880,8 @@ reload:
         }
 
         // embedded font
+        const GooString *fileName = nullptr;
+
         if (fontLoc->locType == gfxFontLocEmbedded) {
             // if there is an embedded font, read it to memory
             tmpBuf = gfxFont->readEmbFontFile((xref) ? xref : doc->getXRef(), 
&tmpBufLen);
@@ -1890,7 +1890,7 @@ reload:
 
             // external font
         } else { // gfxFontLocExternal
-            fileName = fontLoc->path;
+            fileName = fontLoc->pathAsGooString();
             fontType = fontLoc->fontType;
             doAdjustFontMatrix = true;
         }
diff --git a/qt5/src/QPainterOutputDev.cc b/qt5/src/QPainterOutputDev.cc
index f67e65fc..ab7ac045 100644
--- a/qt5/src/QPainterOutputDev.cc
+++ b/qt5/src/QPainterOutputDev.cc
@@ -473,7 +473,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
                 break;
             }
             case gfxFontLocExternal: { // font is in an external font file
-                QString fontFile(fontLoc->path->c_str());
+                QString fontFile(fontLoc->path.c_str());
                 m_rawFont = new QRawFont(fontFile, fontSize, 
m_hintingPreference);
                 m_rawFontCache.insert(std::make_pair(fontID, 
std::unique_ptr<QRawFont>(m_rawFont)));
                 break;
@@ -554,7 +554,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
             FT_Face freeTypeFace;
 
             if (fontLoc->locType != gfxFontLocEmbedded) {
-                if (FT_New_Face(m_ftLibrary, fontLoc->path->c_str(), 
faceIndex, &freeTypeFace)) {
+                if (FT_New_Face(m_ftLibrary, fontLoc->path.c_str(), faceIndex, 
&freeTypeFace)) {
                     error(errSyntaxError, -1, "Couldn't create a FreeType face 
for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->c_str() : "(unnamed)");
                     return;
                 }
@@ -589,7 +589,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
         }
         case fontTrueType:
         case fontTrueTypeOT: {
-            auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::load(fontLoc->path->c_str())) : 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::make(tmpBuf.get(), tmpBufLen));
+            auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::load(fontLoc->path.c_str())) : 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::make(tmpBuf.get(), tmpBufLen));
 
             m_codeToGIDCache[id] = (ff) ? ((Gfx8BitFont 
*)gfxFont)->getCodeToGIDMap(ff.get()) : nullptr;
 
@@ -602,7 +602,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
 
             // check for a CFF font
             if (!m_useCIDs) {
-                auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiType1C>(FoFiType1C::load(fontLoc->path->c_str())) : 
std::unique_ptr<FoFiType1C>(FoFiType1C::make(tmpBuf.get(), tmpBufLen));
+                auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiType1C>(FoFiType1C::load(fontLoc->path.c_str())) : 
std::unique_ptr<FoFiType1C>(FoFiType1C::make(tmpBuf.get(), tmpBufLen));
 
                 cidToGIDMap = (ff) ? ff->getCIDToGIDMap(&nCIDs) : nullptr;
             }
@@ -624,7 +624,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
             int nCIDs = 0;
 
             if (!codeToGID && !m_useCIDs) {
-                auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::load(fontLoc->path->c_str())) : 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::make(tmpBuf.get(), tmpBufLen));
+                auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::load(fontLoc->path.c_str())) : 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::make(tmpBuf.get(), tmpBufLen));
 
                 if (ff && ff->isOpenTypeCFF()) {
                     cidToGIDMap = ff->getCIDToGIDMap(&nCIDs);
@@ -646,7 +646,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
                     memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(), 
codeToGIDLen * sizeof(int));
                 }
             } else {
-                auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::load(fontLoc->path->c_str())) : 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::make(tmpBuf.get(), tmpBufLen));
+                auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::load(fontLoc->path.c_str())) : 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::make(tmpBuf.get(), tmpBufLen));
                 if (!ff) {
                     return;
                 }
diff --git a/qt6/src/QPainterOutputDev.cc b/qt6/src/QPainterOutputDev.cc
index f67e65fc..ab7ac045 100644
--- a/qt6/src/QPainterOutputDev.cc
+++ b/qt6/src/QPainterOutputDev.cc
@@ -473,7 +473,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
                 break;
             }
             case gfxFontLocExternal: { // font is in an external font file
-                QString fontFile(fontLoc->path->c_str());
+                QString fontFile(fontLoc->path.c_str());
                 m_rawFont = new QRawFont(fontFile, fontSize, 
m_hintingPreference);
                 m_rawFontCache.insert(std::make_pair(fontID, 
std::unique_ptr<QRawFont>(m_rawFont)));
                 break;
@@ -554,7 +554,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
             FT_Face freeTypeFace;
 
             if (fontLoc->locType != gfxFontLocEmbedded) {
-                if (FT_New_Face(m_ftLibrary, fontLoc->path->c_str(), 
faceIndex, &freeTypeFace)) {
+                if (FT_New_Face(m_ftLibrary, fontLoc->path.c_str(), faceIndex, 
&freeTypeFace)) {
                     error(errSyntaxError, -1, "Couldn't create a FreeType face 
for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->c_str() : "(unnamed)");
                     return;
                 }
@@ -589,7 +589,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
         }
         case fontTrueType:
         case fontTrueTypeOT: {
-            auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::load(fontLoc->path->c_str())) : 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::make(tmpBuf.get(), tmpBufLen));
+            auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::load(fontLoc->path.c_str())) : 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::make(tmpBuf.get(), tmpBufLen));
 
             m_codeToGIDCache[id] = (ff) ? ((Gfx8BitFont 
*)gfxFont)->getCodeToGIDMap(ff.get()) : nullptr;
 
@@ -602,7 +602,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
 
             // check for a CFF font
             if (!m_useCIDs) {
-                auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiType1C>(FoFiType1C::load(fontLoc->path->c_str())) : 
std::unique_ptr<FoFiType1C>(FoFiType1C::make(tmpBuf.get(), tmpBufLen));
+                auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiType1C>(FoFiType1C::load(fontLoc->path.c_str())) : 
std::unique_ptr<FoFiType1C>(FoFiType1C::make(tmpBuf.get(), tmpBufLen));
 
                 cidToGIDMap = (ff) ? ff->getCIDToGIDMap(&nCIDs) : nullptr;
             }
@@ -624,7 +624,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
             int nCIDs = 0;
 
             if (!codeToGID && !m_useCIDs) {
-                auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::load(fontLoc->path->c_str())) : 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::make(tmpBuf.get(), tmpBufLen));
+                auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::load(fontLoc->path.c_str())) : 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::make(tmpBuf.get(), tmpBufLen));
 
                 if (ff && ff->isOpenTypeCFF()) {
                     cidToGIDMap = ff->getCIDToGIDMap(&nCIDs);
@@ -646,7 +646,7 @@ void QPainterOutputDev::updateFont(GfxState *state)
                     memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(), 
codeToGIDLen * sizeof(int));
                 }
             } else {
-                auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::load(fontLoc->path->c_str())) : 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::make(tmpBuf.get(), tmpBufLen));
+                auto ff = (fontLoc->locType != gfxFontLocEmbedded) ? 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::load(fontLoc->path.c_str())) : 
std::unique_ptr<FoFiTrueType>(FoFiTrueType::make(tmpBuf.get(), tmpBufLen));
                 if (!ff) {
                     return;
                 }
commit f5e53b3c81b7adf41457436dd924fc849b14ddd6
Author: Oliver Sander <oliver.san...@tu-dresden.de>
Date:   Wed Dec 29 13:46:08 2021 +0100

    Remove spurious double include

diff --git a/poppler/CairoFontEngine.cc b/poppler/CairoFontEngine.cc
index 7e118b1d..e4885443 100755
--- a/poppler/CairoFontEngine.cc
+++ b/poppler/CairoFontEngine.cc
@@ -39,7 +39,6 @@
 
 #include <config.h>
 
-#include "config.h"
 #include <cstring>
 #include <forward_list>
 #include "CairoFontEngine.h"
commit 170a36e41921ed11699b230205d6e269f5f62806
Author: Oliver Sander <oliver.san...@tu-dresden.de>
Date:   Fri Dec 31 11:21:43 2021 +0100

    Make a few GooString* arguments const

diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index 140bde80..6c58daa3 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -2295,7 +2295,7 @@ err1:
         strObj.streamClose();
 }
 
-void PSOutputDev::setupExternalType1Font(GooString *fileName, GooString 
*psName)
+void PSOutputDev::setupExternalType1Font(const GooString *fileName, GooString 
*psName)
 {
     static const char hexChar[17] = "0123456789abcdef";
     FILE *fontFile;
@@ -2485,7 +2485,7 @@ void PSOutputDev::setupEmbeddedTrueTypeFont(GfxFont 
*font, Ref *id, GooString *p
     writePS("%%EndResource\n");
 }
 
-void PSOutputDev::setupExternalTrueTypeFont(GfxFont *font, GooString 
*fileName, GooString *psName)
+void PSOutputDev::setupExternalTrueTypeFont(GfxFont *font, const GooString 
*fileName, GooString *psName)
 {
     FoFiTrueType *ffTT;
     int *codeToGID;
@@ -2526,7 +2526,7 @@ void PSOutputDev::updateFontMaxValidGlyph(GfxFont *font, 
int maxValidGlyph)
     }
 }
 
-void PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont *font, GooString 
*fileName, GooString *psName, bool needVerticalMetrics)
+void PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont *font, const GooString 
*fileName, GooString *psName, bool needVerticalMetrics)
 {
     FoFiTrueType *ffTT;
     int *codeToGID;
diff --git a/poppler/PSOutputDev.h b/poppler/PSOutputDev.h
index ac49fe77..76a73ce4 100644
--- a/poppler/PSOutputDev.h
+++ b/poppler/PSOutputDev.h
@@ -369,14 +369,14 @@ private:
     void setupFont(GfxFont *font, Dict *parentResDict);
     void setupEmbeddedType1Font(Ref *id, GooString *psName);
     void updateFontMaxValidGlyph(GfxFont *font, int maxValidGlyph);
-    void setupExternalType1Font(GooString *fileName, GooString *psName);
+    void setupExternalType1Font(const GooString *fileName, GooString *psName);
     void setupEmbeddedType1CFont(GfxFont *font, Ref *id, GooString *psName);
     void setupEmbeddedOpenTypeT1CFont(GfxFont *font, Ref *id, GooString 
*psName);
     void setupEmbeddedTrueTypeFont(GfxFont *font, Ref *id, GooString *psName);
-    void setupExternalTrueTypeFont(GfxFont *font, GooString *fileName, 
GooString *psName);
+    void setupExternalTrueTypeFont(GfxFont *font, const GooString *fileName, 
GooString *psName);
     void setupEmbeddedCIDType0Font(GfxFont *font, Ref *id, GooString *psName);
     void setupEmbeddedCIDTrueTypeFont(GfxFont *font, Ref *id, GooString 
*psName, bool needVerticalMetrics);
-    void setupExternalCIDTrueTypeFont(GfxFont *font, GooString *fileName, 
GooString *psName, bool needVerticalMetrics);
+    void setupExternalCIDTrueTypeFont(GfxFont *font, const GooString 
*fileName, GooString *psName, bool needVerticalMetrics);
     void setupEmbeddedOpenTypeCFFFont(GfxFont *font, Ref *id, GooString 
*psName);
     void setupType3Font(GfxFont *font, GooString *psName, Dict *parentResDict);
     GooString *makePSFontName(GfxFont *font, const Ref *id);
diff --git a/splash/SplashFontFile.cc b/splash/SplashFontFile.cc
index c0efd422..e6e241c2 100644
--- a/splash/SplashFontFile.cc
+++ b/splash/SplashFontFile.cc
@@ -110,7 +110,7 @@ void SplashFontSrc::unref()
         delete this;
 }
 
-void SplashFontSrc::setFile(GooString *file, bool del)
+void SplashFontSrc::setFile(const GooString *file, bool del)
 {
     isFile = true;
     fileName = file->copy();
diff --git a/splash/SplashFontFile.h b/splash/SplashFontFile.h
index 539bd307..2f7b49d2 100644
--- a/splash/SplashFontFile.h
+++ b/splash/SplashFontFile.h
@@ -42,7 +42,7 @@ public:
     SplashFontSrc(const SplashFontSrc &) = delete;
     SplashFontSrc &operator=(const SplashFontSrc &) = delete;
 
-    void setFile(GooString *file, bool del);
+    void setFile(const GooString *file, bool del);
     void setFile(const char *file, bool del);
     void setBuf(char *bufA, int buflenA, bool del);
 

Reply via email to