summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpvt_generateap.cpp
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2018-06-20 20:56:14 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-20 20:56:14 +0000
commitcc4802edc4faee4bafae5219e94a5a22bfbb684b (patch)
tree68ac60938d559e95cc72d4b1af7f77757fbd6d90 /core/fpdfdoc/cpvt_generateap.cpp
parentc62e8489042c5efaa3b666846b38a52da3b91481 (diff)
downloadpdfium-cc4802edc4faee4bafae5219e94a5a22bfbb684b.tar.xz
Fix a couple of CPDF_DefaultAppearance::GetFont usageschromium/3467
Bug: 853238 Change-Id: I133be340fd877e9acd2733845d454924dc86d295 Reviewed-on: https://pdfium-review.googlesource.com/35711 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Diffstat (limited to 'core/fpdfdoc/cpvt_generateap.cpp')
-rw-r--r--core/fpdfdoc/cpvt_generateap.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index a582feb2cb..28598c1959 100644
--- a/core/fpdfdoc/cpvt_generateap.cpp
+++ b/core/fpdfdoc/cpvt_generateap.cpp
@@ -929,10 +929,7 @@ void CPVT_GenerateAP::GenerateFormAP(Type type,
if (!font)
return;
- ByteString sFontName = PDF_NameDecode(font->AsStringView());
- if (sFontName.IsEmpty())
- return;
-
+ ByteString font_name = *font;
CFX_Color crText = CFX_Color::ParseColor(DA);
CPDF_Dictionary* pDRDict = pFormDict->GetDictFor("DR");
if (!pDRDict)
@@ -942,16 +939,14 @@ void CPVT_GenerateAP::GenerateFormAP(Type type,
if (!pDRFontDict)
return;
- CPDF_Dictionary* pFontDict =
- pDRFontDict->GetDictFor(sFontName.Right(sFontName.GetLength() - 1));
+ CPDF_Dictionary* pFontDict = pDRFontDict->GetDictFor(font_name);
if (!pFontDict) {
pFontDict = pDoc->NewIndirect<CPDF_Dictionary>();
pFontDict->SetNewFor<CPDF_Name>("Type", "Font");
pFontDict->SetNewFor<CPDF_Name>("Subtype", "Type1");
pFontDict->SetNewFor<CPDF_Name>("BaseFont", CFX_Font::kDefaultAnsiFontName);
pFontDict->SetNewFor<CPDF_Name>("Encoding", "WinAnsiEncoding");
- pDRFontDict->SetFor(sFontName.Right(sFontName.GetLength() - 1),
- pFontDict->MakeReference(pDoc));
+ pDRFontDict->SetFor(font_name, pFontDict->MakeReference(pDoc));
}
CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict);
if (!pDefFont)
@@ -1071,8 +1066,8 @@ void CPVT_GenerateAP::GenerateFormAP(Type type,
CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictFor("Font");
if (!pStreamResFontList)
pStreamResFontList = pStreamResList->SetNewFor<CPDF_Dictionary>("Font");
- if (!pStreamResFontList->KeyExist(sFontName)) {
- pStreamResFontList->SetFor(sFontName, pFontDict->MakeReference(pDoc));
+ if (!pStreamResFontList->KeyExist(font_name)) {
+ pStreamResFontList->SetFor(font_name, pFontDict->MakeReference(pDoc));
}
} else {
pStreamDict->SetFor("Resources", pFormDict->GetDictFor("DR")->Clone());
@@ -1097,7 +1092,7 @@ void CPVT_GenerateAP::GenerateFormAP(Type type,
: 0;
CPVT_FontMap map(
pDoc, pStreamDict ? pStreamDict->GetDictFor("Resources") : nullptr,
- pDefFont, sFontName.Right(sFontName.GetLength() - 1));
+ pDefFont, font_name);
CPDF_VariableText::Provider prd(&map);
CPDF_VariableText vt;
vt.SetProvider(&prd);
@@ -1158,7 +1153,7 @@ void CPVT_GenerateAP::GenerateFormAP(Type type,
: WideString();
CPVT_FontMap map(
pDoc, pStreamDict ? pStreamDict->GetDictFor("Resources") : nullptr,
- pDefFont, sFontName.Right(sFontName.GetLength() - 1));
+ pDefFont, font_name);
CPDF_VariableText::Provider prd(&map);
CPDF_VariableText vt;
vt.SetProvider(&prd);
@@ -1226,7 +1221,7 @@ void CPVT_GenerateAP::GenerateFormAP(Type type,
case CPVT_GenerateAP::kListBox: {
CPVT_FontMap map(
pDoc, pStreamDict ? pStreamDict->GetDictFor("Resources") : nullptr,
- pDefFont, sFontName.Right(sFontName.GetLength() - 1));
+ pDefFont, font_name);
CPDF_VariableText::Provider prd(&map);
CPDF_Array* pOpts = ToArray(FPDF_GetFieldAttr(pAnnotDict, "Opt"));
CPDF_Array* pSels = ToArray(FPDF_GetFieldAttr(pAnnotDict, "I"));
@@ -1318,8 +1313,8 @@ void CPVT_GenerateAP::GenerateFormAP(Type type,
pStreamResFontList =
pStreamResList->SetNewFor<CPDF_Dictionary>("Font");
}
- if (!pStreamResFontList->KeyExist(sFontName)) {
- pStreamResFontList->SetFor(sFontName, pFontDict->MakeReference(pDoc));
+ if (!pStreamResFontList->KeyExist(font_name)) {
+ pStreamResFontList->SetFor(font_name, pFontDict->MakeReference(pDoc));
}
} else {
pStreamDict->SetFor("Resources", pFormDict->GetDictFor("DR")->Clone());