OLD | NEW |
| (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 CORE_INCLUDE_FXGE_FX_FONT_H_ | |
8 #define CORE_INCLUDE_FXGE_FX_FONT_H_ | |
9 | |
10 #include <map> | |
11 #include <memory> | |
12 #include <vector> | |
13 | |
14 #include "core/fxcrt/include/fx_system.h" | |
15 #include "core/include/fxge/fx_dib.h" | |
16 #include "core/include/fxge/fx_freetype.h" | |
17 | |
18 typedef struct FT_FaceRec_* FXFT_Face; | |
19 typedef void* FXFT_Library; | |
20 | |
21 class CFX_FaceCache; | |
22 class CFX_FontFaceInfo; | |
23 class CFX_FontMapper; | |
24 class CFX_PathData; | |
25 class CFX_SizeGlyphCache; | |
26 class CFX_SubstFont; | |
27 class CTTFontDesc; | |
28 class IFX_SystemFontInfo; | |
29 | |
30 #ifdef _SKIA_SUPPORT_ | |
31 class SkTypeface; | |
32 | |
33 using CFX_TypeFace = SkTypeface; | |
34 #endif | |
35 | |
36 #define FXFONT_FIXED_PITCH 0x01 | |
37 #define FXFONT_SERIF 0x02 | |
38 #define FXFONT_SYMBOLIC 0x04 | |
39 #define FXFONT_SCRIPT 0x08 | |
40 #define FXFONT_ITALIC 0x40 | |
41 #define FXFONT_BOLD 0x40000 | |
42 #define FXFONT_USEEXTERNATTR 0x80000 | |
43 #define FXFONT_CIDFONT 0x100000 | |
44 #ifdef PDF_ENABLE_XFA | |
45 #define FXFONT_EXACTMATCH 0x80000000 | |
46 #endif // PDF_ENABLE_XFA | |
47 #define FXFONT_ANSI_CHARSET 0 | |
48 #define FXFONT_DEFAULT_CHARSET 1 | |
49 #define FXFONT_SYMBOL_CHARSET 2 | |
50 #define FXFONT_SHIFTJIS_CHARSET 128 | |
51 #define FXFONT_HANGEUL_CHARSET 129 | |
52 #define FXFONT_GB2312_CHARSET 134 | |
53 #define FXFONT_CHINESEBIG5_CHARSET 136 | |
54 #define FXFONT_THAI_CHARSET 222 | |
55 #define FXFONT_EASTEUROPE_CHARSET 238 | |
56 #define FXFONT_RUSSIAN_CHARSET 204 | |
57 #define FXFONT_GREEK_CHARSET 161 | |
58 #define FXFONT_TURKISH_CHARSET 162 | |
59 #define FXFONT_HEBREW_CHARSET 177 | |
60 #define FXFONT_ARABIC_CHARSET 178 | |
61 #define FXFONT_BALTIC_CHARSET 186 | |
62 #define FXFONT_FF_FIXEDPITCH 1 | |
63 #define FXFONT_FF_ROMAN (1 << 4) | |
64 #define FXFONT_FF_SCRIPT (4 << 4) | |
65 #define FXFONT_FW_NORMAL 400 | |
66 #define FXFONT_FW_BOLD 700 | |
67 | |
68 class CFX_Font { | |
69 public: | |
70 CFX_Font(); | |
71 ~CFX_Font(); | |
72 | |
73 void LoadSubst(const CFX_ByteString& face_name, | |
74 FX_BOOL bTrueType, | |
75 uint32_t flags, | |
76 int weight, | |
77 int italic_angle, | |
78 int CharsetCP, | |
79 FX_BOOL bVertical = FALSE); | |
80 FX_BOOL LoadEmbedded(const uint8_t* data, uint32_t size); | |
81 FXFT_Face GetFace() const { return m_Face; } | |
82 | |
83 #ifdef PDF_ENABLE_XFA | |
84 FX_BOOL LoadFile(IFX_FileRead* pFile, | |
85 int nFaceIndex = 0, | |
86 int* pFaceCount = NULL); | |
87 | |
88 FX_BOOL LoadClone(const CFX_Font* pFont); | |
89 CFX_SubstFont* GetSubstFont() const { return m_pSubstFont; } | |
90 void SetFace(FXFT_Face face) { m_Face = face; } | |
91 void SetSubstFont(CFX_SubstFont* subst) { m_pSubstFont = subst; } | |
92 #else // PDF_ENABLE_XFA | |
93 const CFX_SubstFont* GetSubstFont() const { return m_pSubstFont; } | |
94 #endif // PDF_ENABLE_XFA | |
95 | |
96 CFX_PathData* LoadGlyphPath(uint32_t glyph_index, int dest_width = 0); | |
97 int GetGlyphWidth(uint32_t glyph_index); | |
98 int GetAscent() const; | |
99 int GetDescent() const; | |
100 FX_BOOL GetGlyphBBox(uint32_t glyph_index, FX_RECT& bbox); | |
101 FX_BOOL IsItalic() const; | |
102 FX_BOOL IsBold() const; | |
103 FX_BOOL IsFixedWidth() const; | |
104 FX_BOOL IsVertical() const { return m_bVertical; } | |
105 CFX_WideString GetPsName() const; | |
106 CFX_ByteString GetFamilyName() const; | |
107 CFX_ByteString GetFaceName() const; | |
108 FX_BOOL IsTTFont() const; | |
109 FX_BOOL GetBBox(FX_RECT& bbox); | |
110 int GetHeight() const; | |
111 int GetULPos() const; | |
112 int GetULthickness() const; | |
113 int GetMaxAdvanceWidth() const; | |
114 FX_BOOL IsEmbedded() const { return m_bEmbedded; } | |
115 uint8_t* GetSubData() const { return m_pGsubData; } | |
116 void SetSubData(uint8_t* data) { m_pGsubData = data; } | |
117 void* GetPlatformFont() const { return m_pPlatformFont; } | |
118 void SetPlatformFont(void* font) { m_pPlatformFont = font; } | |
119 uint8_t* GetFontData() const { return m_pFontData; } | |
120 uint32_t GetSize() const { return m_dwSize; } | |
121 void AdjustMMParams(int glyph_index, int width, int weight); | |
122 | |
123 private: | |
124 void ReleasePlatformResource(); | |
125 void DeleteFace(); | |
126 | |
127 FXFT_Face m_Face; | |
128 CFX_SubstFont* m_pSubstFont; | |
129 uint8_t* m_pFontDataAllocation; | |
130 uint8_t* m_pFontData; | |
131 uint8_t* m_pGsubData; | |
132 uint32_t m_dwSize; | |
133 CFX_BinaryBuf m_OtfFontData; | |
134 void* m_hHandle; | |
135 void* m_pPlatformFont; | |
136 void* m_pPlatformFontCollection; | |
137 void* m_pDwFont; | |
138 FX_BOOL m_bDwLoaded; | |
139 FX_BOOL m_bEmbedded; | |
140 FX_BOOL m_bVertical; | |
141 | |
142 #ifdef PDF_ENABLE_XFA | |
143 | |
144 protected: | |
145 FX_BOOL m_bLogic; | |
146 void* m_pOwnedStream; | |
147 | |
148 #endif // PDF_ENABLE_XFA | |
149 }; | |
150 | |
151 #define ENCODING_INTERNAL 0 | |
152 #define ENCODING_UNICODE 1 | |
153 | |
154 #ifdef PDF_ENABLE_XFA | |
155 #define FXFM_ENC_TAG(a, b, c, d) \ | |
156 (((uint32_t)(a) << 24) | ((uint32_t)(b) << 16) | ((uint32_t)(c) << 8) | \ | |
157 (uint32_t)(d)) | |
158 #define FXFM_ENCODING_NONE FXFM_ENC_TAG(0, 0, 0, 0) | |
159 #define FXFM_ENCODING_MS_SYMBOL FXFM_ENC_TAG('s', 'y', 'm', 'b') | |
160 #define FXFM_ENCODING_UNICODE FXFM_ENC_TAG('u', 'n', 'i', 'c') | |
161 #define FXFM_ENCODING_MS_SJIS FXFM_ENC_TAG('s', 'j', 'i', 's') | |
162 #define FXFM_ENCODING_MS_GB2312 FXFM_ENC_TAG('g', 'b', ' ', ' ') | |
163 #define FXFM_ENCODING_MS_BIG5 FXFM_ENC_TAG('b', 'i', 'g', '5') | |
164 #define FXFM_ENCODING_MS_WANSUNG FXFM_ENC_TAG('w', 'a', 'n', 's') | |
165 #define FXFM_ENCODING_MS_JOHAB FXFM_ENC_TAG('j', 'o', 'h', 'a') | |
166 #define FXFM_ENCODING_ADOBE_STANDARD FXFM_ENC_TAG('A', 'D', 'O', 'B') | |
167 #define FXFM_ENCODING_ADOBE_EXPERT FXFM_ENC_TAG('A', 'D', 'B', 'E') | |
168 #define FXFM_ENCODING_ADOBE_CUSTOM FXFM_ENC_TAG('A', 'D', 'B', 'C') | |
169 #define FXFM_ENCODING_ADOBE_LATIN_1 FXFM_ENC_TAG('l', 'a', 't', '1') | |
170 #define FXFM_ENCODING_OLD_LATIN_2 FXFM_ENC_TAG('l', 'a', 't', '2') | |
171 #define FXFM_ENCODING_APPLE_ROMAN FXFM_ENC_TAG('a', 'r', 'm', 'n') | |
172 #endif // PDF_ENABLE_XFA | |
173 | |
174 class CFX_UnicodeEncoding { | |
175 public: | |
176 explicit CFX_UnicodeEncoding(CFX_Font* pFont); | |
177 virtual ~CFX_UnicodeEncoding(); | |
178 | |
179 virtual uint32_t GlyphFromCharCode(uint32_t charcode); | |
180 | |
181 protected: | |
182 // Unowned, not nullptr. | |
183 CFX_Font* m_pFont; | |
184 }; | |
185 | |
186 #ifdef PDF_ENABLE_XFA | |
187 class CFX_UnicodeEncodingEx : public CFX_UnicodeEncoding { | |
188 public: | |
189 CFX_UnicodeEncodingEx(CFX_Font* pFont, uint32_t EncodingID); | |
190 ~CFX_UnicodeEncodingEx() override; | |
191 | |
192 // CFX_UnicodeEncoding: | |
193 uint32_t GlyphFromCharCode(uint32_t charcode) override; | |
194 | |
195 uint32_t CharCodeFromUnicode(FX_WCHAR Unicode) const; | |
196 | |
197 private: | |
198 uint32_t m_nEncodingID; | |
199 }; | |
200 CFX_UnicodeEncodingEx* FX_CreateFontEncodingEx( | |
201 CFX_Font* pFont, | |
202 uint32_t nEncodingID = FXFM_ENCODING_NONE); | |
203 #endif // PDF_ENABLE_XFA | |
204 | |
205 #define FXFONT_SUBST_MM 0x01 | |
206 #define FXFONT_SUBST_GLYPHPATH 0x04 | |
207 #define FXFONT_SUBST_CLEARTYPE 0x08 | |
208 #define FXFONT_SUBST_TRANSFORM 0x10 | |
209 #define FXFONT_SUBST_NONSYMBOL 0x20 | |
210 #define FXFONT_SUBST_EXACT 0x40 | |
211 #define FXFONT_SUBST_STANDARD 0x80 | |
212 | |
213 class CFX_SubstFont { | |
214 public: | |
215 CFX_SubstFont(); | |
216 | |
217 void* m_ExtHandle; | |
218 | |
219 CFX_ByteString m_Family; | |
220 | |
221 int m_Charset; | |
222 | |
223 uint32_t m_SubstFlags; | |
224 | |
225 int m_Weight; | |
226 | |
227 int m_ItalicAngle; | |
228 | |
229 FX_BOOL m_bSubstOfCJK; | |
230 | |
231 int m_WeightCJK; | |
232 | |
233 FX_BOOL m_bItlicCJK; | |
234 }; | |
235 #define FX_FONT_FLAG_SERIF 0x01 | |
236 #define FX_FONT_FLAG_FIXEDPITCH 0x02 | |
237 #define FX_FONT_FLAG_ITALIC 0x04 | |
238 #define FX_FONT_FLAG_BOLD 0x08 | |
239 #define FX_FONT_FLAG_SYMBOLIC_SYMBOL 0x10 | |
240 #define FX_FONT_FLAG_SYMBOLIC_DINGBATS 0x20 | |
241 #define FX_FONT_FLAG_MULTIPLEMASTER 0x40 | |
242 | |
243 class CFX_FontMgr { | |
244 public: | |
245 CFX_FontMgr(); | |
246 ~CFX_FontMgr(); | |
247 | |
248 void InitFTLibrary(); | |
249 | |
250 FXFT_Face GetCachedFace(const CFX_ByteString& face_name, | |
251 int weight, | |
252 FX_BOOL bItalic, | |
253 uint8_t*& pFontData); | |
254 FXFT_Face AddCachedFace(const CFX_ByteString& face_name, | |
255 int weight, | |
256 FX_BOOL bItalic, | |
257 uint8_t* pData, | |
258 uint32_t size, | |
259 int face_index); | |
260 FXFT_Face GetCachedTTCFace(int ttc_size, | |
261 uint32_t checksum, | |
262 int font_offset, | |
263 uint8_t*& pFontData); | |
264 FXFT_Face AddCachedTTCFace(int ttc_size, | |
265 uint32_t checksum, | |
266 uint8_t* pData, | |
267 uint32_t size, | |
268 int font_offset); | |
269 FXFT_Face GetFileFace(const FX_CHAR* filename, int face_index); | |
270 FXFT_Face GetFixedFace(const uint8_t* pData, uint32_t size, int face_index); | |
271 void ReleaseFace(FXFT_Face face); | |
272 void SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo); | |
273 FXFT_Face FindSubstFont(const CFX_ByteString& face_name, | |
274 FX_BOOL bTrueType, | |
275 uint32_t flags, | |
276 int weight, | |
277 int italic_angle, | |
278 int CharsetCP, | |
279 CFX_SubstFont* pSubstFont); | |
280 bool GetBuiltinFont(size_t index, const uint8_t** pFontData, uint32_t* size); | |
281 CFX_FontMapper* GetBuiltinMapper() const { return m_pBuiltinMapper.get(); } | |
282 FXFT_Library GetFTLibrary() const { return m_FTLibrary; } | |
283 | |
284 private: | |
285 std::unique_ptr<CFX_FontMapper> m_pBuiltinMapper; | |
286 std::map<CFX_ByteString, CTTFontDesc*> m_FaceMap; | |
287 FXFT_Library m_FTLibrary; | |
288 }; | |
289 | |
290 class IFX_FontEnumerator { | |
291 public: | |
292 virtual void HitFont() = 0; | |
293 | |
294 virtual void Finish() = 0; | |
295 | |
296 protected: | |
297 virtual ~IFX_FontEnumerator() {} | |
298 }; | |
299 | |
300 class IFX_AdditionalFontEnum { | |
301 public: | |
302 virtual int CountFiles() = 0; | |
303 virtual IFX_FileStream* GetFontFile(int index) = 0; | |
304 | |
305 protected: | |
306 virtual ~IFX_AdditionalFontEnum() {} | |
307 }; | |
308 | |
309 class CFX_FontMapper { | |
310 public: | |
311 explicit CFX_FontMapper(CFX_FontMgr* mgr); | |
312 ~CFX_FontMapper(); | |
313 | |
314 void SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo); | |
315 IFX_SystemFontInfo* GetSystemFontInfo() { return m_pFontInfo; } | |
316 void AddInstalledFont(const CFX_ByteString& name, int charset); | |
317 void LoadInstalledFonts(); | |
318 std::vector<CFX_ByteString> m_InstalledTTFonts; | |
319 void SetFontEnumerator(IFX_FontEnumerator* pFontEnumerator) { | |
320 m_pFontEnumerator = pFontEnumerator; | |
321 } | |
322 IFX_FontEnumerator* GetFontEnumerator() const { return m_pFontEnumerator; } | |
323 FXFT_Face FindSubstFont(const CFX_ByteString& face_name, | |
324 FX_BOOL bTrueType, | |
325 uint32_t flags, | |
326 int weight, | |
327 int italic_angle, | |
328 int CharsetCP, | |
329 CFX_SubstFont* pSubstFont); | |
330 #ifdef PDF_ENABLE_XFA | |
331 FXFT_Face FindSubstFontByUnicode(uint32_t dwUnicode, | |
332 uint32_t flags, | |
333 int weight, | |
334 int italic_angle); | |
335 #endif // PDF_ENABLE_XFA | |
336 FX_BOOL IsBuiltinFace(const FXFT_Face face) const; | |
337 int GetFaceSize() const; | |
338 CFX_ByteString GetFaceName(int index) const { return m_FaceArray[index]; } | |
339 | |
340 private: | |
341 static const size_t MM_FACE_COUNT = 2; | |
342 static const size_t FOXIT_FACE_COUNT = 14; | |
343 | |
344 CFX_ByteString GetPSNameFromTT(void* hFont); | |
345 CFX_ByteString MatchInstalledFonts(const CFX_ByteString& norm_name); | |
346 FXFT_Face UseInternalSubst(CFX_SubstFont* pSubstFont, | |
347 int iBaseFont, | |
348 int italic_angle, | |
349 int weight, | |
350 int picthfamily); | |
351 | |
352 FX_BOOL m_bListLoaded; | |
353 FXFT_Face m_MMFaces[MM_FACE_COUNT]; | |
354 CFX_ByteString m_LastFamily; | |
355 CFX_ArrayTemplate<uint32_t> m_CharsetArray; | |
356 std::vector<CFX_ByteString> m_FaceArray; | |
357 IFX_SystemFontInfo* m_pFontInfo; | |
358 FXFT_Face m_FoxitFaces[FOXIT_FACE_COUNT]; | |
359 IFX_FontEnumerator* m_pFontEnumerator; | |
360 CFX_FontMgr* const m_pFontMgr; | |
361 }; | |
362 | |
363 class IFX_SystemFontInfo { | |
364 public: | |
365 static IFX_SystemFontInfo* CreateDefault(const char** pUserPaths); | |
366 virtual void Release() = 0; | |
367 | |
368 virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper) = 0; | |
369 virtual void* MapFont(int weight, | |
370 FX_BOOL bItalic, | |
371 int charset, | |
372 int pitch_family, | |
373 const FX_CHAR* face, | |
374 int& iExact) = 0; | |
375 | |
376 #ifdef PDF_ENABLE_XFA | |
377 virtual void* MapFontByUnicode(uint32_t dwUnicode, | |
378 int weight, | |
379 FX_BOOL bItalic, | |
380 int pitch_family); | |
381 #endif // PDF_ENABLE_XFA | |
382 | |
383 virtual void* GetFont(const FX_CHAR* face) = 0; | |
384 virtual uint32_t GetFontData(void* hFont, | |
385 uint32_t table, | |
386 uint8_t* buffer, | |
387 uint32_t size) = 0; | |
388 virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) = 0; | |
389 virtual FX_BOOL GetFontCharset(void* hFont, int& charset) = 0; | |
390 virtual int GetFaceIndex(void* hFont); | |
391 virtual void DeleteFont(void* hFont) = 0; | |
392 virtual void* RetainFont(void* hFont); | |
393 | |
394 protected: | |
395 virtual ~IFX_SystemFontInfo() {} | |
396 }; | |
397 | |
398 class CFX_FolderFontInfo : public IFX_SystemFontInfo { | |
399 public: | |
400 CFX_FolderFontInfo(); | |
401 ~CFX_FolderFontInfo() override; | |
402 void AddPath(const CFX_ByteStringC& path); | |
403 | |
404 // IFX_SytemFontInfo: | |
405 void Release() override; | |
406 FX_BOOL EnumFontList(CFX_FontMapper* pMapper) override; | |
407 void* MapFont(int weight, | |
408 FX_BOOL bItalic, | |
409 int charset, | |
410 int pitch_family, | |
411 const FX_CHAR* face, | |
412 int& bExact) override; | |
413 #ifdef PDF_ENABLE_XFA | |
414 void* MapFontByUnicode(uint32_t dwUnicode, | |
415 int weight, | |
416 FX_BOOL bItalic, | |
417 int pitch_family) override; | |
418 #endif // PDF_ENABLE_XFA | |
419 void* GetFont(const FX_CHAR* face) override; | |
420 uint32_t GetFontData(void* hFont, | |
421 uint32_t table, | |
422 uint8_t* buffer, | |
423 uint32_t size) override; | |
424 void DeleteFont(void* hFont) override; | |
425 FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) override; | |
426 FX_BOOL GetFontCharset(void* hFont, int& charset) override; | |
427 | |
428 protected: | |
429 void ScanPath(const CFX_ByteString& path); | |
430 void ScanFile(const CFX_ByteString& path); | |
431 void ReportFace(const CFX_ByteString& path, | |
432 FXSYS_FILE* pFile, | |
433 uint32_t filesize, | |
434 uint32_t offset); | |
435 void* GetSubstFont(const CFX_ByteString& face); | |
436 void* FindFont(int weight, | |
437 FX_BOOL bItalic, | |
438 int charset, | |
439 int pitch_family, | |
440 const FX_CHAR* family, | |
441 FX_BOOL bMatchName); | |
442 | |
443 std::map<CFX_ByteString, CFX_FontFaceInfo*> m_FontList; | |
444 std::vector<CFX_ByteString> m_PathList; | |
445 CFX_FontMapper* m_pMapper; | |
446 }; | |
447 | |
448 class CFX_CountedFaceCache { | |
449 public: | |
450 CFX_FaceCache* m_Obj; | |
451 uint32_t m_nCount; | |
452 }; | |
453 | |
454 class CFX_FontCache { | |
455 public: | |
456 CFX_FontCache(); | |
457 ~CFX_FontCache(); | |
458 CFX_FaceCache* GetCachedFace(CFX_Font* pFont); | |
459 void ReleaseCachedFace(CFX_Font* pFont); | |
460 void FreeCache(FX_BOOL bRelease = FALSE); | |
461 #ifdef _SKIA_SUPPORT_ | |
462 CFX_TypeFace* GetDeviceCache(CFX_Font* pFont); | |
463 #endif | |
464 | |
465 private: | |
466 using CFX_FTCacheMap = std::map<FXFT_Face, CFX_CountedFaceCache*>; | |
467 CFX_FTCacheMap m_FTFaceMap; | |
468 CFX_FTCacheMap m_ExtFaceMap; | |
469 }; | |
470 | |
471 class CFX_AutoFontCache { | |
472 public: | |
473 CFX_AutoFontCache(CFX_FontCache* pFontCache, CFX_Font* pFont) | |
474 : m_pFontCache(pFontCache), m_pFont(pFont) {} | |
475 ~CFX_AutoFontCache() { m_pFontCache->ReleaseCachedFace(m_pFont); } | |
476 CFX_FontCache* m_pFontCache; | |
477 CFX_Font* m_pFont; | |
478 }; | |
479 #define FX_FONTCACHE_DEFINE(pFontCache, pFont) \ | |
480 CFX_AutoFontCache autoFontCache((pFontCache), (pFont)) | |
481 class CFX_GlyphBitmap { | |
482 public: | |
483 int m_Top; | |
484 int m_Left; | |
485 CFX_DIBitmap m_Bitmap; | |
486 }; | |
487 class CFX_FaceCache { | |
488 public: | |
489 explicit CFX_FaceCache(FXFT_Face face); | |
490 ~CFX_FaceCache(); | |
491 const CFX_GlyphBitmap* LoadGlyphBitmap(CFX_Font* pFont, | |
492 uint32_t glyph_index, | |
493 FX_BOOL bFontStyle, | |
494 const CFX_Matrix* pMatrix, | |
495 int dest_width, | |
496 int anti_alias, | |
497 int& text_flags); | |
498 const CFX_PathData* LoadGlyphPath(CFX_Font* pFont, | |
499 uint32_t glyph_index, | |
500 int dest_width); | |
501 | |
502 #ifdef _SKIA_SUPPORT_ | |
503 CFX_TypeFace* GetDeviceCache(CFX_Font* pFont); | |
504 #endif | |
505 | |
506 private: | |
507 CFX_GlyphBitmap* RenderGlyph(CFX_Font* pFont, | |
508 uint32_t glyph_index, | |
509 FX_BOOL bFontStyle, | |
510 const CFX_Matrix* pMatrix, | |
511 int dest_width, | |
512 int anti_alias); | |
513 CFX_GlyphBitmap* RenderGlyph_Nativetext(CFX_Font* pFont, | |
514 uint32_t glyph_index, | |
515 const CFX_Matrix* pMatrix, | |
516 int dest_width, | |
517 int anti_alias); | |
518 CFX_GlyphBitmap* LookUpGlyphBitmap(CFX_Font* pFont, | |
519 const CFX_Matrix* pMatrix, | |
520 CFX_ByteStringC& FaceGlyphsKey, | |
521 uint32_t glyph_index, | |
522 FX_BOOL bFontStyle, | |
523 int dest_width, | |
524 int anti_alias); | |
525 void InitPlatform(); | |
526 void DestroyPlatform(); | |
527 | |
528 FXFT_Face const m_Face; | |
529 std::map<CFX_ByteString, CFX_SizeGlyphCache*> m_SizeMap; | |
530 std::map<uint32_t, CFX_PathData*> m_PathMap; | |
531 CFX_DIBitmap* m_pBitmap; | |
532 #ifdef _SKIA_SUPPORT_ | |
533 CFX_TypeFace* m_pTypeface; | |
534 #endif | |
535 }; | |
536 | |
537 struct FXTEXT_GLYPHPOS { | |
538 const CFX_GlyphBitmap* m_pGlyph; | |
539 int m_OriginX; | |
540 int m_OriginY; | |
541 FX_FLOAT m_fOriginX; | |
542 FX_FLOAT m_fOriginY; | |
543 }; | |
544 | |
545 FX_RECT FXGE_GetGlyphsBBox(FXTEXT_GLYPHPOS* pGlyphAndPos, | |
546 int nChars, | |
547 int anti_alias, | |
548 FX_FLOAT retinaScaleX = 1.0f, | |
549 FX_FLOAT retinaScaleY = 1.0f); | |
550 | |
551 class IFX_GSUBTable { | |
552 public: | |
553 static IFX_GSUBTable* Create(CFX_Font* pFont); | |
554 virtual FX_BOOL GetVerticalGlyph(uint32_t glyphnum, uint32_t* vglyphnum) = 0; | |
555 | |
556 protected: | |
557 virtual ~IFX_GSUBTable() {} | |
558 }; | |
559 | |
560 CFX_ByteString GetNameFromTT(const uint8_t* name_table, | |
561 uint32_t name_table_size, | |
562 uint32_t name); | |
563 | |
564 int PDF_GetStandardFontName(CFX_ByteString* name); | |
565 | |
566 #endif // CORE_INCLUDE_FXGE_FX_FONT_H_ | |
OLD | NEW |