[poppler] 3 commits - poppler/SplashOutputDev.cc splash/SplashFontFile.cc splash/SplashFontFile.h splash/SplashFTFontFile.cc
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Mar 15 14:54:27 UTC 2022
poppler/SplashOutputDev.cc | 18 +++++++++---------
splash/SplashFTFontFile.cc | 6 +++---
splash/SplashFontFile.cc | 33 +++++++--------------------------
splash/SplashFontFile.h | 12 ++++++------
4 files changed, 25 insertions(+), 44 deletions(-)
New commits:
commit efe7d77838896ddcefb838f382628ae31be54d99
Author: Oliver Sander <oliver.sander at tu-dresden.de>
Date: Tue Mar 15 11:03:58 2022 +0100
Use std::string for filename in SplashFontSrc
diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index 9045032a..23284f6b 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -1894,7 +1894,7 @@ reload:
}
// embedded font
- const GooString *fileName = nullptr;
+ std::string fileName;
if (fontLoc->locType == gfxFontLocEmbedded) {
// if there is an embedded font, read it to memory
@@ -1905,13 +1905,13 @@ reload:
// external font
} else { // gfxFontLocExternal
- fileName = fontLoc->pathAsGooString();
+ fileName = fontLoc->path;
fontType = fontLoc->fontType;
doAdjustFontMatrix = true;
}
fontsrc = new SplashFontSrc;
- if (fileName) {
+ if (!fileName.empty()) {
fontsrc->setFile(fileName);
} else {
fontsrc->setBuf(tmpBuf, tmpBufLen);
@@ -1949,8 +1949,8 @@ reload:
case fontTrueType:
case fontTrueTypeOT: {
std::unique_ptr<FoFiTrueType> ff;
- if (fileName) {
- ff = FoFiTrueType::load(fileName->c_str());
+ if (!fileName.empty()) {
+ ff = FoFiTrueType::load(fileName.c_str());
} else {
ff = FoFiTrueType::make(tmpBuf, tmpBufLen);
}
@@ -2023,8 +2023,8 @@ reload:
}
} else {
std::unique_ptr<FoFiTrueType> ff;
- if (fileName) {
- ff = FoFiTrueType::load(fileName->c_str());
+ if (!fileName.empty()) {
+ ff = FoFiTrueType::load(fileName.c_str());
} else {
ff = FoFiTrueType::make(tmpBuf, tmpBufLen);
}
diff --git a/splash/SplashFTFontFile.cc b/splash/SplashFTFontFile.cc
index 5b8ef14f..bb2c098c 100644
--- a/splash/SplashFTFontFile.cc
+++ b/splash/SplashFTFontFile.cc
@@ -42,7 +42,7 @@ SplashFontFile *SplashFTFontFile::loadType1Font(SplashFTFontEngine *engineA, Spl
int i;
if (src->isFile) {
- if (FT_New_Face(engineA->lib, src->fileName->c_str(), 0, &faceA)) {
+ if (FT_New_Face(engineA->lib, src->fileName.c_str(), 0, &faceA)) {
return nullptr;
}
} else {
@@ -72,7 +72,7 @@ SplashFontFile *SplashFTFontFile::loadCIDFont(SplashFTFontEngine *engineA, Splas
FT_Face faceA;
if (src->isFile) {
- if (FT_New_Face(engineA->lib, src->fileName->c_str(), 0, &faceA)) {
+ if (FT_New_Face(engineA->lib, src->fileName.c_str(), 0, &faceA)) {
return nullptr;
}
} else {
@@ -89,7 +89,7 @@ SplashFontFile *SplashFTFontFile::loadTrueTypeFont(SplashFTFontEngine *engineA,
FT_Face faceA;
if (src->isFile) {
- if (FT_New_Face(engineA->lib, src->fileName->c_str(), faceIndexA, &faceA)) {
+ if (FT_New_Face(engineA->lib, src->fileName.c_str(), faceIndexA, &faceA)) {
return nullptr;
}
} else {
diff --git a/splash/SplashFontFile.cc b/splash/SplashFontFile.cc
index 44de3340..ec101da5 100644
--- a/splash/SplashFontFile.cc
+++ b/splash/SplashFontFile.cc
@@ -80,10 +80,6 @@ SplashFontSrc::~SplashFontSrc()
gfree(buf);
}
}
-
- if (isFile && fileName) {
- delete fileName;
- }
}
void SplashFontSrc::ref()
@@ -98,10 +94,10 @@ void SplashFontSrc::unref()
}
}
-void SplashFontSrc::setFile(const GooString *file)
+void SplashFontSrc::setFile(const std::string &file)
{
isFile = true;
- fileName = file->copy();
+ fileName = file;
}
void SplashFontSrc::setBuf(char *bufA, int bufLenA)
diff --git a/splash/SplashFontFile.h b/splash/SplashFontFile.h
index d547d626..1e1e4fe1 100644
--- a/splash/SplashFontFile.h
+++ b/splash/SplashFontFile.h
@@ -23,10 +23,11 @@
#ifndef SPLASHFONTFILE_H
#define SPLASHFONTFILE_H
+#include <string>
+
#include "SplashTypes.h"
#include "poppler_private_export.h"
-class GooString;
class SplashFontEngine;
class SplashFont;
class SplashFontFileID;
@@ -43,14 +44,14 @@ public:
SplashFontSrc(const SplashFontSrc &) = delete;
SplashFontSrc &operator=(const SplashFontSrc &) = delete;
- void setFile(const GooString *file);
+ void setFile(const std::string &file);
void setBuf(char *bufA, int buflenA);
void ref();
void unref();
bool isFile;
- GooString *fileName;
+ std::string fileName;
char *buf;
int bufLen;
commit 27a6d29018817a2263d69aadeb965dee3f5bc927
Author: Oliver Sander <oliver.sander at tu-dresden.de>
Date: Tue Mar 15 10:51:46 2022 +0100
Remove the deleteSrc variable from SplashFontSrc
The way SplashFontSrc is used the variable is always equal
to !isFile.
diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index ed6bd4cb..9045032a 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -1912,9 +1912,9 @@ reload:
fontsrc = new SplashFontSrc;
if (fileName) {
- fontsrc->setFile(fileName, false);
+ fontsrc->setFile(fileName);
} else {
- fontsrc->setBuf(tmpBuf, tmpBufLen, true);
+ fontsrc->setBuf(tmpBuf, tmpBufLen);
}
// load the font file
diff --git a/splash/SplashFontFile.cc b/splash/SplashFontFile.cc
index c5b3135c..44de3340 100644
--- a/splash/SplashFontFile.cc
+++ b/splash/SplashFontFile.cc
@@ -14,6 +14,7 @@
// Copyright (C) 2006 Takashi Iwai <tiwai at suse.de>
// Copyright (C) 2008 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2019 Christian Persch <chpe at src.gnome.org>
+// Copyright (C) 2022 Oliver Sander <oliver.sander at 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
@@ -67,7 +68,6 @@ void SplashFontFile::decRefCnt()
SplashFontSrc::SplashFontSrc()
{
isFile = false;
- deleteSrc = false;
fileName = nullptr;
buf = nullptr;
refcnt = 1;
@@ -75,15 +75,9 @@ SplashFontSrc::SplashFontSrc()
SplashFontSrc::~SplashFontSrc()
{
- if (deleteSrc) {
- if (isFile) {
- if (fileName) {
- unlink(fileName->c_str());
- }
- } else {
- if (buf) {
- gfree(buf);
- }
+ if (!isFile) {
+ if (buf) {
+ gfree(buf);
}
}
@@ -104,17 +98,15 @@ void SplashFontSrc::unref()
}
}
-void SplashFontSrc::setFile(const GooString *file, bool del)
+void SplashFontSrc::setFile(const GooString *file)
{
isFile = true;
fileName = file->copy();
- deleteSrc = del;
}
-void SplashFontSrc::setBuf(char *bufA, int bufLenA, bool del)
+void SplashFontSrc::setBuf(char *bufA, int bufLenA)
{
isFile = false;
buf = bufA;
bufLen = bufLenA;
- deleteSrc = del;
}
diff --git a/splash/SplashFontFile.h b/splash/SplashFontFile.h
index 16c93626..d547d626 100644
--- a/splash/SplashFontFile.h
+++ b/splash/SplashFontFile.h
@@ -13,6 +13,7 @@
//
// Copyright (C) 2006 Takashi Iwai <tiwai at suse.de>
// Copyright (C) 2008, 2010, 2018 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2022 Oliver Sander <oliver.sander at 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
@@ -42,8 +43,8 @@ public:
SplashFontSrc(const SplashFontSrc &) = delete;
SplashFontSrc &operator=(const SplashFontSrc &) = delete;
- void setFile(const GooString *file, bool del);
- void setBuf(char *bufA, int buflenA, bool del);
+ void setFile(const GooString *file);
+ void setBuf(char *bufA, int buflenA);
void ref();
void unref();
@@ -56,7 +57,6 @@ public:
private:
~SplashFontSrc();
int refcnt;
- bool deleteSrc;
};
class SplashFontFile
commit d6f3aabff3442d3a78de13917e8222d7896e526a
Author: Oliver Sander <oliver.sander at tu-dresden.de>
Date: Tue Mar 15 10:47:01 2022 +0100
Remove method SplashFontSrc::setFile(const char *file, bool del)
It is never used.
diff --git a/splash/SplashFontFile.cc b/splash/SplashFontFile.cc
index 36172266..c5b3135c 100644
--- a/splash/SplashFontFile.cc
+++ b/splash/SplashFontFile.cc
@@ -111,13 +111,6 @@ void SplashFontSrc::setFile(const GooString *file, bool del)
deleteSrc = del;
}
-void SplashFontSrc::setFile(const char *file, bool del)
-{
- isFile = true;
- fileName = new GooString(file);
- deleteSrc = del;
-}
-
void SplashFontSrc::setBuf(char *bufA, int bufLenA, bool del)
{
isFile = false;
diff --git a/splash/SplashFontFile.h b/splash/SplashFontFile.h
index 2f7b49d2..16c93626 100644
--- a/splash/SplashFontFile.h
+++ b/splash/SplashFontFile.h
@@ -43,7 +43,6 @@ public:
SplashFontSrc &operator=(const SplashFontSrc &) = delete;
void setFile(const GooString *file, bool del);
- void setFile(const char *file, bool del);
void setBuf(char *bufA, int buflenA, bool del);
void ref();
More information about the poppler
mailing list