summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_font
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/fpdfapi/fpdf_font')
-rw-r--r--core/src/fpdfapi/fpdf_font/font_int.h16
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp51
2 files changed, 32 insertions, 35 deletions
diff --git a/core/src/fpdfapi/fpdf_font/font_int.h b/core/src/fpdfapi/fpdf_font/font_int.h
index d7cbe1b0b5..30223ad63a 100644
--- a/core/src/fpdfapi/fpdf_font/font_int.h
+++ b/core/src/fpdfapi/fpdf_font/font_int.h
@@ -3,10 +3,22 @@
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
#ifndef CORE_SRC_FPDFAPI_FPDF_FONT_FONT_INT_H_
#define CORE_SRC_FPDFAPI_FPDF_FONT_FONT_INT_H_
+#include <map>
+
+#include "../../../include/fxcrt/fx_basic.h"
+#include "../../../include/fpdfapi/fpdf_resource.h"
+
+class CPDF_CID2UnicodeMap;
+class CPDF_CMap;
+class CPDF_Font;
+class CPDF_Stream;
+
typedef void* FXFT_Library;
+
class CPDF_CMapManager {
public:
CPDF_CMapManager();
@@ -19,9 +31,9 @@ class CPDF_CMapManager {
private:
CPDF_CMap* LoadPredefinedCMap(const CFX_ByteString& name, FX_BOOL bPrompt);
CPDF_CID2UnicodeMap* LoadCID2UnicodeMap(int charset, FX_BOOL bPrompt);
- void DropAll(FX_BOOL bReload);
+
FX_BOOL m_bPrompted;
- CFX_MapByteStringToPtr m_CMaps;
+ std::map<CFX_ByteString, CPDF_CMap*> m_CMaps;
CPDF_CID2UnicodeMap* m_CID2UnicodeMaps[6];
};
class CPDF_FontGlobals {
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
index 6c728242e6..ebb99fad63 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
@@ -22,19 +22,24 @@ CPDF_CMapManager::CPDF_CMapManager() {
FXSYS_memset(m_CID2UnicodeMaps, 0, sizeof m_CID2UnicodeMaps);
}
CPDF_CMapManager::~CPDF_CMapManager() {
- DropAll(FALSE);
+ for (const auto& pair : m_CMaps) {
+ delete pair.second;
+ }
+ m_CMaps.clear();
+ for (int i = 0; i < FX_ArraySize(m_CID2UnicodeMaps); ++i) {
+ delete m_CID2UnicodeMaps[i];
+ }
}
CPDF_CMap* CPDF_CMapManager::GetPredefinedCMap(const CFX_ByteString& name,
FX_BOOL bPromptCJK) {
- CPDF_CMap* pCMap;
- if (m_CMaps.Lookup(name, (void*&)pCMap)) {
- return pCMap;
+ auto it = m_CMaps.find(name);
+ if (it != m_CMaps.end()) {
+ return it->second;
}
- pCMap = LoadPredefinedCMap(name, bPromptCJK);
- if (name.IsEmpty()) {
- return pCMap;
+ CPDF_CMap* pCMap = LoadPredefinedCMap(name, bPromptCJK);
+ if (!name.IsEmpty()) {
+ m_CMaps[name] = pCMap;
}
- m_CMaps.SetAt(name, pCMap);
return pCMap;
}
CPDF_CMap* CPDF_CMapManager::LoadPredefinedCMap(const CFX_ByteString& name,
@@ -59,33 +64,13 @@ int _CharsetFromOrdering(const CFX_ByteString& Ordering) {
return CIDSET_UNKNOWN;
}
void CPDF_CMapManager::ReloadAll() {
- DropAll(TRUE);
-}
-void CPDF_CMapManager::DropAll(FX_BOOL bReload) {
- FX_POSITION pos = m_CMaps.GetStartPosition();
- while (pos) {
- CFX_ByteString name;
- CPDF_CMap* pCMap;
- m_CMaps.GetNextAssoc(pos, name, (void*&)pCMap);
- if (pCMap == NULL) {
- continue;
- }
- if (bReload) {
- pCMap->LoadPredefined(this, name, FALSE);
- } else {
- delete pCMap;
- }
+ for (const auto& pair : m_CMaps) {
+ CPDF_CMap* pCMap = pair.second;
+ pCMap->LoadPredefined(this, pair.first, FALSE);
}
- for (int i = 0; i < sizeof m_CID2UnicodeMaps / sizeof(CPDF_CID2UnicodeMap*);
- i++) {
- CPDF_CID2UnicodeMap* pMap = m_CID2UnicodeMaps[i];
- if (pMap == NULL) {
- continue;
- }
- if (bReload) {
+ for (int i = 0; i < FX_ArraySize(m_CID2UnicodeMaps); ++i) {
+ if (CPDF_CID2UnicodeMap* pMap = m_CID2UnicodeMaps[i]) {
pMap->Load(this, i, FALSE);
- } else {
- delete pMap;
}
}
}