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

Side by Side Diff: xfa/fgas/font/fgas_font.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/cfgas_fontmgr.cpp ('k') | xfa/fgas/font/fgas_fontutils.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_FONT_H_
8 #define XFA_FGAS_FONT_FGAS_FONT_H_
9
10 #include "core/fxge/fx_font.h"
11 #include "xfa/fgas/crt/fgas_stream.h"
12
13 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
14 #include "xfa/fgas/crt/fgas_memory.h"
15 #include "xfa/fgas/crt/fgas_utils.h"
16 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
17
18 class CFX_FontSourceEnum_File;
19 class CFGAS_GEFont;
20 class CXFA_PDFFontMgr;
21 class IFGAS_FontMgr;
22
23 #define FX_FONTSTYLE_Normal 0x00
24 #define FX_FONTSTYLE_FixedPitch 0x01
25 #define FX_FONTSTYLE_Serif 0x02
26 #define FX_FONTSTYLE_Symbolic 0x04
27 #define FX_FONTSTYLE_Script 0x08
28 #define FX_FONTSTYLE_Italic 0x40
29 #define FX_FONTSTYLE_Bold 0x40000
30 #define FX_FONTSTYLE_BoldItalic (FX_FONTSTYLE_Bold | FX_FONTSTYLE_Italic)
31 #define FX_FONTSTYLE_ExactMatch 0x80000000
32
33 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
34 struct FX_FONTMATCHPARAMS {
35 const FX_WCHAR* pwsFamily;
36 uint32_t dwFontStyles;
37 uint32_t dwUSB;
38 uint32_t dwMatchFlags;
39 FX_WCHAR wUnicode;
40 uint16_t wCodePage;
41 };
42 typedef FX_FONTMATCHPARAMS* FX_LPFONTMATCHPARAMS;
43 typedef FX_FONTMATCHPARAMS const* FX_LPCFONTMATCHPARAMS;
44
45 struct FX_FONTSIGNATURE {
46 uint32_t fsUsb[4];
47 uint32_t fsCsb[2];
48 };
49 inline bool operator==(const FX_FONTSIGNATURE& left,
50 const FX_FONTSIGNATURE& right) {
51 return left.fsUsb[0] == right.fsUsb[0] && left.fsUsb[1] == right.fsUsb[1] &&
52 left.fsUsb[2] == right.fsUsb[2] && left.fsUsb[3] == right.fsUsb[3] &&
53 left.fsCsb[0] == right.fsCsb[0] && left.fsCsb[1] == right.fsCsb[1];
54 }
55
56 struct FX_FONTDESCRIPTOR {
57 FX_WCHAR wsFontFace[32];
58 uint32_t dwFontStyles;
59 uint8_t uCharSet;
60 FX_FONTSIGNATURE FontSignature;
61 };
62
63 typedef CFX_MassArrayTemplate<FX_FONTDESCRIPTOR> CFX_FontDescriptors;
64 inline bool operator==(const FX_FONTDESCRIPTOR& left,
65 const FX_FONTDESCRIPTOR& right) {
66 return left.uCharSet == right.uCharSet &&
67 left.dwFontStyles == right.dwFontStyles &&
68 left.FontSignature == right.FontSignature &&
69 FXSYS_wcscmp(left.wsFontFace, right.wsFontFace) == 0;
70 }
71
72 #define FX_FONTMATCHPARA_MacthStyle 0x01
73 #define FX_FONTMATCHPARA_MacthFamily 0x02
74 #define FX_FONTMATCHPARA_MacthUnicode 0x04
75 typedef void (*FX_LPEnumAllFonts)(CFX_FontDescriptors& fonts,
76 const FX_WCHAR* pwsFaceName,
77 FX_WCHAR wUnicode);
78 FX_LPEnumAllFonts FX_GetDefFontEnumerator();
79 typedef FX_FONTDESCRIPTOR const* (*FX_LPMatchFont)(
80 FX_LPFONTMATCHPARAMS pParams,
81 const CFX_FontDescriptors& fonts);
82 FX_LPMatchFont FX_GetDefFontMatchor();
83
84 class IFGAS_FontMgr {
85 public:
86 virtual ~IFGAS_FontMgr() {}
87
88 static std::unique_ptr<IFGAS_FontMgr> Create(FX_LPEnumAllFonts pEnumerator);
89
90 virtual CFGAS_GEFont* GetDefFontByCodePage(
91 uint16_t wCodePage,
92 uint32_t dwFontStyles,
93 const FX_WCHAR* pszFontFamily = nullptr) = 0;
94 virtual CFGAS_GEFont* GetDefFontByCharset(
95 uint8_t nCharset,
96 uint32_t dwFontStyles,
97 const FX_WCHAR* pszFontFamily = nullptr) = 0;
98 virtual CFGAS_GEFont* GetDefFontByUnicode(
99 FX_WCHAR wUnicode,
100 uint32_t dwFontStyles,
101 const FX_WCHAR* pszFontFamily = nullptr) = 0;
102 virtual CFGAS_GEFont* GetDefFontByLanguage(
103 uint16_t wLanguage,
104 uint32_t dwFontStyles,
105 const FX_WCHAR* pszFontFamily = nullptr) = 0;
106 virtual CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily,
107 uint32_t dwFontStyles,
108 uint16_t wCodePage = 0xFFFF) = 0;
109 virtual CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, int32_t iLength) = 0;
110 virtual CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream,
111 const FX_WCHAR* pszFontAlias = nullptr,
112 uint32_t dwFontStyles = 0,
113 uint16_t wCodePage = 0,
114 bool bSaveStream = false) = 0;
115 virtual CFGAS_GEFont* LoadFont(CFGAS_GEFont* pSrcFont,
116 uint32_t dwFontStyles,
117 uint16_t wCodePage = 0xFFFF) = 0;
118 virtual void ClearFontCache() = 0;
119 virtual void RemoveFont(CFGAS_GEFont* pFont) = 0;
120 };
121
122 #else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
123
124 class IFGAS_FontMgr {
125 public:
126 virtual ~IFGAS_FontMgr() {}
127
128 static std::unique_ptr<IFGAS_FontMgr> Create(
129 CFX_FontSourceEnum_File* pFontEnum);
130
131 virtual CFGAS_GEFont* GetDefFontByCodePage(uint16_t wCodePage,
132 uint32_t dwFontStyles,
133 const FX_WCHAR* pszFontFamily) = 0;
134 virtual CFGAS_GEFont* GetDefFontByCharset(uint8_t nCharset,
135 uint32_t dwFontStyles,
136 const FX_WCHAR* pszFontFamily) = 0;
137 virtual CFGAS_GEFont* GetDefFontByUnicode(FX_WCHAR wUnicode,
138 uint32_t dwFontStyles,
139 const FX_WCHAR* pszFontFamily) = 0;
140 virtual CFGAS_GEFont* GetDefFontByLanguage(uint16_t wLanguage,
141 uint32_t dwFontStyles,
142 const FX_WCHAR* pszFontFamily) = 0;
143 virtual CFGAS_GEFont* GetFontByCodePage(uint16_t wCodePage,
144 uint32_t dwFontStyles,
145 const FX_WCHAR* pszFontFamily) = 0;
146 inline CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily,
147 uint32_t dwFontStyles,
148 uint16_t wCodePage) {
149 return GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily);
150 }
151 virtual CFGAS_GEFont* GetFontByCharset(uint8_t nCharset,
152 uint32_t dwFontStyles,
153 const FX_WCHAR* pszFontFamily) = 0;
154 virtual CFGAS_GEFont* GetFontByUnicode(FX_WCHAR wUnicode,
155 uint32_t dwFontStyles,
156 const FX_WCHAR* pszFontFamily) = 0;
157 virtual CFGAS_GEFont* GetFontByLanguage(uint16_t wLanguage,
158 uint32_t dwFontStyles,
159 const FX_WCHAR* pszFontFamily) = 0;
160 virtual void ClearFontCache() = 0;
161 virtual void RemoveFont(CFGAS_GEFont* pFont) = 0;
162 };
163 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
164
165 #endif // XFA_FGAS_FONT_FGAS_FONT_H_
OLDNEW
« no previous file with comments | « xfa/fgas/font/cfgas_fontmgr.cpp ('k') | xfa/fgas/font/fgas_fontutils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698