7#include "core/fpdfapi/font/cpdf_fontglobals.h"
11#include "core/fpdfapi/cmaps/CNS1/cmaps_cns1.h"
12#include "core/fpdfapi/cmaps/GB1/cmaps_gb1.h"
13#include "core/fpdfapi/cmaps/Japan1/cmaps_japan1.h"
14#include "core/fpdfapi/cmaps/Korea1/cmaps_korea1.h"
15#include "core/fpdfapi/font/cfx_stockfontarray.h"
16#include "core/fpdfapi/font/cpdf_cid2unicodemap.h"
17#include "core/fpdfapi/font/cpdf_cmap.h"
18#include "core/fpdfapi/parser/cpdf_document.h"
19#include "third_party/base/check.h"
20#include "third_party/base/containers/contains.h"
26RetainPtr<
const CPDF_CMap> LoadPredefinedCMap(ByteStringView name) {
27 if (!name.IsEmpty() && name[0] ==
'/')
28 name = name.Last(name.GetLength() - 1);
29 return pdfium::MakeRetain<CPDF_CMap>(name);
36 DCHECK(!g_FontGlobals);
42 DCHECK(g_FontGlobals);
44 g_FontGlobals =
nullptr;
49 DCHECK(g_FontGlobals);
58 LoadEmbeddedGB1CMaps();
59 LoadEmbeddedCNS1CMaps();
60 LoadEmbeddedJapan1CMaps();
61 LoadEmbeddedKorea1CMaps();
67 auto it = m_StockMap.find(pDoc);
68 if (it == m_StockMap.end() || !it->second)
71 return it->second->GetFont(index);
78 if (!pdfium::Contains(m_StockMap, pKey))
79 m_StockMap[pKey] = std::make_unique<CFX_StockFontArray>();
80 m_StockMap[pKey]->SetFont(index, std::move(pFont));
86 auto it = m_StockMap.find(pDoc);
87 if (it != m_StockMap.end())
93 fxcmap::kGB1_cmaps_size)
);
99 fxcmap::kCNS1_cmaps_size)
);
118 const ByteString& name) {
119 auto it = m_CMaps.find(name);
120 if (it != m_CMaps.end())
123 RetainPtr<
const CPDF_CMap> pCMap = LoadPredefinedCMap(name.AsStringView());
125 m_CMaps[name] = pCMap;
131 if (!m_CID2UnicodeMaps[charset]) {
132 m_CID2UnicodeMaps[charset] = std::make_unique<CPDF_CID2UnicodeMap>(charset);
134 return m_CID2UnicodeMaps[charset].get();
void Set(CPDF_Document *pDoc, CFX_FontMapper::StandardFont index, RetainPtr< CPDF_Font > pFont)
RetainPtr< CPDF_Font > Find(CPDF_Document *pDoc, CFX_FontMapper::StandardFont index)
static CPDF_FontGlobals * GetInstance()
RetainPtr< const CPDF_CMap > GetPredefinedCMap(const ByteString &name)
void Clear(CPDF_Document *pDoc)
void SetEmbeddedCharset(CIDSet idx, pdfium::span< const fxcmap::CMap > map)
CPDF_CID2UnicodeMap * GetCID2UnicodeMap(CIDSet charset)
void SetEmbeddedToUnicode(CIDSet idx, pdfium::span< const uint16_t > map)
const CMap kJapan1_cmaps[]
const CMap kKorea1_cmaps[]
const uint16_t kJapan1CID2Unicode_4[15444]
const uint16_t kGB1CID2Unicode_5[30284]
const uint16_t kKorea1CID2Unicode_2[18352]
const uint16_t kCNS1CID2Unicode_5[19088]