Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cfgas_fontmgr.h
Go to the documentation of this file.
1// Copyright 2014 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#ifndef XFA_FGAS_FONT_CFGAS_FONTMGR_H_
8#define XFA_FGAS_FONT_CFGAS_FONTMGR_H_
9
10#include <array>
11#include <deque>
12#include <map>
13#include <memory>
14#include <set>
15#include <vector>
16
17#include "build/build_config.h"
18#include "core/fxcrt/compiler_specific.h"
19#include "core/fxcrt/fx_codepage_forward.h"
20#include "core/fxcrt/retain_ptr.h"
21#include "core/fxcrt/widestring.h"
22#include "core/fxge/cfx_face.h"
23
24class CFGAS_GEFont;
26
27#if BUILDFLAG(IS_WIN)
28struct FX_FONTSIGNATURE {
29 std::array<uint32_t, 4> fsUsb;
30 std::array<uint32_t, 2> fsCsb;
31};
32
33inline bool operator==(const FX_FONTSIGNATURE& left,
34 const FX_FONTSIGNATURE& right) {
35 return left.fsUsb[0] == right.fsUsb[0] && left.fsUsb[1] == right.fsUsb[1] &&
36 left.fsUsb[2] == right.fsUsb[2] && left.fsUsb[3] == right.fsUsb[3] &&
37 left.fsCsb[0] == right.fsCsb[0] && left.fsCsb[1] == right.fsCsb[1];
38}
39
40struct FX_FONTDESCRIPTOR {
41 wchar_t wsFontFace[32];
42 uint32_t dwFontStyles;
43 FX_Charset uCharSet;
44 FX_FONTSIGNATURE FontSignature;
45};
46
47inline bool operator==(const FX_FONTDESCRIPTOR& left,
48 const FX_FONTDESCRIPTOR& right) {
49 return left.uCharSet == right.uCharSet &&
50 left.dwFontStyles == right.dwFontStyles &&
51 left.FontSignature == right.FontSignature &&
52 wcscmp(left.wsFontFace, right.wsFontFace) == 0;
53}
54
55#else // BUILDFLAG(IS_WIN)
56
58 public:
61
62 int32_t m_nFaceIndex = 0;
63 uint32_t m_dwFontStyles = 0;
66 std::array<uint32_t, 4> m_dwUsb = {};
67 std::array<uint32_t, 2> m_dwCsb = {};
68};
69
71 public:
73 int32_t nPenalty;
74
75 bool operator>(const CFGAS_FontDescriptorInfo& other) const {
76 return nPenalty > other.nPenalty;
77 }
78 bool operator<(const CFGAS_FontDescriptorInfo& other) const {
79 return nPenalty < other.nPenalty;
80 }
81 bool operator==(const CFGAS_FontDescriptorInfo& other) const {
82 return nPenalty == other.nPenalty;
83 }
84};
85
86#endif // BUILDFLAG(IS_WIN)
87
89 public:
92
93 bool EnumFonts();
94 RetainPtr<CFGAS_GEFont> GetFontByCodePage(FX_CodePage wCodePage,
95 uint32_t dwFontStyles,
96 const wchar_t* pszFontFamily);
97 RetainPtr<CFGAS_GEFont> GetFontByUnicode(wchar_t wUnicode,
98 uint32_t dwFontStyles,
99 const wchar_t* pszFontFamily);
100 RetainPtr<CFGAS_GEFont> LoadFont(const wchar_t* pszFontFamily,
101 uint32_t dwFontStyles,
102 FX_CodePage wCodePage);
103
104 private:
105 RetainPtr<CFGAS_GEFont> GetFontByUnicodeImpl(wchar_t wUnicode,
106 uint32_t dwFontStyles,
107 const wchar_t* pszFontFamily,
108 uint32_t dwHash,
109 FX_CodePage wCodePage,
110 uint16_t wBitField);
111
112#if BUILDFLAG(IS_WIN)
113 const FX_FONTDESCRIPTOR* FindFont(const wchar_t* pszFontFamily,
118 wchar_t wUnicode);
119
120#else // BUILDFLAG(IS_WIN)
121 bool EnumFontsFromFontMapper();
122 void RegisterFace(RetainPtr<CFX_Face> pFace, const WideString& wsFaceName);
123 void RegisterFaces(const RetainPtr<IFX_SeekableReadStream>& pFontStream,
124 const WideString& wsFaceName);
125 std::vector<CFGAS_FontDescriptorInfo> MatchFonts(FX_CodePage wCodePage,
126 uint32_t dwFontStyles,
127 const WideString& FontName,
128 wchar_t wcUnicode);
129 RetainPtr<CFGAS_GEFont> LoadFontInternal(const WideString& wsFaceName,
130 int32_t iFaceIndex);
131#endif // BUILDFLAG(IS_WIN)
132
133 std::map<uint32_t, std::vector<RetainPtr<CFGAS_GEFont>>> m_Hash2Fonts;
134 std::set<wchar_t> m_FailedUnicodesSet;
135
136#if BUILDFLAG(IS_WIN)
138#else
139 std::vector<std::unique_ptr<CFGAS_FontDescriptor>> m_InstalledFonts;
140 std::map<uint32_t, std::vector<CFGAS_FontDescriptorInfo>>
141 m_Hash2CandidateList;
142#endif // BUILDFLAG(IS_WIN)
143};
144
145#endif // XFA_FGAS_FONT_CFGAS_FONTMGR_H_
fxcrt::ByteString ByteString
Definition bytestring.h:180
std::array< uint32_t, 4 > m_dwUsb
std::vector< WideString > m_wsFamilyNames
std::array< uint32_t, 2 > m_dwCsb
RetainPtr< CFGAS_GEFont > GetFontByCodePage(FX_CodePage wCodePage, uint32_t dwFontStyles, const wchar_t *pszFontFamily)
RetainPtr< CFGAS_GEFont > GetFontByUnicode(wchar_t wUnicode, uint32_t dwFontStyles, const wchar_t *pszFontFamily)
RetainPtr< CFGAS_GEFont > LoadFont(const wchar_t *pszFontFamily, uint32_t dwFontStyles, FX_CodePage wCodePage)
constexpr CFX_RectF()=default
constexpr CFX_RectF(float dst_left, float dst_top, float dst_width, float dst_height)
virtual RetainPtr< CFGAS_GEFont > LoadFont()
~CFDETextOutTest() override=default
CFX_DefaultRenderDevice * device()
virtual const char * GetEmptyBitmapChecksum()
FX_CodePage
Definition fx_codepage.h:19
CFX_STemplate< int32_t > CFX_Size
CRYPT_md5_context CRYPT_MD5Start()
Definition fx_crypt.cpp:164
std::string CryptToBase16(const uint8_t *digest)
Definition hash.cpp:9
TEST_F(CFDETextOutTest, DrawLogicTextBasic)
bool operator<(const CFGAS_FontDescriptorInfo &other) const
bool operator==(const CFGAS_FontDescriptorInfo &other) const
bool operator>(const CFGAS_FontDescriptorInfo &other) const
UNOWNED_PTR_EXCLUSION CFGAS_FontDescriptor * pFont
#define UNOWNED_PTR_EXCLUSION
fxcrt::WideString WideString
Definition widestring.h:207