summaryrefslogtreecommitdiff
path: root/core/fpdfapi/font
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/font')
-rw-r--r--core/fpdfapi/font/cpdf_cidfont.cpp2
-rw-r--r--core/fpdfapi/font/cpdf_cidfont.h4
-rw-r--r--core/fpdfapi/font/font_int.h21
-rw-r--r--core/fpdfapi/font/fpdf_font_cid.cpp18
4 files changed, 23 insertions, 22 deletions
diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp
index 217a6eaf2e..5aad5194cd 100644
--- a/core/fpdfapi/font/cpdf_cidfont.cpp
+++ b/core/fpdfapi/font/cpdf_cidfont.cpp
@@ -365,9 +365,9 @@ bool CPDF_CIDFont::Load() {
if (!m_pCMap)
return false;
} else if (CPDF_Stream* pStream = pEncoding->AsStream()) {
- m_pCMap = pdfium::MakeUnique<CPDF_CMap>();
CPDF_StreamAcc acc;
acc.LoadAllData(pStream, false);
+ m_pCMap = pdfium::MakeRetain<CPDF_CMap>();
m_pCMap->LoadEmbedded(acc.GetData(), acc.GetSize());
} else {
return false;
diff --git a/core/fpdfapi/font/cpdf_cidfont.h b/core/fpdfapi/font/cpdf_cidfont.h
index ec7da6a9bf..938b537b1b 100644
--- a/core/fpdfapi/font/cpdf_cidfont.h
+++ b/core/fpdfapi/font/cpdf_cidfont.h
@@ -11,7 +11,7 @@
#include <vector>
#include "core/fpdfapi/font/cpdf_font.h"
-#include "core/fxcrt/cfx_maybe_owned.h"
+#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/fx_system.h"
@@ -72,7 +72,7 @@ class CPDF_CIDFont : public CPDF_Font {
void LoadSubstFont();
wchar_t GetUnicodeFromCharCode(uint32_t charcode) const;
- CFX_MaybeOwned<CPDF_CMap> m_pCMap;
+ CFX_RetainPtr<CPDF_CMap> m_pCMap;
CPDF_CID2UnicodeMap* m_pCID2UnicodeMap;
CIDSet m_Charset;
bool m_bType1;
diff --git a/core/fpdfapi/font/font_int.h b/core/fpdfapi/font/font_int.h
index 23513d4e90..926ea91a9e 100644
--- a/core/fpdfapi/font/font_int.h
+++ b/core/fpdfapi/font/font_int.h
@@ -12,7 +12,7 @@
#include <vector>
#include "core/fpdfapi/font/cpdf_cidfont.h"
-#include "core/fxcrt/cfx_maybe_owned.h"
+#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/fx_basic.h"
class CPDF_CID2UnicodeMap;
@@ -31,17 +31,17 @@ class CPDF_CMapManager {
CPDF_CMapManager();
~CPDF_CMapManager();
- CFX_MaybeOwned<CPDF_CMap> GetPredefinedCMap(const CFX_ByteString& name,
- bool bPromptCJK);
+ CFX_RetainPtr<CPDF_CMap> GetPredefinedCMap(const CFX_ByteString& name,
+ bool bPromptCJK);
CPDF_CID2UnicodeMap* GetCID2UnicodeMap(CIDSet charset, bool bPromptCJK);
private:
- std::unique_ptr<CPDF_CMap> LoadPredefinedCMap(const CFX_ByteString& name,
- bool bPromptCJK);
+ CFX_RetainPtr<CPDF_CMap> LoadPredefinedCMap(const CFX_ByteString& name,
+ bool bPromptCJK);
std::unique_ptr<CPDF_CID2UnicodeMap> LoadCID2UnicodeMap(CIDSet charset,
bool bPromptCJK);
- std::map<CFX_ByteString, std::unique_ptr<CPDF_CMap>> m_CMaps;
+ std::map<CFX_ByteString, CFX_RetainPtr<CPDF_CMap>> m_CMaps;
std::unique_ptr<CPDF_CID2UnicodeMap> m_CID2UnicodeMaps[6];
};
@@ -127,7 +127,7 @@ enum CIDCoding : uint8_t {
CIDCODING_UTF16,
};
-class CPDF_CMap {
+class CPDF_CMap : public CFX_Retainable {
public:
enum CodingScheme : uint8_t {
OneByte,
@@ -136,8 +136,8 @@ class CPDF_CMap {
MixedFourBytes
};
- CPDF_CMap();
- ~CPDF_CMap();
+ template <typename T, typename... Args>
+ friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args);
void LoadPredefined(CPDF_CMapManager* pMgr,
const CFX_ByteString& name,
@@ -156,6 +156,9 @@ class CPDF_CMap {
friend class CPDF_CMapParser;
friend class CPDF_CIDFont;
+ CPDF_CMap();
+ ~CPDF_CMap() override;
+
CFX_ByteString m_PredefinedCMap;
bool m_bVertical;
CIDSet m_Charset;
diff --git a/core/fpdfapi/font/fpdf_font_cid.cpp b/core/fpdfapi/font/fpdf_font_cid.cpp
index e6be712a13..ddc0c12b7d 100644
--- a/core/fpdfapi/font/fpdf_font_cid.cpp
+++ b/core/fpdfapi/font/fpdf_font_cid.cpp
@@ -286,30 +286,28 @@ CPDF_CMapManager::CPDF_CMapManager() {}
CPDF_CMapManager::~CPDF_CMapManager() {}
-CFX_MaybeOwned<CPDF_CMap> CPDF_CMapManager::GetPredefinedCMap(
+CFX_RetainPtr<CPDF_CMap> CPDF_CMapManager::GetPredefinedCMap(
const CFX_ByteString& name,
bool bPromptCJK) {
auto it = m_CMaps.find(name);
if (it != m_CMaps.end())
- return CFX_MaybeOwned<CPDF_CMap>(it->second.get()); // Unowned.
+ return it->second;
- std::unique_ptr<CPDF_CMap> pCMap = LoadPredefinedCMap(name, bPromptCJK);
- if (name.IsEmpty())
- return CFX_MaybeOwned<CPDF_CMap>(std::move(pCMap)); // Owned.
+ CFX_RetainPtr<CPDF_CMap> pCMap = LoadPredefinedCMap(name, bPromptCJK);
+ if (!name.IsEmpty())
+ m_CMaps[name] = pCMap;
- CPDF_CMap* pUnowned = pCMap.get();
- m_CMaps[name] = std::move(pCMap);
- return CFX_MaybeOwned<CPDF_CMap>(pUnowned); // Unowned.
+ return pCMap;
}
-std::unique_ptr<CPDF_CMap> CPDF_CMapManager::LoadPredefinedCMap(
+CFX_RetainPtr<CPDF_CMap> CPDF_CMapManager::LoadPredefinedCMap(
const CFX_ByteString& name,
bool bPromptCJK) {
- auto pCMap = pdfium::MakeUnique<CPDF_CMap>();
const char* pname = name.c_str();
if (*pname == '/')
pname++;
+ auto pCMap = pdfium::MakeRetain<CPDF_CMap>();
pCMap->LoadPredefined(this, pname, bPromptCJK);
return pCMap;
}