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
cpvt_fontmap.cpp
Go to the documentation of this file.
1
// Copyright 2016 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/fpdfdoc/cpvt_fontmap.h"
8
9
#
include
<
utility
>
10
11
#
include
"core/fpdfapi/font/cpdf_font.h"
12
#
include
"core/fpdfapi/parser/cpdf_dictionary.h"
13
#
include
"core/fpdfapi/parser/cpdf_document.h"
14
#
include
"core/fpdfapi/parser/cpdf_reference.h"
15
#
include
"core/fpdfapi/parser/fpdf_parser_utility.h"
16
#
include
"core/fpdfdoc/cpdf_interactiveform.h"
17
#
include
"core/fxcrt/check.h"
18
#
include
"core/fxcrt/fx_codepage.h"
19
#
include
"core/fxcrt/notreached.h"
20
21
CPVT_FontMap::
CPVT_FontMap
(
CPDF_Document
* pDoc,
22
RetainPtr
<
CPDF_Dictionary
> pResDict,
23
RetainPtr
<
CPDF_Font
> pDefFont,
24
const
ByteString
& sDefFontAlias)
25
:
m_pDocument
(
pDoc
),
26
m_pResDict
(
std
::
move
(
pResDict
)),
27
m_pDefFont
(
std
::
move
(
pDefFont
)),
28
m_sDefFontAlias
(
sDefFontAlias
) {}
29
30
CPVT_FontMap::~
CPVT_FontMap
() =
default
;
31
32
void
CPVT_FontMap::SetupAnnotSysPDFFont() {
33
if
(!m_pDocument || !m_pResDict)
34
return
;
35
36
RetainPtr
<
CPDF_Font
> pPDFFont =
37
CPDF_InteractiveForm::AddNativeInteractiveFormFont(m_pDocument,
38
&m_sSysFontAlias);
39
if
(!pPDFFont)
40
return
;
41
42
RetainPtr
<
CPDF_Dictionary
> pFontList = m_pResDict->GetMutableDictFor(
"Font"
);
43
if
(ValidateFontResourceDict(pFontList.Get()) &&
44
!pFontList->KeyExist(m_sSysFontAlias)) {
45
pFontList->SetNewFor<CPDF_Reference>(m_sSysFontAlias, m_pDocument,
46
pPDFFont->GetFontDictObjNum());
47
}
48
m_pSysFont = std::move(pPDFFont);
49
}
50
51
RetainPtr
<
CPDF_Font
> CPVT_FontMap::
GetPDFFont
(int32_t nFontIndex) {
52
switch
(nFontIndex) {
53
case
0:
54
return
m_pDefFont;
55
case
1:
56
if
(!m_pSysFont)
57
SetupAnnotSysPDFFont();
58
return
m_pSysFont;
59
default
:
60
return
nullptr
;
61
}
62
}
63
64
ByteString
CPVT_FontMap::
GetPDFFontAlias
(int32_t nFontIndex) {
65
switch
(nFontIndex) {
66
case
0:
67
return
m_sDefFontAlias;
68
case
1:
69
if
(!m_pSysFont)
70
SetupAnnotSysPDFFont();
71
return
m_sSysFontAlias;
72
default
:
73
return
ByteString
(
)
;
74
}
75
}
76
77
int32_t CPVT_FontMap::
GetWordFontIndex
(uint16_t word,
78
FX_Charset
charset,
79
int32_t nFontIndex) {
80
NOTREACHED_NORETURN
();
81
}
82
83
int32_t CPVT_FontMap::
CharCodeFromUnicode
(int32_t nFontIndex, uint16_t word) {
84
NOTREACHED_NORETURN
();
85
}
86
87
FX_Charset
CPVT_FontMap::
CharSetFromUnicode
(uint16_t word,
88
FX_Charset
nOldCharset) {
89
NOTREACHED_NORETURN
();
90
}
ByteString
fxcrt::ByteString ByteString
Definition
bytestring.h:180
CPDF_Dictionary::DictMap
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
Definition
cpdf_dictionary.h:31
CPDF_Document
Definition
cpdf_document.h:29
CPDF_Font
Definition
cpdf_font.h:37
CPVT_FontMap::GetPDFFontAlias
ByteString GetPDFFontAlias(int32_t nFontIndex) override
Definition
cpvt_fontmap.cpp:64
CPVT_FontMap::GetPDFFont
RetainPtr< CPDF_Font > GetPDFFont(int32_t nFontIndex) override
Definition
cpvt_fontmap.cpp:51
CPVT_FontMap::CharCodeFromUnicode
int32_t CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) override
Definition
cpvt_fontmap.cpp:83
CPVT_FontMap::CPVT_FontMap
CPVT_FontMap(CPDF_Document *pDoc, RetainPtr< CPDF_Dictionary > pResDict, RetainPtr< CPDF_Font > pDefFont, const ByteString &sDefFontAlias)
Definition
cpvt_fontmap.cpp:21
CPVT_FontMap::GetWordFontIndex
int32_t GetWordFontIndex(uint16_t word, FX_Charset charset, int32_t nFontIndex) override
Definition
cpvt_fontmap.cpp:77
CPVT_FontMap::CharSetFromUnicode
FX_Charset CharSetFromUnicode(uint16_t word, FX_Charset nOldCharset) override
Definition
cpvt_fontmap.cpp:87
CPVT_FontMap::~CPVT_FontMap
~CPVT_FontMap() override
fxcrt::ByteString::ByteString
ByteString()=default
fxcrt::RetainPtr
Definition
retain_ptr.h:28
FX_Charset
FX_Charset
Definition
fx_codepage.h:71
NOTREACHED_NORETURN
#define NOTREACHED_NORETURN()
Definition
notreached.h:22
qtwebengine
src
3rdparty
chromium
third_party
pdfium
core
fpdfdoc
cpvt_fontmap.cpp
Generated on
for Qt by
1.18.0