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
cfgas_defaultfontmanager.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
"xfa/fgas/font/cfgas_defaultfontmanager.h"
8
9
#
include
"core/fxcrt/compiler_specific.h"
10
#
include
"core/fxcrt/fx_codepage.h"
11
#
include
"core/fxcrt/numerics/safe_conversions.h"
12
#
include
"core/fxge/fx_font.h"
13
#
include
"xfa/fgas/font/cfgas_fontmgr.h"
14
#
include
"xfa/fgas/font/cfgas_gefont.h"
15
#
include
"xfa/fgas/font/cfgas_gemodule.h"
16
#
include
"xfa/fgas/font/fgas_fontutils.h"
17
18
// static
19
RetainPtr
<CFGAS_GEFont>
CFGAS_DefaultFontManager
::
GetFont
(
20
WideString
wsFontName,
21
uint32_t dwFontStyles) {
22
CFGAS_FontMgr
* pFontMgr =
CFGAS_GEModule
::
Get
(
)
->
GetFontMgr
(
)
;
23
RetainPtr
<CFGAS_GEFont> pFont = pFontMgr->LoadFont(
24
wsFontName.c_str(), dwFontStyles, FX_CodePage::kFailure);
25
if
(pFont) {
26
return
pFont;
27
}
28
const
FGAS_FontInfo
* pCurFont =
29
FGAS_FontInfoByFontName(wsFontName.AsStringView());
30
if
(!pCurFont || !pCurFont
->
pReplaceFont
) {
31
return
nullptr
;
32
}
33
uint32_t dwStyle = 0;
34
// TODO(dsinclair): Why doesn't this check the other flags?
35
if
(
FontStyleIsForceBold
(
dwFontStyles
)
) {
36
dwStyle |=
FXFONT_FORCE_BOLD
;
37
}
38
if
(
FontStyleIsItalic
(
dwFontStyles
)
) {
39
dwStyle |=
FXFONT_ITALIC
;
40
}
41
ByteStringView
replace_view(pCurFont->pReplaceFont);
42
while
(!replace_view.IsEmpty()) {
43
ByteStringView
segment;
44
auto
found = replace_view.Find(
','
);
45
if
(found.has_value()) {
46
segment = replace_view.First(found.value());
47
replace_view = replace_view.Substr(found.value() + 1);
48
}
else
{
49
segment = replace_view;
50
replace_view = ByteStringView();
51
}
52
pFont = pFontMgr
->
LoadFont
(
WideString
::
FromASCII
(
segment
)
.c_str()
,
dwStyle
,
53
FX_CodePage
::
kFailure
)
;
54
if
(pFont) {
55
return
pFont;
56
}
57
}
58
return
nullptr
;
59
}
60
61
// static
62
RetainPtr
<CFGAS_GEFont>
CFGAS_DefaultFontManager
::
GetDefaultFont
(
63
uint32_t dwFontStyles) {
64
CFGAS_FontMgr
* pFontMgr =
CFGAS_GEModule
::
Get
(
)
->
GetFontMgr
(
)
;
65
RetainPtr
<CFGAS_GEFont> pFont =
66
pFontMgr->LoadFont(L"Arial Narrow", dwFontStyles, FX_CodePage::kFailure);
67
if
(pFont)
68
return
pFont;
69
70
return
pFontMgr
->
LoadFont
(
nullptr
, dwFontStyles,
FX_CodePage
::
kFailure
);
71
}
CFGAS_DefaultFontManager
Definition
cfgas_defaultfontmanager.h:15
CFGAS_DefaultFontManager::GetDefaultFont
static RetainPtr< CFGAS_GEFont > GetDefaultFont(uint32_t dwFontStyles)
Definition
cfgas_defaultfontmanager.cpp:62
CFGAS_DefaultFontManager::GetFont
static RetainPtr< CFGAS_GEFont > GetFont(WideString wsFontName, uint32_t dwFontStyles)
Definition
cfgas_defaultfontmanager.cpp:19
CFGAS_FontMgr
Definition
cfgas_fontmgr.h:88
CFGAS_FontMgr::LoadFont
RetainPtr< CFGAS_GEFont > LoadFont(const wchar_t *pszFontFamily, uint32_t dwFontStyles, FX_CodePage wCodePage)
Definition
cfgas_fontmgr.cpp:878
CFGAS_GEModule
Definition
cfgas_gemodule.h:12
CFGAS_GEModule::Get
static CFGAS_GEModule * Get()
Definition
cfgas_gemodule.cpp:31
CFGAS_GEModule::GetFontMgr
CFGAS_FontMgr * GetFontMgr()
Definition
cfgas_gemodule.h:18
fxcrt::RetainPtr
Definition
retain_ptr.h:28
fxcrt::WideString::FromASCII
static WideString FromASCII(ByteStringView str)
Definition
widestring.cpp:704
FX_CodePage
FX_CodePage
Definition
fx_codepage.h:19
FX_CodePage::kFailure
@ kFailure
Definition
fx_codepage.h:68
FXFONT_ITALIC
#define FXFONT_ITALIC
Definition
fx_font.h:35
FontStyleIsItalic
bool FontStyleIsItalic(uint32_t style)
Definition
fx_font.h:64
FXFONT_FORCE_BOLD
#define FXFONT_FORCE_BOLD
Definition
fx_font.h:38
FontStyleIsForceBold
bool FontStyleIsForceBold(uint32_t style)
Definition
fx_font.h:61
ByteStringView
fxcrt::ByteStringView ByteStringView
Definition
string_view_template.h:325
FGAS_FontInfo
Definition
fgas_fontutils.h:26
FGAS_FontInfo::pReplaceFont
const char * pReplaceFont
Definition
fgas_fontutils.h:29
WideString
fxcrt::WideString WideString
Definition
widestring.h:207
qtwebengine
src
3rdparty
chromium
third_party
pdfium
xfa
fgas
font
cfgas_defaultfontmanager.cpp
Generated on
for Qt by
1.18.0