[poppler] poppler/Gfx.cc poppler/GfxFont.cc poppler/GfxFont.h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Oct 22 16:42:40 UTC 2021


 poppler/Gfx.cc     |    2 +-
 poppler/GfxFont.cc |    4 +---
 poppler/GfxFont.h  |    8 ++++----
 3 files changed, 6 insertions(+), 8 deletions(-)

New commits:
commit 4edef6b3de6e262852fda6423fbbe23a16f09389
Author: Albert Astals Cid <aacid at kde.org>
Date:   Fri Oct 22 17:46:46 2021 +0200

    Move GfxFont::tag to be a std::string
    
    No need for it to be a GooString *

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 38088059..873fb287 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -3613,7 +3613,7 @@ void Gfx::opSetFont(Object args[], int numArgs)
         return;
     }
     if (printCommands) {
-        printf("  font: tag=%s name='%s' %g\n", font->getTag()->c_str(), font->getName() ? font->getName()->c_str() : "???", args[1].getNum());
+        printf("  font: tag=%s name='%s' %g\n", font->getTag().c_str(), font->getName() ? font->getName()->c_str() : "???", args[1].getNum());
         fflush(stdout);
     }
 
diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index 71798880..2596255e 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -220,10 +220,9 @@ GfxFont *GfxFont::makeFont(XRef *xref, const char *tagA, Ref idA, Dict *fontDict
     return font;
 }
 
-GfxFont::GfxFont(const char *tagA, Ref idA, const GooString *nameA, GfxFontType typeA, Ref embFontIDA)
+GfxFont::GfxFont(const char *tagA, Ref idA, const GooString *nameA, GfxFontType typeA, Ref embFontIDA) : tag(tagA)
 {
     ok = false;
-    tag = new GooString(tagA);
     id = idA;
     name = nameA;
     type = typeA;
@@ -238,7 +237,6 @@ GfxFont::GfxFont(const char *tagA, Ref idA, const GooString *nameA, GfxFontType
 
 GfxFont::~GfxFont()
 {
-    delete tag;
     delete family;
     if (name) {
         delete name;
diff --git a/poppler/GfxFont.h b/poppler/GfxFont.h
index 398f4dea..add7f05e 100644
--- a/poppler/GfxFont.h
+++ b/poppler/GfxFont.h
@@ -13,7 +13,7 @@
 // All changes made under the Poppler project to this file are licensed
 // under GPL version 2 or later
 //
-// Copyright (C) 2005, 2008, 2015, 2017-2020 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2005, 2008, 2015, 2017-2021 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2006 Takashi Iwai <tiwai at suse.de>
 // Copyright (C) 2006 Kristian Høgsberg <krh at redhat.com>
 // Copyright (C) 2007 Julien Rebetez <julienr at svn.gnome.org>
@@ -193,13 +193,13 @@ public:
     void decRefCnt();
 
     // Get font tag.
-    const GooString *getTag() const { return tag; }
+    const std::string &getTag() const { return tag; }
 
     // Get font dictionary ID.
     const Ref *getID() const { return &id; }
 
     // Does this font match the tag?
-    bool matches(const char *tagA) const { return !tag->cmp(tagA); }
+    bool matches(const char *tagA) const { return tag == tagA; }
 
     // Get font family name.
     GooString *getFamily() const { return family; }
@@ -309,7 +309,7 @@ protected:
     CharCodeToUnicode *readToUnicodeCMap(Dict *fontDict, int nBits, CharCodeToUnicode *ctu);
     static GfxFontLoc *getExternalFont(GooString *path, bool cid);
 
-    GooString *tag; // PDF font tag
+    const std::string tag; // PDF font tag
     Ref id; // reference (used as unique ID)
     const GooString *name; // font name
     GooString *family; // font family


More information about the poppler mailing list