summaryrefslogtreecommitdiff
path: root/core/fpdfapi/font
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/font')
-rw-r--r--core/fpdfapi/font/cpdf_fontencoding.cpp23
-rw-r--r--core/fpdfapi/font/cpdf_fontencoding.h4
2 files changed, 14 insertions, 13 deletions
diff --git a/core/fpdfapi/font/cpdf_fontencoding.cpp b/core/fpdfapi/font/cpdf_fontencoding.cpp
index df21267e1d..88b2c8d6a5 100644
--- a/core/fpdfapi/font/cpdf_fontencoding.cpp
+++ b/core/fpdfapi/font/cpdf_fontencoding.cpp
@@ -1672,7 +1672,8 @@ bool CPDF_FontEncoding::IsIdentical(CPDF_FontEncoding* pAnother) const {
0;
}
-CPDF_Object* CPDF_FontEncoding::Realize(CFX_WeakPtr<CFX_ByteStringPool> pPool) {
+std::unique_ptr<CPDF_Object> CPDF_FontEncoding::Realize(
+ CFX_WeakPtr<CFX_ByteStringPool> pPool) {
int predefined = 0;
for (int cs = PDFFONT_ENCODING_WINANSI; cs < PDFFONT_ENCODING_ZAPFDINGBATS;
cs++) {
@@ -1690,15 +1691,13 @@ CPDF_Object* CPDF_FontEncoding::Realize(CFX_WeakPtr<CFX_ByteStringPool> pPool) {
}
}
if (predefined) {
- if (predefined == PDFFONT_ENCODING_WINANSI) {
- return new CPDF_Name(pPool, "WinAnsiEncoding");
- }
- if (predefined == PDFFONT_ENCODING_MACROMAN) {
- return new CPDF_Name(pPool, "MacRomanEncoding");
- }
- if (predefined == PDFFONT_ENCODING_MACEXPERT) {
- return new CPDF_Name(pPool, "MacExpertEncoding");
- }
+ if (predefined == PDFFONT_ENCODING_WINANSI)
+ return pdfium::MakeUnique<CPDF_Name>(pPool, "WinAnsiEncoding");
+ if (predefined == PDFFONT_ENCODING_MACROMAN)
+ return pdfium::MakeUnique<CPDF_Name>(pPool, "MacRomanEncoding");
+ if (predefined == PDFFONT_ENCODING_MACEXPERT)
+ return pdfium::MakeUnique<CPDF_Name>(pPool, "MacExpertEncoding");
+
return nullptr;
}
const uint16_t* pStandard =
@@ -1712,10 +1711,10 @@ CPDF_Object* CPDF_FontEncoding::Realize(CFX_WeakPtr<CFX_ByteStringPool> pPool) {
pDiff->AddNew<CPDF_Name>(PDF_AdobeNameFromUnicode(m_Unicodes[i]));
}
- CPDF_Dictionary* pDict = new CPDF_Dictionary(pPool);
+ auto pDict = pdfium::MakeUnique<CPDF_Dictionary>(pPool);
pDict->SetNewFor<CPDF_Name>("BaseEncoding", "WinAnsiEncoding");
pDict->SetFor("Differences", std::move(pDiff));
- return pDict;
+ return std::move(pDict);
}
uint32_t FT_CharCodeFromUnicode(int encoding, FX_WCHAR unicode) {
diff --git a/core/fpdfapi/font/cpdf_fontencoding.h b/core/fpdfapi/font/cpdf_fontencoding.h
index a497681e5e..6c0de909e1 100644
--- a/core/fpdfapi/font/cpdf_fontencoding.h
+++ b/core/fpdfapi/font/cpdf_fontencoding.h
@@ -7,6 +7,8 @@
#ifndef CORE_FPDFAPI_FONT_CPDF_FONTENCODING_H_
#define CORE_FPDFAPI_FONT_CPDF_FONTENCODING_H_
+#include <memory>
+
#include "core/fxcrt/cfx_string_pool_template.h"
#include "core/fxcrt/cfx_weak_ptr.h"
#include "core/fxcrt/fx_string.h"
@@ -52,7 +54,7 @@ class CPDF_FontEncoding {
m_Unicodes[charcode] = unicode;
}
- CPDF_Object* Realize(CFX_WeakPtr<CFX_ByteStringPool> pPool);
+ std::unique_ptr<CPDF_Object> Realize(CFX_WeakPtr<CFX_ByteStringPool> pPool);
public:
FX_WCHAR m_Unicodes[256];