summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Sander <oliver.sander@tu-dresden.de>2021-12-30 10:46:46 +0100
committerAlbert Astals Cid <tsdgeos@yahoo.es>2022-01-05 13:45:07 +0000
commit953c9c762f346236d856327833f3a550b993138a (patch)
tree0df8302ad04fb195c60837ddc068d301eeeffd67
parent9389df54ca8f9c182153aa13eb1109ea98fb307c (diff)
Let FoFiTrueType::make and ...::load return std::unique_ptr
Because these methods do release the object ownership.
-rw-r--r--fofi/FoFiTrueType.cc18
-rw-r--r--fofi/FoFiTrueType.h5
-rw-r--r--poppler/CairoFontEngine.cc15
-rw-r--r--poppler/PSOutputDev.cc30
-rw-r--r--poppler/SplashOutputDev.cc9
-rw-r--r--qt5/src/QPainterOutputDev.cc6
-rw-r--r--qt6/src/QPainterOutputDev.cc6
-rw-r--r--splash/SplashFTFontEngine.cc3
8 files changed, 38 insertions, 54 deletions
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;
}
}
}