Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
cpdf_fontglobals.cpp
Go to the documentation of this file.
1
// Copyright 2017 The PDFium Authors
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7
#
include
"core/fpdfapi/font/cpdf_fontglobals.h"
8
9
#
include
<
utility
>
10
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
"core/fxcrt/check.h"
20
#
include
"core/fxcrt/containers/contains.h"
21
22
namespace
{
23
24
CPDF_FontGlobals
* g_FontGlobals =
nullptr
;
25
26
RetainPtr
<
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);
30
}
31
32
}
// namespace
33
34
// static
35
void
CPDF_FontGlobals
::
Create
() {
36
DCHECK
(!g_FontGlobals);
37
g_FontGlobals =
new
CPDF_FontGlobals
();
38
}
39
40
// static
41
void
CPDF_FontGlobals
::
Destroy
() {
42
DCHECK
(g_FontGlobals);
43
delete
g_FontGlobals;
44
g_FontGlobals =
nullptr
;
45
}
46
47
// static
48
CPDF_FontGlobals
*
CPDF_FontGlobals
::
GetInstance
() {
49
DCHECK
(g_FontGlobals);
50
return
g_FontGlobals;
51
}
52
53
CPDF_FontGlobals
::CPDF_FontGlobals() =
default
;
54
55
CPDF_FontGlobals
::~CPDF_FontGlobals() =
default
;
56
57
void
CPDF_FontGlobals
::
LoadEmbeddedMaps
() {
58
LoadEmbeddedGB1CMaps();
59
LoadEmbeddedCNS1CMaps();
60
LoadEmbeddedJapan1CMaps();
61
LoadEmbeddedKorea1CMaps();
62
}
63
64
RetainPtr
<
CPDF_Font
>
CPDF_FontGlobals
::
Find
(
65
CPDF_Document
* pDoc,
66
CFX_FontMapper
::
StandardFont
index) {
67
auto
it = m_StockMap.find(pDoc);
68
if
(it == m_StockMap.end() || !it->second)
69
return
nullptr
;
70
71
return
it->second->GetFont(index);
72
}
73
74
void
CPDF_FontGlobals
::
Set
(
CPDF_Document
* pDoc,
75
CFX_FontMapper
::
StandardFont
index,
76
RetainPtr
<
CPDF_Font
> pFont) {
77
UnownedPtr
<
CPDF_Document
> pKey(pDoc);
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));
81
}
82
83
void
CPDF_FontGlobals
::
Clear
(
CPDF_Document
* pDoc) {
84
// Avoid constructing smart-pointer key as erase() doesn't invoke
85
// transparent lookup in the same way find() does.
86
auto
it = m_StockMap.find(pDoc);
87
if
(it != m_StockMap.end())
88
m_StockMap.erase(it);
89
}
90
91
void
CPDF_FontGlobals
::LoadEmbeddedGB1CMaps() {
92
SetEmbeddedCharset(CIDSET_GB1, fxcmap::kGB1_cmaps_span);
93
SetEmbeddedToUnicode(CIDSET_GB1, fxcmap::kGB1CID2Unicode_5);
94
}
95
96
void
CPDF_FontGlobals
::LoadEmbeddedCNS1CMaps() {
97
SetEmbeddedCharset(CIDSET_CNS1, fxcmap::kCNS1_cmaps_span);
98
SetEmbeddedToUnicode(CIDSET_CNS1, fxcmap::kCNS1CID2Unicode_5);
99
}
100
101
void
CPDF_FontGlobals
::LoadEmbeddedJapan1CMaps() {
102
SetEmbeddedCharset(CIDSET_JAPAN1, fxcmap::kJapan1_cmaps_span);
103
SetEmbeddedToUnicode(CIDSET_JAPAN1, fxcmap::kJapan1CID2Unicode_4);
104
}
105
106
void
CPDF_FontGlobals
::LoadEmbeddedKorea1CMaps() {
107
SetEmbeddedCharset(CIDSET_KOREA1, fxcmap::kKorea1_cmaps_span);
108
SetEmbeddedToUnicode(CIDSET_KOREA1, fxcmap::kKorea1CID2Unicode_2);
109
}
110
111
RetainPtr
<
const
CPDF_CMap>
CPDF_FontGlobals
::
GetPredefinedCMap
(
112
const
ByteString
& name) {
113
auto
it = m_CMaps.find(name);
114
if
(it != m_CMaps.end())
115
return
it->second;
116
117
RetainPtr
<
const
CPDF_CMap> pCMap = LoadPredefinedCMap(name.AsStringView());
118
if
(!name.IsEmpty())
119
m_CMaps[name] = pCMap;
120
121
return
pCMap;
122
}
123
124
CPDF_CID2UnicodeMap
*
CPDF_FontGlobals
::
GetCID2UnicodeMap
(
CIDSet
charset) {
125
if
(!m_CID2UnicodeMaps[charset]) {
126
m_CID2UnicodeMaps[charset] = std::make_unique<CPDF_CID2UnicodeMap>(charset);
127
}
128
return
m_CID2UnicodeMaps[charset].get();
129
}
ByteString
fxcrt::ByteString ByteString
Definition
bytestring.h:180
DCHECK
#define DCHECK
Definition
check.h:33
CFX_FontMapper
Definition
cfx_fontmapper.h:31
CFX_FontMapper::StandardFont
StandardFont
Definition
cfx_fontmapper.h:33
CPDF_CID2UnicodeMap
Definition
cpdf_cid2unicodemap.h:13
CPDF_Document
Definition
cpdf_document.h:29
CPDF_FontGlobals
Definition
cpdf_fontglobals.h:25
CPDF_FontGlobals::Set
void Set(CPDF_Document *pDoc, CFX_FontMapper::StandardFont index, RetainPtr< CPDF_Font > pFont)
Definition
cpdf_fontglobals.cpp:74
CPDF_FontGlobals::Destroy
static void Destroy()
Definition
cpdf_fontglobals.cpp:41
CPDF_FontGlobals::Find
RetainPtr< CPDF_Font > Find(CPDF_Document *pDoc, CFX_FontMapper::StandardFont index)
Definition
cpdf_fontglobals.cpp:64
CPDF_FontGlobals::LoadEmbeddedMaps
void LoadEmbeddedMaps()
Definition
cpdf_fontglobals.cpp:57
CPDF_FontGlobals::GetInstance
static CPDF_FontGlobals * GetInstance()
Definition
cpdf_fontglobals.cpp:48
CPDF_FontGlobals::GetPredefinedCMap
RetainPtr< const CPDF_CMap > GetPredefinedCMap(const ByteString &name)
Definition
cpdf_fontglobals.cpp:111
CPDF_FontGlobals::Clear
void Clear(CPDF_Document *pDoc)
Definition
cpdf_fontglobals.cpp:83
CPDF_FontGlobals::GetCID2UnicodeMap
CPDF_CID2UnicodeMap * GetCID2UnicodeMap(CIDSet charset)
Definition
cpdf_fontglobals.cpp:124
CPDF_FontGlobals::Create
static void Create()
Definition
cpdf_fontglobals.cpp:35
CPDF_Font
Definition
cpdf_font.h:37
fxcrt::RetainPtr
Definition
retain_ptr.h:28
fxcrt::UnownedPtr
Definition
unowned_ptr.h:76
pdfium::CFDETextOutLargeBitmapTest
Definition
cfde_textout_unittest.cpp:117
CIDSet
CIDSet
Definition
cpdf_cidfont.h:22
ByteStringView
fxcrt::ByteStringView ByteStringView
Definition
string_view_template.h:325
qtwebengine
src
3rdparty
chromium
third_party
pdfium
core
fpdfapi
font
cpdf_fontglobals.cpp
Generated on
for Qt by
1.18.0