diff options
author | Oliver Sander <oliver.sander@tu-dresden.de> | 2022-03-14 10:56:27 +0100 |
---|---|---|
committer | Albert Astals Cid <tsdgeos@yahoo.es> | 2022-03-18 16:29:26 +0000 |
commit | a6b2442e37cc00534bcdca7c83366a0fa0501157 (patch) | |
tree | fd1f4c9b2a4de9bcb459895bd6d5db53cc62c76a /poppler/SplashOutputDev.cc | |
parent | d3b0fd9a76e1f6ace83b50f8c1bc9db096a8fbc7 (diff) |
Store font data in a std::vector<unsigned char>
This simplifies various method signatures, because the data array and
its size do not have to be passed around separately, anymore.
Also, using a std::vector makes tracking the ownership much easier.
Diffstat (limited to 'poppler/SplashOutputDev.cc')
-rw-r--r-- | poppler/SplashOutputDev.cc | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc index 8f362b55..8ff7b9a4 100644 --- a/poppler/SplashOutputDev.cc +++ b/poppler/SplashOutputDev.cc @@ -1845,8 +1845,6 @@ void SplashOutputDev::doUpdateFont(GfxState *state) SplashOutFontFileID *id = nullptr; SplashFontFile *fontFile; SplashFontSrc *fontsrc = nullptr; - unsigned char *tmpBuf; - int tmpBufLen; const double *textMat; double m11, m12, m21, m22, fontSize; int faceIndex = 0; @@ -1856,7 +1854,6 @@ void SplashOutputDev::doUpdateFont(GfxState *state) needFontUpdate = false; font = nullptr; - tmpBuf = nullptr; GfxFont *const gfxFont = state->getFont().get(); if (!gfxFont) { @@ -1895,11 +1892,12 @@ reload: // embedded font std::string fileName; + std::vector<unsigned char> tmpBuf; if (fontLoc->locType == gfxFontLocEmbedded) { // if there is an embedded font, read it to memory - tmpBuf = gfxFont->readEmbFontFile((xref) ? xref : doc->getXRef(), &tmpBufLen); - if (!tmpBuf) { + tmpBuf = gfxFont->readEmbFontFile((xref) ? xref : doc->getXRef()); + if (tmpBuf.empty()) { goto err2; } @@ -1914,7 +1912,7 @@ reload: if (!fileName.empty()) { fontsrc->setFile(fileName); } else { - fontsrc->setBuf(tmpBuf, tmpBufLen); + fontsrc->setBuf(std::move(tmpBuf)); } // load the font file @@ -1952,7 +1950,7 @@ reload: if (!fileName.empty()) { ff = FoFiTrueType::load(fileName.c_str()); } else { - ff = FoFiTrueType::make(tmpBuf, tmpBufLen); + ff = FoFiTrueType::make(fontsrc->buf.data(), fontsrc->buf.size()); } int *codeToGID; const int n = ff ? 256 : 0; @@ -2026,7 +2024,7 @@ reload: if (!fileName.empty()) { ff = FoFiTrueType::load(fileName.c_str()); } else { - ff = FoFiTrueType::make(tmpBuf, tmpBufLen); + ff = FoFiTrueType::make(fontsrc->buf.data(), fontsrc->buf.size()); } if (!ff) { error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->c_str() : "(unnamed)"); |