OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef CORE_INCLUDE_FXGE_FX_FONT_H_ | 7 #ifndef CORE_INCLUDE_FXGE_FX_FONT_H_ |
8 #define CORE_INCLUDE_FXGE_FX_FONT_H_ | 8 #define CORE_INCLUDE_FXGE_FX_FONT_H_ |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 #define FXFONT_FW_NORMAL 400 | 59 #define FXFONT_FW_NORMAL 400 |
60 #define FXFONT_FW_BOLD 700 | 60 #define FXFONT_FW_BOLD 700 |
61 | 61 |
62 class CFX_Font { | 62 class CFX_Font { |
63 public: | 63 public: |
64 CFX_Font(); | 64 CFX_Font(); |
65 ~CFX_Font(); | 65 ~CFX_Font(); |
66 | 66 |
67 void LoadSubst(const CFX_ByteString& face_name, | 67 void LoadSubst(const CFX_ByteString& face_name, |
68 FX_BOOL bTrueType, | 68 FX_BOOL bTrueType, |
69 FX_DWORD flags, | 69 uint32_t flags, |
70 int weight, | 70 int weight, |
71 int italic_angle, | 71 int italic_angle, |
72 int CharsetCP, | 72 int CharsetCP, |
73 FX_BOOL bVertical = FALSE); | 73 FX_BOOL bVertical = FALSE); |
74 FX_BOOL LoadEmbedded(const uint8_t* data, FX_DWORD size); | 74 FX_BOOL LoadEmbedded(const uint8_t* data, uint32_t size); |
75 FXFT_Face GetFace() const { return m_Face; } | 75 FXFT_Face GetFace() const { return m_Face; } |
76 | 76 |
77 #ifdef PDF_ENABLE_XFA | 77 #ifdef PDF_ENABLE_XFA |
78 FX_BOOL LoadFile(IFX_FileRead* pFile, | 78 FX_BOOL LoadFile(IFX_FileRead* pFile, |
79 int nFaceIndex = 0, | 79 int nFaceIndex = 0, |
80 int* pFaceCount = NULL); | 80 int* pFaceCount = NULL); |
81 | 81 |
82 FX_BOOL LoadClone(const CFX_Font* pFont); | 82 FX_BOOL LoadClone(const CFX_Font* pFont); |
83 CFX_SubstFont* GetSubstFont() const { return m_pSubstFont; } | 83 CFX_SubstFont* GetSubstFont() const { return m_pSubstFont; } |
84 void SetFace(FXFT_Face face) { m_Face = face; } | 84 void SetFace(FXFT_Face face) { m_Face = face; } |
85 void SetSubstFont(CFX_SubstFont* subst) { m_pSubstFont = subst; } | 85 void SetSubstFont(CFX_SubstFont* subst) { m_pSubstFont = subst; } |
86 #else // PDF_ENABLE_XFA | 86 #else // PDF_ENABLE_XFA |
87 const CFX_SubstFont* GetSubstFont() const { return m_pSubstFont; } | 87 const CFX_SubstFont* GetSubstFont() const { return m_pSubstFont; } |
88 #endif // PDF_ENABLE_XFA | 88 #endif // PDF_ENABLE_XFA |
89 | 89 |
90 CFX_PathData* LoadGlyphPath(FX_DWORD glyph_index, int dest_width = 0); | 90 CFX_PathData* LoadGlyphPath(uint32_t glyph_index, int dest_width = 0); |
91 int GetGlyphWidth(FX_DWORD glyph_index); | 91 int GetGlyphWidth(uint32_t glyph_index); |
92 int GetAscent() const; | 92 int GetAscent() const; |
93 int GetDescent() const; | 93 int GetDescent() const; |
94 FX_BOOL GetGlyphBBox(FX_DWORD glyph_index, FX_RECT& bbox); | 94 FX_BOOL GetGlyphBBox(uint32_t glyph_index, FX_RECT& bbox); |
95 FX_BOOL IsItalic() const; | 95 FX_BOOL IsItalic() const; |
96 FX_BOOL IsBold() const; | 96 FX_BOOL IsBold() const; |
97 FX_BOOL IsFixedWidth() const; | 97 FX_BOOL IsFixedWidth() const; |
98 FX_BOOL IsVertical() const { return m_bVertical; } | 98 FX_BOOL IsVertical() const { return m_bVertical; } |
99 CFX_WideString GetPsName() const; | 99 CFX_WideString GetPsName() const; |
100 CFX_ByteString GetFamilyName() const; | 100 CFX_ByteString GetFamilyName() const; |
101 CFX_ByteString GetFaceName() const; | 101 CFX_ByteString GetFaceName() const; |
102 FX_BOOL IsTTFont() const; | 102 FX_BOOL IsTTFont() const; |
103 FX_BOOL GetBBox(FX_RECT& bbox); | 103 FX_BOOL GetBBox(FX_RECT& bbox); |
104 int GetHeight() const; | 104 int GetHeight() const; |
105 int GetULPos() const; | 105 int GetULPos() const; |
106 int GetULthickness() const; | 106 int GetULthickness() const; |
107 int GetMaxAdvanceWidth() const; | 107 int GetMaxAdvanceWidth() const; |
108 FX_BOOL IsEmbedded() const { return m_bEmbedded; } | 108 FX_BOOL IsEmbedded() const { return m_bEmbedded; } |
109 uint8_t* GetSubData() const { return m_pGsubData; } | 109 uint8_t* GetSubData() const { return m_pGsubData; } |
110 void SetSubData(uint8_t* data) { m_pGsubData = data; } | 110 void SetSubData(uint8_t* data) { m_pGsubData = data; } |
111 void* GetPlatformFont() const { return m_pPlatformFont; } | 111 void* GetPlatformFont() const { return m_pPlatformFont; } |
112 void SetPlatformFont(void* font) { m_pPlatformFont = font; } | 112 void SetPlatformFont(void* font) { m_pPlatformFont = font; } |
113 uint8_t* GetFontData() const { return m_pFontData; } | 113 uint8_t* GetFontData() const { return m_pFontData; } |
114 FX_DWORD GetSize() const { return m_dwSize; } | 114 uint32_t GetSize() const { return m_dwSize; } |
115 void AdjustMMParams(int glyph_index, int width, int weight); | 115 void AdjustMMParams(int glyph_index, int width, int weight); |
116 | 116 |
117 private: | 117 private: |
118 void ReleasePlatformResource(); | 118 void ReleasePlatformResource(); |
119 void DeleteFace(); | 119 void DeleteFace(); |
120 | 120 |
121 FXFT_Face m_Face; | 121 FXFT_Face m_Face; |
122 CFX_SubstFont* m_pSubstFont; | 122 CFX_SubstFont* m_pSubstFont; |
123 uint8_t* m_pFontDataAllocation; | 123 uint8_t* m_pFontDataAllocation; |
124 uint8_t* m_pFontData; | 124 uint8_t* m_pFontData; |
125 uint8_t* m_pGsubData; | 125 uint8_t* m_pGsubData; |
126 FX_DWORD m_dwSize; | 126 uint32_t m_dwSize; |
127 CFX_BinaryBuf m_OtfFontData; | 127 CFX_BinaryBuf m_OtfFontData; |
128 void* m_hHandle; | 128 void* m_hHandle; |
129 void* m_pPlatformFont; | 129 void* m_pPlatformFont; |
130 void* m_pPlatformFontCollection; | 130 void* m_pPlatformFontCollection; |
131 void* m_pDwFont; | 131 void* m_pDwFont; |
132 FX_BOOL m_bDwLoaded; | 132 FX_BOOL m_bDwLoaded; |
133 FX_BOOL m_bEmbedded; | 133 FX_BOOL m_bEmbedded; |
134 FX_BOOL m_bVertical; | 134 FX_BOOL m_bVertical; |
135 | 135 |
136 #ifdef PDF_ENABLE_XFA | 136 #ifdef PDF_ENABLE_XFA |
137 | 137 |
138 protected: | 138 protected: |
139 FX_BOOL m_bLogic; | 139 FX_BOOL m_bLogic; |
140 void* m_pOwnedStream; | 140 void* m_pOwnedStream; |
141 | 141 |
142 #endif // PDF_ENABLE_XFA | 142 #endif // PDF_ENABLE_XFA |
143 }; | 143 }; |
144 | 144 |
145 #define ENCODING_INTERNAL 0 | 145 #define ENCODING_INTERNAL 0 |
146 #define ENCODING_UNICODE 1 | 146 #define ENCODING_UNICODE 1 |
147 | 147 |
148 #ifdef PDF_ENABLE_XFA | 148 #ifdef PDF_ENABLE_XFA |
149 #define FXFM_ENC_TAG(a, b, c, d) \ | 149 #define FXFM_ENC_TAG(a, b, c, d) \ |
150 (((FX_DWORD)(a) << 24) | ((FX_DWORD)(b) << 16) | ((FX_DWORD)(c) << 8) | \ | 150 (((uint32_t)(a) << 24) | ((uint32_t)(b) << 16) | ((uint32_t)(c) << 8) | \ |
151 (FX_DWORD)(d)) | 151 (uint32_t)(d)) |
152 #define FXFM_ENCODING_NONE FXFM_ENC_TAG(0, 0, 0, 0) | 152 #define FXFM_ENCODING_NONE FXFM_ENC_TAG(0, 0, 0, 0) |
153 #define FXFM_ENCODING_MS_SYMBOL FXFM_ENC_TAG('s', 'y', 'm', 'b') | 153 #define FXFM_ENCODING_MS_SYMBOL FXFM_ENC_TAG('s', 'y', 'm', 'b') |
154 #define FXFM_ENCODING_UNICODE FXFM_ENC_TAG('u', 'n', 'i', 'c') | 154 #define FXFM_ENCODING_UNICODE FXFM_ENC_TAG('u', 'n', 'i', 'c') |
155 #define FXFM_ENCODING_MS_SJIS FXFM_ENC_TAG('s', 'j', 'i', 's') | 155 #define FXFM_ENCODING_MS_SJIS FXFM_ENC_TAG('s', 'j', 'i', 's') |
156 #define FXFM_ENCODING_MS_GB2312 FXFM_ENC_TAG('g', 'b', ' ', ' ') | 156 #define FXFM_ENCODING_MS_GB2312 FXFM_ENC_TAG('g', 'b', ' ', ' ') |
157 #define FXFM_ENCODING_MS_BIG5 FXFM_ENC_TAG('b', 'i', 'g', '5') | 157 #define FXFM_ENCODING_MS_BIG5 FXFM_ENC_TAG('b', 'i', 'g', '5') |
158 #define FXFM_ENCODING_MS_WANSUNG FXFM_ENC_TAG('w', 'a', 'n', 's') | 158 #define FXFM_ENCODING_MS_WANSUNG FXFM_ENC_TAG('w', 'a', 'n', 's') |
159 #define FXFM_ENCODING_MS_JOHAB FXFM_ENC_TAG('j', 'o', 'h', 'a') | 159 #define FXFM_ENCODING_MS_JOHAB FXFM_ENC_TAG('j', 'o', 'h', 'a') |
160 #define FXFM_ENCODING_ADOBE_STANDARD FXFM_ENC_TAG('A', 'D', 'O', 'B') | 160 #define FXFM_ENCODING_ADOBE_STANDARD FXFM_ENC_TAG('A', 'D', 'O', 'B') |
161 #define FXFM_ENCODING_ADOBE_EXPERT FXFM_ENC_TAG('A', 'D', 'B', 'E') | 161 #define FXFM_ENCODING_ADOBE_EXPERT FXFM_ENC_TAG('A', 'D', 'B', 'E') |
162 #define FXFM_ENCODING_ADOBE_CUSTOM FXFM_ENC_TAG('A', 'D', 'B', 'C') | 162 #define FXFM_ENCODING_ADOBE_CUSTOM FXFM_ENC_TAG('A', 'D', 'B', 'C') |
163 #define FXFM_ENCODING_ADOBE_LATIN_1 FXFM_ENC_TAG('l', 'a', 't', '1') | 163 #define FXFM_ENCODING_ADOBE_LATIN_1 FXFM_ENC_TAG('l', 'a', 't', '1') |
164 #define FXFM_ENCODING_OLD_LATIN_2 FXFM_ENC_TAG('l', 'a', 't', '2') | 164 #define FXFM_ENCODING_OLD_LATIN_2 FXFM_ENC_TAG('l', 'a', 't', '2') |
165 #define FXFM_ENCODING_APPLE_ROMAN FXFM_ENC_TAG('a', 'r', 'm', 'n') | 165 #define FXFM_ENCODING_APPLE_ROMAN FXFM_ENC_TAG('a', 'r', 'm', 'n') |
166 #endif // PDF_ENABLE_XFA | 166 #endif // PDF_ENABLE_XFA |
167 | 167 |
168 class CFX_UnicodeEncoding { | 168 class CFX_UnicodeEncoding { |
169 public: | 169 public: |
170 explicit CFX_UnicodeEncoding(CFX_Font* pFont); | 170 explicit CFX_UnicodeEncoding(CFX_Font* pFont); |
171 virtual ~CFX_UnicodeEncoding(); | 171 virtual ~CFX_UnicodeEncoding(); |
172 | 172 |
173 virtual FX_DWORD GlyphFromCharCode(FX_DWORD charcode); | 173 virtual uint32_t GlyphFromCharCode(uint32_t charcode); |
174 | 174 |
175 protected: | 175 protected: |
176 // Unowned, not nullptr. | 176 // Unowned, not nullptr. |
177 CFX_Font* m_pFont; | 177 CFX_Font* m_pFont; |
178 }; | 178 }; |
179 | 179 |
180 #ifdef PDF_ENABLE_XFA | 180 #ifdef PDF_ENABLE_XFA |
181 class CFX_UnicodeEncodingEx : public CFX_UnicodeEncoding { | 181 class CFX_UnicodeEncodingEx : public CFX_UnicodeEncoding { |
182 public: | 182 public: |
183 CFX_UnicodeEncodingEx(CFX_Font* pFont, FX_DWORD EncodingID); | 183 CFX_UnicodeEncodingEx(CFX_Font* pFont, uint32_t EncodingID); |
184 ~CFX_UnicodeEncodingEx() override; | 184 ~CFX_UnicodeEncodingEx() override; |
185 | 185 |
186 // CFX_UnicodeEncoding: | 186 // CFX_UnicodeEncoding: |
187 FX_DWORD GlyphFromCharCode(FX_DWORD charcode) override; | 187 uint32_t GlyphFromCharCode(uint32_t charcode) override; |
188 | 188 |
189 FX_DWORD CharCodeFromUnicode(FX_WCHAR Unicode) const; | 189 uint32_t CharCodeFromUnicode(FX_WCHAR Unicode) const; |
190 | 190 |
191 private: | 191 private: |
192 FX_DWORD m_nEncodingID; | 192 uint32_t m_nEncodingID; |
193 }; | 193 }; |
194 CFX_UnicodeEncodingEx* FX_CreateFontEncodingEx( | 194 CFX_UnicodeEncodingEx* FX_CreateFontEncodingEx( |
195 CFX_Font* pFont, | 195 CFX_Font* pFont, |
196 FX_DWORD nEncodingID = FXFM_ENCODING_NONE); | 196 uint32_t nEncodingID = FXFM_ENCODING_NONE); |
197 #endif // PDF_ENABLE_XFA | 197 #endif // PDF_ENABLE_XFA |
198 | 198 |
199 #define FXFONT_SUBST_MM 0x01 | 199 #define FXFONT_SUBST_MM 0x01 |
200 #define FXFONT_SUBST_GLYPHPATH 0x04 | 200 #define FXFONT_SUBST_GLYPHPATH 0x04 |
201 #define FXFONT_SUBST_CLEARTYPE 0x08 | 201 #define FXFONT_SUBST_CLEARTYPE 0x08 |
202 #define FXFONT_SUBST_TRANSFORM 0x10 | 202 #define FXFONT_SUBST_TRANSFORM 0x10 |
203 #define FXFONT_SUBST_NONSYMBOL 0x20 | 203 #define FXFONT_SUBST_NONSYMBOL 0x20 |
204 #define FXFONT_SUBST_EXACT 0x40 | 204 #define FXFONT_SUBST_EXACT 0x40 |
205 #define FXFONT_SUBST_STANDARD 0x80 | 205 #define FXFONT_SUBST_STANDARD 0x80 |
206 | 206 |
207 class CFX_SubstFont { | 207 class CFX_SubstFont { |
208 public: | 208 public: |
209 CFX_SubstFont(); | 209 CFX_SubstFont(); |
210 | 210 |
211 void* m_ExtHandle; | 211 void* m_ExtHandle; |
212 | 212 |
213 CFX_ByteString m_Family; | 213 CFX_ByteString m_Family; |
214 | 214 |
215 int m_Charset; | 215 int m_Charset; |
216 | 216 |
217 FX_DWORD m_SubstFlags; | 217 uint32_t m_SubstFlags; |
218 | 218 |
219 int m_Weight; | 219 int m_Weight; |
220 | 220 |
221 int m_ItalicAngle; | 221 int m_ItalicAngle; |
222 | 222 |
223 FX_BOOL m_bSubstOfCJK; | 223 FX_BOOL m_bSubstOfCJK; |
224 | 224 |
225 int m_WeightCJK; | 225 int m_WeightCJK; |
226 | 226 |
227 FX_BOOL m_bItlicCJK; | 227 FX_BOOL m_bItlicCJK; |
(...skipping 14 matching lines...) Expand all Loading... |
242 void InitFTLibrary(); | 242 void InitFTLibrary(); |
243 | 243 |
244 FXFT_Face GetCachedFace(const CFX_ByteString& face_name, | 244 FXFT_Face GetCachedFace(const CFX_ByteString& face_name, |
245 int weight, | 245 int weight, |
246 FX_BOOL bItalic, | 246 FX_BOOL bItalic, |
247 uint8_t*& pFontData); | 247 uint8_t*& pFontData); |
248 FXFT_Face AddCachedFace(const CFX_ByteString& face_name, | 248 FXFT_Face AddCachedFace(const CFX_ByteString& face_name, |
249 int weight, | 249 int weight, |
250 FX_BOOL bItalic, | 250 FX_BOOL bItalic, |
251 uint8_t* pData, | 251 uint8_t* pData, |
252 FX_DWORD size, | 252 uint32_t size, |
253 int face_index); | 253 int face_index); |
254 FXFT_Face GetCachedTTCFace(int ttc_size, | 254 FXFT_Face GetCachedTTCFace(int ttc_size, |
255 FX_DWORD checksum, | 255 uint32_t checksum, |
256 int font_offset, | 256 int font_offset, |
257 uint8_t*& pFontData); | 257 uint8_t*& pFontData); |
258 FXFT_Face AddCachedTTCFace(int ttc_size, | 258 FXFT_Face AddCachedTTCFace(int ttc_size, |
259 FX_DWORD checksum, | 259 uint32_t checksum, |
260 uint8_t* pData, | 260 uint8_t* pData, |
261 FX_DWORD size, | 261 uint32_t size, |
262 int font_offset); | 262 int font_offset); |
263 FXFT_Face GetFileFace(const FX_CHAR* filename, int face_index); | 263 FXFT_Face GetFileFace(const FX_CHAR* filename, int face_index); |
264 FXFT_Face GetFixedFace(const uint8_t* pData, FX_DWORD size, int face_index); | 264 FXFT_Face GetFixedFace(const uint8_t* pData, uint32_t size, int face_index); |
265 void ReleaseFace(FXFT_Face face); | 265 void ReleaseFace(FXFT_Face face); |
266 void SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo); | 266 void SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo); |
267 FXFT_Face FindSubstFont(const CFX_ByteString& face_name, | 267 FXFT_Face FindSubstFont(const CFX_ByteString& face_name, |
268 FX_BOOL bTrueType, | 268 FX_BOOL bTrueType, |
269 FX_DWORD flags, | 269 uint32_t flags, |
270 int weight, | 270 int weight, |
271 int italic_angle, | 271 int italic_angle, |
272 int CharsetCP, | 272 int CharsetCP, |
273 CFX_SubstFont* pSubstFont); | 273 CFX_SubstFont* pSubstFont); |
274 bool GetBuiltinFont(size_t index, const uint8_t** pFontData, FX_DWORD* size); | 274 bool GetBuiltinFont(size_t index, const uint8_t** pFontData, uint32_t* size); |
275 CFX_FontMapper* GetBuiltinMapper() const { return m_pBuiltinMapper.get(); } | 275 CFX_FontMapper* GetBuiltinMapper() const { return m_pBuiltinMapper.get(); } |
276 FXFT_Library GetFTLibrary() const { return m_FTLibrary; } | 276 FXFT_Library GetFTLibrary() const { return m_FTLibrary; } |
277 | 277 |
278 private: | 278 private: |
279 std::unique_ptr<CFX_FontMapper> m_pBuiltinMapper; | 279 std::unique_ptr<CFX_FontMapper> m_pBuiltinMapper; |
280 std::map<CFX_ByteString, CTTFontDesc*> m_FaceMap; | 280 std::map<CFX_ByteString, CTTFontDesc*> m_FaceMap; |
281 FXFT_Library m_FTLibrary; | 281 FXFT_Library m_FTLibrary; |
282 }; | 282 }; |
283 | 283 |
284 class IFX_FontEnumerator { | 284 class IFX_FontEnumerator { |
(...skipping 24 matching lines...) Expand all Loading... |
309 IFX_SystemFontInfo* GetSystemFontInfo() { return m_pFontInfo; } | 309 IFX_SystemFontInfo* GetSystemFontInfo() { return m_pFontInfo; } |
310 void AddInstalledFont(const CFX_ByteString& name, int charset); | 310 void AddInstalledFont(const CFX_ByteString& name, int charset); |
311 void LoadInstalledFonts(); | 311 void LoadInstalledFonts(); |
312 std::vector<CFX_ByteString> m_InstalledTTFonts; | 312 std::vector<CFX_ByteString> m_InstalledTTFonts; |
313 void SetFontEnumerator(IFX_FontEnumerator* pFontEnumerator) { | 313 void SetFontEnumerator(IFX_FontEnumerator* pFontEnumerator) { |
314 m_pFontEnumerator = pFontEnumerator; | 314 m_pFontEnumerator = pFontEnumerator; |
315 } | 315 } |
316 IFX_FontEnumerator* GetFontEnumerator() const { return m_pFontEnumerator; } | 316 IFX_FontEnumerator* GetFontEnumerator() const { return m_pFontEnumerator; } |
317 FXFT_Face FindSubstFont(const CFX_ByteString& face_name, | 317 FXFT_Face FindSubstFont(const CFX_ByteString& face_name, |
318 FX_BOOL bTrueType, | 318 FX_BOOL bTrueType, |
319 FX_DWORD flags, | 319 uint32_t flags, |
320 int weight, | 320 int weight, |
321 int italic_angle, | 321 int italic_angle, |
322 int CharsetCP, | 322 int CharsetCP, |
323 CFX_SubstFont* pSubstFont); | 323 CFX_SubstFont* pSubstFont); |
324 #ifdef PDF_ENABLE_XFA | 324 #ifdef PDF_ENABLE_XFA |
325 FXFT_Face FindSubstFontByUnicode(FX_DWORD dwUnicode, | 325 FXFT_Face FindSubstFontByUnicode(uint32_t dwUnicode, |
326 FX_DWORD flags, | 326 uint32_t flags, |
327 int weight, | 327 int weight, |
328 int italic_angle); | 328 int italic_angle); |
329 #endif // PDF_ENABLE_XFA | 329 #endif // PDF_ENABLE_XFA |
330 FX_BOOL IsBuiltinFace(const FXFT_Face face) const; | 330 FX_BOOL IsBuiltinFace(const FXFT_Face face) const; |
331 int GetFaceSize() const; | 331 int GetFaceSize() const; |
332 CFX_ByteString GetFaceName(int index) const { return m_FaceArray[index]; } | 332 CFX_ByteString GetFaceName(int index) const { return m_FaceArray[index]; } |
333 | 333 |
334 private: | 334 private: |
335 static const size_t MM_FACE_COUNT = 2; | 335 static const size_t MM_FACE_COUNT = 2; |
336 static const size_t FOXIT_FACE_COUNT = 14; | 336 static const size_t FOXIT_FACE_COUNT = 14; |
337 | 337 |
338 CFX_ByteString GetPSNameFromTT(void* hFont); | 338 CFX_ByteString GetPSNameFromTT(void* hFont); |
339 CFX_ByteString MatchInstalledFonts(const CFX_ByteString& norm_name); | 339 CFX_ByteString MatchInstalledFonts(const CFX_ByteString& norm_name); |
340 FXFT_Face UseInternalSubst(CFX_SubstFont* pSubstFont, | 340 FXFT_Face UseInternalSubst(CFX_SubstFont* pSubstFont, |
341 int iBaseFont, | 341 int iBaseFont, |
342 int italic_angle, | 342 int italic_angle, |
343 int weight, | 343 int weight, |
344 int picthfamily); | 344 int picthfamily); |
345 | 345 |
346 FX_BOOL m_bListLoaded; | 346 FX_BOOL m_bListLoaded; |
347 FXFT_Face m_MMFaces[MM_FACE_COUNT]; | 347 FXFT_Face m_MMFaces[MM_FACE_COUNT]; |
348 CFX_ByteString m_LastFamily; | 348 CFX_ByteString m_LastFamily; |
349 CFX_ArrayTemplate<FX_DWORD> m_CharsetArray; | 349 CFX_ArrayTemplate<uint32_t> m_CharsetArray; |
350 std::vector<CFX_ByteString> m_FaceArray; | 350 std::vector<CFX_ByteString> m_FaceArray; |
351 IFX_SystemFontInfo* m_pFontInfo; | 351 IFX_SystemFontInfo* m_pFontInfo; |
352 FXFT_Face m_FoxitFaces[FOXIT_FACE_COUNT]; | 352 FXFT_Face m_FoxitFaces[FOXIT_FACE_COUNT]; |
353 IFX_FontEnumerator* m_pFontEnumerator; | 353 IFX_FontEnumerator* m_pFontEnumerator; |
354 CFX_FontMgr* const m_pFontMgr; | 354 CFX_FontMgr* const m_pFontMgr; |
355 }; | 355 }; |
356 | 356 |
357 class IFX_SystemFontInfo { | 357 class IFX_SystemFontInfo { |
358 public: | 358 public: |
359 static IFX_SystemFontInfo* CreateDefault(const char** pUserPaths); | 359 static IFX_SystemFontInfo* CreateDefault(const char** pUserPaths); |
360 virtual void Release() = 0; | 360 virtual void Release() = 0; |
361 | 361 |
362 virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper) = 0; | 362 virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper) = 0; |
363 virtual void* MapFont(int weight, | 363 virtual void* MapFont(int weight, |
364 FX_BOOL bItalic, | 364 FX_BOOL bItalic, |
365 int charset, | 365 int charset, |
366 int pitch_family, | 366 int pitch_family, |
367 const FX_CHAR* face, | 367 const FX_CHAR* face, |
368 int& iExact) = 0; | 368 int& iExact) = 0; |
369 | 369 |
370 #ifdef PDF_ENABLE_XFA | 370 #ifdef PDF_ENABLE_XFA |
371 virtual void* MapFontByUnicode(FX_DWORD dwUnicode, | 371 virtual void* MapFontByUnicode(uint32_t dwUnicode, |
372 int weight, | 372 int weight, |
373 FX_BOOL bItalic, | 373 FX_BOOL bItalic, |
374 int pitch_family); | 374 int pitch_family); |
375 #endif // PDF_ENABLE_XFA | 375 #endif // PDF_ENABLE_XFA |
376 | 376 |
377 virtual void* GetFont(const FX_CHAR* face) = 0; | 377 virtual void* GetFont(const FX_CHAR* face) = 0; |
378 virtual FX_DWORD GetFontData(void* hFont, | 378 virtual uint32_t GetFontData(void* hFont, |
379 FX_DWORD table, | 379 uint32_t table, |
380 uint8_t* buffer, | 380 uint8_t* buffer, |
381 FX_DWORD size) = 0; | 381 uint32_t size) = 0; |
382 virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) = 0; | 382 virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) = 0; |
383 virtual FX_BOOL GetFontCharset(void* hFont, int& charset) = 0; | 383 virtual FX_BOOL GetFontCharset(void* hFont, int& charset) = 0; |
384 virtual int GetFaceIndex(void* hFont); | 384 virtual int GetFaceIndex(void* hFont); |
385 virtual void DeleteFont(void* hFont) = 0; | 385 virtual void DeleteFont(void* hFont) = 0; |
386 virtual void* RetainFont(void* hFont); | 386 virtual void* RetainFont(void* hFont); |
387 | 387 |
388 protected: | 388 protected: |
389 virtual ~IFX_SystemFontInfo() {} | 389 virtual ~IFX_SystemFontInfo() {} |
390 }; | 390 }; |
391 | 391 |
392 class CFX_FolderFontInfo : public IFX_SystemFontInfo { | 392 class CFX_FolderFontInfo : public IFX_SystemFontInfo { |
393 public: | 393 public: |
394 CFX_FolderFontInfo(); | 394 CFX_FolderFontInfo(); |
395 ~CFX_FolderFontInfo() override; | 395 ~CFX_FolderFontInfo() override; |
396 void AddPath(const CFX_ByteStringC& path); | 396 void AddPath(const CFX_ByteStringC& path); |
397 | 397 |
398 // IFX_SytemFontInfo: | 398 // IFX_SytemFontInfo: |
399 void Release() override; | 399 void Release() override; |
400 FX_BOOL EnumFontList(CFX_FontMapper* pMapper) override; | 400 FX_BOOL EnumFontList(CFX_FontMapper* pMapper) override; |
401 void* MapFont(int weight, | 401 void* MapFont(int weight, |
402 FX_BOOL bItalic, | 402 FX_BOOL bItalic, |
403 int charset, | 403 int charset, |
404 int pitch_family, | 404 int pitch_family, |
405 const FX_CHAR* face, | 405 const FX_CHAR* face, |
406 int& bExact) override; | 406 int& bExact) override; |
407 #ifdef PDF_ENABLE_XFA | 407 #ifdef PDF_ENABLE_XFA |
408 void* MapFontByUnicode(FX_DWORD dwUnicode, | 408 void* MapFontByUnicode(uint32_t dwUnicode, |
409 int weight, | 409 int weight, |
410 FX_BOOL bItalic, | 410 FX_BOOL bItalic, |
411 int pitch_family) override; | 411 int pitch_family) override; |
412 #endif // PDF_ENABLE_XFA | 412 #endif // PDF_ENABLE_XFA |
413 void* GetFont(const FX_CHAR* face) override; | 413 void* GetFont(const FX_CHAR* face) override; |
414 FX_DWORD GetFontData(void* hFont, | 414 uint32_t GetFontData(void* hFont, |
415 FX_DWORD table, | 415 uint32_t table, |
416 uint8_t* buffer, | 416 uint8_t* buffer, |
417 FX_DWORD size) override; | 417 uint32_t size) override; |
418 void DeleteFont(void* hFont) override; | 418 void DeleteFont(void* hFont) override; |
419 FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) override; | 419 FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) override; |
420 FX_BOOL GetFontCharset(void* hFont, int& charset) override; | 420 FX_BOOL GetFontCharset(void* hFont, int& charset) override; |
421 | 421 |
422 protected: | 422 protected: |
423 void ScanPath(const CFX_ByteString& path); | 423 void ScanPath(const CFX_ByteString& path); |
424 void ScanFile(const CFX_ByteString& path); | 424 void ScanFile(const CFX_ByteString& path); |
425 void ReportFace(const CFX_ByteString& path, | 425 void ReportFace(const CFX_ByteString& path, |
426 FXSYS_FILE* pFile, | 426 FXSYS_FILE* pFile, |
427 FX_DWORD filesize, | 427 uint32_t filesize, |
428 FX_DWORD offset); | 428 uint32_t offset); |
429 void* GetSubstFont(const CFX_ByteString& face); | 429 void* GetSubstFont(const CFX_ByteString& face); |
430 void* FindFont(int weight, | 430 void* FindFont(int weight, |
431 FX_BOOL bItalic, | 431 FX_BOOL bItalic, |
432 int charset, | 432 int charset, |
433 int pitch_family, | 433 int pitch_family, |
434 const FX_CHAR* family, | 434 const FX_CHAR* family, |
435 FX_BOOL bMatchName); | 435 FX_BOOL bMatchName); |
436 | 436 |
437 std::map<CFX_ByteString, CFX_FontFaceInfo*> m_FontList; | 437 std::map<CFX_ByteString, CFX_FontFaceInfo*> m_FontList; |
438 std::vector<CFX_ByteString> m_PathList; | 438 std::vector<CFX_ByteString> m_PathList; |
439 CFX_FontMapper* m_pMapper; | 439 CFX_FontMapper* m_pMapper; |
440 }; | 440 }; |
441 | 441 |
442 class CFX_CountedFaceCache { | 442 class CFX_CountedFaceCache { |
443 public: | 443 public: |
444 CFX_FaceCache* m_Obj; | 444 CFX_FaceCache* m_Obj; |
445 FX_DWORD m_nCount; | 445 uint32_t m_nCount; |
446 }; | 446 }; |
447 | 447 |
448 class CFX_FontCache { | 448 class CFX_FontCache { |
449 public: | 449 public: |
450 CFX_FontCache(); | 450 CFX_FontCache(); |
451 ~CFX_FontCache(); | 451 ~CFX_FontCache(); |
452 CFX_FaceCache* GetCachedFace(CFX_Font* pFont); | 452 CFX_FaceCache* GetCachedFace(CFX_Font* pFont); |
453 void ReleaseCachedFace(CFX_Font* pFont); | 453 void ReleaseCachedFace(CFX_Font* pFont); |
454 void FreeCache(FX_BOOL bRelease = FALSE); | 454 void FreeCache(FX_BOOL bRelease = FALSE); |
455 | 455 |
(...skipping 17 matching lines...) Expand all Loading... |
473 public: | 473 public: |
474 int m_Top; | 474 int m_Top; |
475 int m_Left; | 475 int m_Left; |
476 CFX_DIBitmap m_Bitmap; | 476 CFX_DIBitmap m_Bitmap; |
477 }; | 477 }; |
478 class CFX_FaceCache { | 478 class CFX_FaceCache { |
479 public: | 479 public: |
480 explicit CFX_FaceCache(FXFT_Face face); | 480 explicit CFX_FaceCache(FXFT_Face face); |
481 ~CFX_FaceCache(); | 481 ~CFX_FaceCache(); |
482 const CFX_GlyphBitmap* LoadGlyphBitmap(CFX_Font* pFont, | 482 const CFX_GlyphBitmap* LoadGlyphBitmap(CFX_Font* pFont, |
483 FX_DWORD glyph_index, | 483 uint32_t glyph_index, |
484 FX_BOOL bFontStyle, | 484 FX_BOOL bFontStyle, |
485 const CFX_Matrix* pMatrix, | 485 const CFX_Matrix* pMatrix, |
486 int dest_width, | 486 int dest_width, |
487 int anti_alias, | 487 int anti_alias, |
488 int& text_flags); | 488 int& text_flags); |
489 const CFX_PathData* LoadGlyphPath(CFX_Font* pFont, | 489 const CFX_PathData* LoadGlyphPath(CFX_Font* pFont, |
490 FX_DWORD glyph_index, | 490 uint32_t glyph_index, |
491 int dest_width); | 491 int dest_width); |
492 | 492 |
493 private: | 493 private: |
494 CFX_GlyphBitmap* RenderGlyph(CFX_Font* pFont, | 494 CFX_GlyphBitmap* RenderGlyph(CFX_Font* pFont, |
495 FX_DWORD glyph_index, | 495 uint32_t glyph_index, |
496 FX_BOOL bFontStyle, | 496 FX_BOOL bFontStyle, |
497 const CFX_Matrix* pMatrix, | 497 const CFX_Matrix* pMatrix, |
498 int dest_width, | 498 int dest_width, |
499 int anti_alias); | 499 int anti_alias); |
500 CFX_GlyphBitmap* RenderGlyph_Nativetext(CFX_Font* pFont, | 500 CFX_GlyphBitmap* RenderGlyph_Nativetext(CFX_Font* pFont, |
501 FX_DWORD glyph_index, | 501 uint32_t glyph_index, |
502 const CFX_Matrix* pMatrix, | 502 const CFX_Matrix* pMatrix, |
503 int dest_width, | 503 int dest_width, |
504 int anti_alias); | 504 int anti_alias); |
505 CFX_GlyphBitmap* LookUpGlyphBitmap(CFX_Font* pFont, | 505 CFX_GlyphBitmap* LookUpGlyphBitmap(CFX_Font* pFont, |
506 const CFX_Matrix* pMatrix, | 506 const CFX_Matrix* pMatrix, |
507 CFX_ByteStringC& FaceGlyphsKey, | 507 CFX_ByteStringC& FaceGlyphsKey, |
508 FX_DWORD glyph_index, | 508 uint32_t glyph_index, |
509 FX_BOOL bFontStyle, | 509 FX_BOOL bFontStyle, |
510 int dest_width, | 510 int dest_width, |
511 int anti_alias); | 511 int anti_alias); |
512 void InitPlatform(); | 512 void InitPlatform(); |
513 void DestroyPlatform(); | 513 void DestroyPlatform(); |
514 | 514 |
515 FXFT_Face const m_Face; | 515 FXFT_Face const m_Face; |
516 std::map<CFX_ByteString, CFX_SizeGlyphCache*> m_SizeMap; | 516 std::map<CFX_ByteString, CFX_SizeGlyphCache*> m_SizeMap; |
517 std::map<FX_DWORD, CFX_PathData*> m_PathMap; | 517 std::map<uint32_t, CFX_PathData*> m_PathMap; |
518 CFX_DIBitmap* m_pBitmap; | 518 CFX_DIBitmap* m_pBitmap; |
519 }; | 519 }; |
520 | 520 |
521 struct FXTEXT_GLYPHPOS { | 521 struct FXTEXT_GLYPHPOS { |
522 const CFX_GlyphBitmap* m_pGlyph; | 522 const CFX_GlyphBitmap* m_pGlyph; |
523 int m_OriginX; | 523 int m_OriginX; |
524 int m_OriginY; | 524 int m_OriginY; |
525 FX_FLOAT m_fOriginX; | 525 FX_FLOAT m_fOriginX; |
526 FX_FLOAT m_fOriginY; | 526 FX_FLOAT m_fOriginY; |
527 }; | 527 }; |
528 | 528 |
529 FX_RECT FXGE_GetGlyphsBBox(FXTEXT_GLYPHPOS* pGlyphAndPos, | 529 FX_RECT FXGE_GetGlyphsBBox(FXTEXT_GLYPHPOS* pGlyphAndPos, |
530 int nChars, | 530 int nChars, |
531 int anti_alias, | 531 int anti_alias, |
532 FX_FLOAT retinaScaleX = 1.0f, | 532 FX_FLOAT retinaScaleX = 1.0f, |
533 FX_FLOAT retinaScaleY = 1.0f); | 533 FX_FLOAT retinaScaleY = 1.0f); |
534 | 534 |
535 class IFX_GSUBTable { | 535 class IFX_GSUBTable { |
536 public: | 536 public: |
537 static IFX_GSUBTable* Create(CFX_Font* pFont); | 537 static IFX_GSUBTable* Create(CFX_Font* pFont); |
538 virtual FX_BOOL GetVerticalGlyph(FX_DWORD glyphnum, FX_DWORD* vglyphnum) = 0; | 538 virtual FX_BOOL GetVerticalGlyph(uint32_t glyphnum, uint32_t* vglyphnum) = 0; |
539 | 539 |
540 protected: | 540 protected: |
541 virtual ~IFX_GSUBTable() {} | 541 virtual ~IFX_GSUBTable() {} |
542 }; | 542 }; |
543 | 543 |
544 CFX_ByteString GetNameFromTT(const uint8_t* name_table, | 544 CFX_ByteString GetNameFromTT(const uint8_t* name_table, |
545 FX_DWORD name_table_size, | 545 uint32_t name_table_size, |
546 FX_DWORD name); | 546 uint32_t name); |
547 | 547 |
548 int PDF_GetStandardFontName(CFX_ByteString* name); | 548 int PDF_GetStandardFontName(CFX_ByteString* name); |
549 | 549 |
550 #endif // CORE_INCLUDE_FXGE_FX_FONT_H_ | 550 #endif // CORE_INCLUDE_FXGE_FX_FONT_H_ |
OLD | NEW |