[poppler] poppler/CairoFontEngine.cc
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Mar 31 13:27:06 UTC 2022
poppler/CairoFontEngine.cc | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
New commits:
commit 8942ba12781560e59e3a2f1a2185c34a697f5fee
Author: Albert Astals Cid <aacid at kde.org>
Date: Thu Mar 31 15:23:38 2022 +0200
Fix regression caused by d72c22caf28cbe8cf1e268f8ff741d7e1330df63
diff --git a/poppler/CairoFontEngine.cc b/poppler/CairoFontEngine.cc
index 0f80a205..759c61b0 100644
--- a/poppler/CairoFontEngine.cc
+++ b/poppler/CairoFontEngine.cc
@@ -281,7 +281,7 @@ CairoFreeTypeFont::~CairoFreeTypeFont() { }
CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Library lib, bool useCIDs)
{
const char *fileNameC;
- std::optional<std::vector<unsigned char>> font_data;
+ std::vector<unsigned char> font_data;
int i, n;
GfxFontType fontType;
std::optional<GfxFontLoc> fontLoc;
@@ -314,10 +314,11 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li
// embedded font
if (fontLoc->locType == gfxFontLocEmbedded) {
- font_data = gfxFont->readEmbFontFile(xref);
- if (!font_data) {
+ auto fd = gfxFont->readEmbFontFile(xref);
+ if (!fd || fd->empty()) {
goto err2;
}
+ font_data = std::move(fd.value());
// external font
} else { // gfxFontLocExternal
@@ -334,7 +335,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li
case fontType1:
case fontType1C:
case fontType1COT:
- if (!_ft_new_face(lib, fileNameC, embFontID, std::move(font_data.value()), &face, &font_face)) {
+ if (!_ft_new_face(lib, fileNameC, embFontID, std::move(font_data), &face, &font_face)) {
error(errSyntaxError, -1, "could not create type1 face");
goto err2;
}
@@ -373,8 +374,8 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li
}
} else {
std::unique_ptr<FoFiTrueType> ff;
- if (font_data) {
- ff = FoFiTrueType::make(font_data->data(), font_data->size());
+ if (!font_data.empty()) {
+ ff = FoFiTrueType::make(font_data.data(), font_data.size());
} else {
ff = FoFiTrueType::load(fileNameC);
}
@@ -388,8 +389,8 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li
case fontTrueType:
case fontTrueTypeOT: {
std::unique_ptr<FoFiTrueType> ff;
- if (font_data) {
- ff = FoFiTrueType::make(font_data->data(), font_data->size());
+ if (!font_data.empty()) {
+ ff = FoFiTrueType::make(font_data.data(), font_data.size());
} else {
ff = FoFiTrueType::load(fileNameC);
}
@@ -402,7 +403,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li
codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff.get());
codeToGIDLen = 256;
}
- if (!_ft_new_face(lib, fileNameC, embFontID, std::move(font_data.value()), &face, &font_face)) {
+ if (!_ft_new_face(lib, fileNameC, embFontID, std::move(font_data), &face, &font_face)) {
error(errSyntaxError, -1, "could not create truetype face\n");
goto err2;
}
@@ -415,8 +416,8 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li
codeToGIDLen = 0;
if (!useCIDs) {
- if (font_data) {
- ff1c = FoFiType1C::make(font_data->data(), font_data->size());
+ if (!font_data.empty()) {
+ ff1c = FoFiType1C::make(font_data.data(), font_data.size());
} else {
ff1c = FoFiType1C::load(fileNameC);
}
@@ -426,7 +427,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li
}
}
- if (!_ft_new_face(lib, fileNameC, embFontID, std::move(font_data.value()), &face, &font_face)) {
+ if (!_ft_new_face(lib, fileNameC, embFontID, std::move(font_data), &face, &font_face)) {
error(errSyntaxError, -1, "could not create cid face\n");
goto err2;
}
@@ -447,8 +448,8 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li
if (!codeToGID) {
if (!useCIDs) {
std::unique_ptr<FoFiTrueType> ff;
- if (font_data) {
- ff = FoFiTrueType::make(font_data->data(), font_data->size());
+ if (!font_data.empty()) {
+ ff = FoFiTrueType::make(font_data.data(), font_data.size());
} else {
ff = FoFiTrueType::load(fileNameC);
}
@@ -459,7 +460,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li
}
}
}
- if (!_ft_new_face(lib, fileNameC, embFontID, std::move(font_data.value()), &face, &font_face)) {
+ if (!_ft_new_face(lib, fileNameC, embFontID, std::move(font_data), &face, &font_face)) {
error(errSyntaxError, -1, "could not create cid (OT) face\n");
goto err2;
}
More information about the poppler
mailing list