Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: xfa/fgas/font/fgas_stdfontmgr.h

Issue 2494883002: Remove IFGAS_FontMgr and clean up (the renamed) CFGAS_FontMgr a little. (Closed)
Patch Set: Nits Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fgas/font/fgas_gefont.cpp ('k') | xfa/fgas/font/fgas_stdfontmgr.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
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_FGAS_STDFONTMGR_H_
8 #define XFA_FGAS_FONT_FGAS_STDFONTMGR_H_
9
10 #include <vector>
11
12 #include "core/fxcrt/fx_ext.h"
13 #include "core/fxge/cfx_fontmapper.h"
14 #include "core/fxge/fx_freetype.h"
15 #include "core/fxge/ifx_systemfontinfo.h"
16 #include "third_party/freetype/include/freetype/fttypes.h"
17 #include "xfa/fgas/font/fgas_font.h"
18
19 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
20 int32_t FX_GetSimilarValue(FX_FONTDESCRIPTOR const* pFont,
21 uint32_t dwFontStyles);
22 FX_FONTDESCRIPTOR const* FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams,
23 const CFX_FontDescriptors& fonts);
24
25 class CFGAS_StdFontMgrImp : public IFGAS_FontMgr {
26 public:
27 explicit CFGAS_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator);
28 ~CFGAS_StdFontMgrImp() override;
29
30 // IFGAS_FontMgr:
31 CFGAS_GEFont* GetDefFontByCodePage(
32 uint16_t wCodePage,
33 uint32_t dwFontStyles,
34 const FX_WCHAR* pszFontFamily = nullptr) override;
35 CFGAS_GEFont* GetDefFontByCharset(
36 uint8_t nCharset,
37 uint32_t dwFontStyles,
38 const FX_WCHAR* pszFontFamily = nullptr) override;
39 CFGAS_GEFont* GetDefFontByUnicode(
40 FX_WCHAR wUnicode,
41 uint32_t dwFontStyles,
42 const FX_WCHAR* pszFontFamily = nullptr) override;
43 CFGAS_GEFont* GetDefFontByLanguage(
44 uint16_t wLanguage,
45 uint32_t dwFontStyles,
46 const FX_WCHAR* pszFontFamily = nullptr) override;
47 CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily,
48 uint32_t dwFontStyles,
49 uint16_t wCodePage = 0xFFFF) override;
50 CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, int32_t iLength) override;
51 CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream,
52 const FX_WCHAR* pszFontAlias = nullptr,
53 uint32_t dwFontStyles = 0,
54 uint16_t wCodePage = 0,
55 bool bSaveStream = false) override;
56 CFGAS_GEFont* LoadFont(CFGAS_GEFont* pSrcFont,
57 uint32_t dwFontStyles,
58 uint16_t wCodePage = 0xFFFF) override;
59
60 void ClearFontCache() override;
61 void RemoveFont(CFGAS_GEFont* pFont) override;
62
63 protected:
64 void RemoveFont(CFX_MapPtrToPtr& fontMap, CFGAS_GEFont* pFont);
65 FX_FONTDESCRIPTOR const* FindFont(const FX_WCHAR* pszFontFamily,
66 uint32_t dwFontStyles,
67 uint32_t dwMatchFlags,
68 uint16_t wCodePage,
69 uint32_t dwUSB = 999,
70 FX_WCHAR wUnicode = 0);
71
72 FX_LPEnumAllFonts m_pEnumerator;
73 CFX_FontDescriptors m_FontFaces;
74 CFX_ArrayTemplate<CFGAS_GEFont*> m_Fonts;
75 CFX_MapPtrToPtr m_CPFonts;
76 CFX_MapPtrToPtr m_FamilyFonts;
77 CFX_MapPtrToPtr m_UnicodeFonts;
78 CFX_MapPtrToPtr m_BufferFonts;
79 CFX_MapPtrToPtr m_StreamFonts;
80 CFX_MapPtrToPtr m_DeriveFonts;
81 };
82 uint32_t FX_GetGdiFontStyles(const LOGFONTW& lf);
83
84 #else
85
86 class CFX_FontDescriptor {
87 public:
88 CFX_FontDescriptor();
89 ~CFX_FontDescriptor();
90
91 int32_t m_nFaceIndex;
92 CFX_WideString m_wsFaceName;
93 CFX_WideStringArray m_wsFamilyNames;
94 uint32_t m_dwFontStyles;
95 uint32_t m_dwUsb[4];
96 uint32_t m_dwCsb[2];
97 };
98
99 typedef CFX_ArrayTemplate<CFX_FontDescriptor*> CFX_FontDescriptors;
100
101 struct FX_FontDescriptorInfo {
102 public:
103 CFX_FontDescriptor* pFont;
104 int32_t nPenalty;
105
106 bool operator>(const FX_FontDescriptorInfo& other) const {
107 return nPenalty > other.nPenalty;
108 }
109 bool operator<(const FX_FontDescriptorInfo& other) const {
110 return nPenalty < other.nPenalty;
111 }
112 bool operator==(const FX_FontDescriptorInfo& other) const {
113 return nPenalty == other.nPenalty;
114 }
115 };
116
117 typedef CFX_ArrayTemplate<FX_FontDescriptorInfo> CFX_FontDescriptorInfos;
118
119 struct FX_HandleParentPath {
120 FX_HandleParentPath() {}
121 FX_HandleParentPath(const FX_HandleParentPath& x) {
122 pFileHandle = x.pFileHandle;
123 bsParentPath = x.bsParentPath;
124 }
125 FX_FileHandle* pFileHandle;
126 CFX_ByteString bsParentPath;
127 };
128
129 class CFX_FontSourceEnum_File {
130 public:
131 CFX_FontSourceEnum_File();
132 ~CFX_FontSourceEnum_File();
133
134 FX_POSITION GetStartPosition();
135 IFX_FileAccess* GetNext(FX_POSITION& pos);
136
137 private:
138 CFX_ByteString GetNextFile();
139
140 CFX_WideString m_wsNext;
141 CFX_ObjectArray<FX_HandleParentPath> m_FolderQueue;
142 CFX_ByteStringArray m_FolderPaths;
143 };
144
145 class CFGAS_FontMgrImp : public IFGAS_FontMgr {
146 public:
147 explicit CFGAS_FontMgrImp(CFX_FontSourceEnum_File* pFontEnum);
148 ~CFGAS_FontMgrImp() override;
149
150 // IFGAS_FontMgr:
151 CFGAS_GEFont* GetDefFontByCodePage(uint16_t wCodePage,
152 uint32_t dwFontStyles,
153 const FX_WCHAR* pszFontFamily) override;
154 CFGAS_GEFont* GetDefFontByCharset(uint8_t nCharset,
155 uint32_t dwFontStyles,
156 const FX_WCHAR* pszFontFamily) override;
157 CFGAS_GEFont* GetDefFontByUnicode(FX_WCHAR wUnicode,
158 uint32_t dwFontStyles,
159 const FX_WCHAR* pszFontFamily) override;
160 CFGAS_GEFont* GetDefFontByLanguage(uint16_t wLanguage,
161 uint32_t dwFontStyles,
162 const FX_WCHAR* pszFontFamily) override;
163 CFGAS_GEFont* GetFontByCodePage(uint16_t wCodePage,
164 uint32_t dwFontStyles,
165 const FX_WCHAR* pszFontFamily) override;
166 CFGAS_GEFont* GetFontByCharset(uint8_t nCharset,
167 uint32_t dwFontStyles,
168 const FX_WCHAR* pszFontFamily) override;
169 CFGAS_GEFont* GetFontByUnicode(FX_WCHAR wUnicode,
170 uint32_t dwFontStyles,
171 const FX_WCHAR* pszFontFamily) override;
172 CFGAS_GEFont* GetFontByLanguage(uint16_t wLanguage,
173 uint32_t dwFontStyles,
174 const FX_WCHAR* pszFontFamily) override;
175 void ClearFontCache() override;
176 void RemoveFont(CFGAS_GEFont* pFont) override;
177
178 CFGAS_GEFont* LoadFont(const CFX_WideString& wsFaceName,
179 int32_t iFaceIndex,
180 int32_t* pFaceCount);
181 bool EnumFonts();
182 bool EnumFontsFromFontMapper();
183 bool EnumFontsFromFiles();
184
185 protected:
186 void RegisterFace(FXFT_Face pFace,
187 const CFX_WideString* pFaceName);
188 void RegisterFaces(IFX_SeekableReadStream* pFontStream,
189 const CFX_WideString* pFaceName);
190 void GetNames(const uint8_t* name_table, CFX_WideStringArray& Names);
191 std::vector<uint16_t> GetCharsets(FXFT_Face pFace) const;
192 void GetUSBCSB(FXFT_Face pFace, uint32_t* USB, uint32_t* CSB);
193 uint32_t GetFlags(FXFT_Face pFace);
194 bool VerifyUnicode(CFX_FontDescriptor* pDesc, FX_WCHAR wcUnicode);
195 bool VerifyUnicode(CFGAS_GEFont* pFont, FX_WCHAR wcUnicode);
196 int32_t IsPartName(const CFX_WideString& Name1, const CFX_WideString& Name2);
197 int32_t MatchFonts(CFX_FontDescriptorInfos& MatchedFonts,
198 uint16_t wCodePage,
199 uint32_t dwFontStyles,
200 const CFX_WideString& FontName,
201 FX_WCHAR wcUnicode = 0xFFFE);
202 int32_t CalcPenalty(CFX_FontDescriptor* pInstalled,
203 uint16_t wCodePage,
204 uint32_t dwFontStyles,
205 const CFX_WideString& FontName,
206 FX_WCHAR wcUnicode = 0xFFFE);
207 FXFT_Face LoadFace(IFX_SeekableReadStream* pFontStream, int32_t iFaceIndex);
208 IFX_SeekableReadStream* CreateFontStream(CFX_FontMapper* pFontMapper,
209 IFX_SystemFontInfo* pSystemFontInfo,
210 uint32_t index);
211 IFX_SeekableReadStream* CreateFontStream(const CFX_ByteString& bsFaceName);
212
213 CFX_FontDescriptors m_InstalledFonts;
214 CFX_MapPtrTemplate<uint32_t, CFX_FontDescriptorInfos*> m_Hash2CandidateList;
215 CFX_MapPtrTemplate<uint32_t, CFX_ArrayTemplate<CFGAS_GEFont*>*> m_Hash2Fonts;
216 CFX_MapPtrTemplate<CFGAS_GEFont*, IFX_SeekableReadStream*> m_IFXFont2FileRead;
217 CFX_MapPtrTemplate<FX_WCHAR, CFGAS_GEFont*> m_FailedUnicodes2Nullptr;
218 CFX_FontSourceEnum_File* const m_pFontSource;
219 };
220 #endif
221
222 #endif // XFA_FGAS_FONT_FGAS_STDFONTMGR_H_
OLDNEW
« no previous file with comments | « xfa/fgas/font/fgas_gefont.cpp ('k') | xfa/fgas/font/fgas_stdfontmgr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698