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 <deque>
11#include <map>
12#include <memory>
13#include <set>
14#include <vector>
15
16#include "build/build_config.h"
17#include "core/fxcrt/fx_codepage_forward.h"
18#include "core/fxcrt/retain_ptr.h"
19#include "core/fxcrt/widestring.h"
20#include "core/fxge/cfx_face.h"
21
22class CFGAS_GEFont;
24
25#if BUILDFLAG(IS_WIN)
26struct FX_FONTSIGNATURE {
27 uint32_t fsUsb[4];
28 uint32_t fsCsb[2];
29};
30
31inline bool operator==(const FX_FONTSIGNATURE& left,
32 const FX_FONTSIGNATURE& right) {
33 return left.fsUsb[0] == right.fsUsb[0] && left.fsUsb[1] == right.fsUsb[1] &&
34 left.fsUsb[2] == right.fsUsb[2] && left.fsUsb[3] == right.fsUsb[3] &&
35 left.fsCsb[0] == right.fsCsb[0] && left.fsCsb[1] == right.fsCsb[1];
36}
37
38struct FX_FONTDESCRIPTOR {
39 wchar_t wsFontFace[32];
40 uint32_t dwFontStyles;
41 FX_Charset uCharSet;
42 FX_FONTSIGNATURE FontSignature;
43};
44
45inline bool operator==(const FX_FONTDESCRIPTOR& left,
46 const FX_FONTDESCRIPTOR& right) {
47 return left.uCharSet == right.uCharSet &&
48 left.dwFontStyles == right.dwFontStyles &&
49 left.FontSignature == right.FontSignature &&
50 wcscmp(left.wsFontFace, right.wsFontFace) == 0;
51}
52
53#else // BUILDFLAG(IS_WIN)
54
56 public:
59
60 int32_t m_nFaceIndex = 0;
61 uint32_t m_dwFontStyles = 0;
62 WideString m_wsFaceName;
64 uint32_t m_dwUsb[4] = {};
65 uint32_t m_dwCsb[2] = {};
66};
67
69 public:
71 int32_t nPenalty;
72
73 bool operator>(const CFGAS_FontDescriptorInfo& other) const {
74 return nPenalty > other.nPenalty;
75 }
76 bool operator<(const CFGAS_FontDescriptorInfo& other) const {
77 return nPenalty < other.nPenalty;
78 }
79 bool operator==(const CFGAS_FontDescriptorInfo& other) const {
80 return nPenalty == other.nPenalty;
81 }
82};
83
84#endif // BUILDFLAG(IS_WIN)
85
87 public:
90
91 bool EnumFonts();
92 RetainPtr<CFGAS_GEFont> GetFontByCodePage(FX_CodePage wCodePage,
93 uint32_t dwFontStyles,
94 const wchar_t* pszFontFamily);
95 RetainPtr<CFGAS_GEFont> GetFontByUnicode(wchar_t wUnicode,
96 uint32_t dwFontStyles,
97 const wchar_t* pszFontFamily);
98 RetainPtr<CFGAS_GEFont> LoadFont(const wchar_t* pszFontFamily,
99 uint32_t dwFontStyles,
100 FX_CodePage wCodePage);
101
102 private:
103 RetainPtr<CFGAS_GEFont> GetFontByUnicodeImpl(wchar_t wUnicode,
104 uint32_t dwFontStyles,
105 const wchar_t* pszFontFamily,
106 uint32_t dwHash,
107 FX_CodePage wCodePage,
108 uint16_t wBitField);
109
110#if BUILDFLAG(IS_WIN)
111 const FX_FONTDESCRIPTOR* FindFont(const wchar_t* pszFontFamily,
116 wchar_t wUnicode);
117
118#else // BUILDFLAG(IS_WIN)
119 bool EnumFontsFromFontMapper();
120 void RegisterFace(RetainPtr<CFX_Face> pFace, const WideString& wsFaceName);
121 void RegisterFaces(const RetainPtr<IFX_SeekableReadStream>& pFontStream,
122 const WideString& wsFaceName);
123 std::vector<CFGAS_FontDescriptorInfo> MatchFonts(FX_CodePage wCodePage,
124 uint32_t dwFontStyles,
125 const WideString& FontName,
126 wchar_t wcUnicode);
127 RetainPtr<CFGAS_GEFont> LoadFontInternal(const WideString& wsFaceName,
128 int32_t iFaceIndex);
129#endif // BUILDFLAG(IS_WIN)
130
131 std::map<uint32_t, std::vector<RetainPtr<CFGAS_GEFont>>> m_Hash2Fonts;
132 std::set<wchar_t> m_FailedUnicodesSet;
133
134#if BUILDFLAG(IS_WIN)
136#else
137 std::vector<std::unique_ptr<CFGAS_FontDescriptor>> m_InstalledFonts;
138 std::map<uint32_t, std::vector<CFGAS_FontDescriptorInfo>>
139 m_Hash2CandidateList;
140#endif // BUILDFLAG(IS_WIN)
141};
142
143#endif // XFA_FGAS_FONT_CFGAS_FONTMGR_H_
TEST_F(CFDETextOutTest, DrawLogicTextBasic)
CFDE_TextOut & text_out()
virtual RetainPtr< CFGAS_GEFont > LoadFont()
CFDETextOutTest()=default
virtual CFX_Size GetBitmapSize()
~CFDETextOutTest() override=default
virtual const char * GetEmptyBitmapChecksum()
CFX_DefaultRenderDevice * device()
std::vector< WideString > m_wsFamilyNames
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)
const char * c_str() const
Definition bytestring.h:76
FX_CodePage
Definition fx_codepage.h:18
void CRYPT_MD5Finish(CRYPT_md5_context *context, uint8_t digest[16])
Definition fx_crypt.cpp:214
CRYPT_md5_context CRYPT_MD5Start()
Definition fx_crypt.cpp:176
std::string CryptToBase16(const uint8_t *digest)
Definition hash.cpp:9
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