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> |
11 #include <memory> | 11 #include <memory> |
| 12 #include <vector> |
12 | 13 |
13 #include "core/include/fxcrt/fx_system.h" | 14 #include "core/include/fxcrt/fx_system.h" |
14 #include "fx_dib.h" | 15 #include "core/include/fxge/fx_dib.h" |
15 | 16 |
16 typedef struct FT_FaceRec_* FXFT_Face; | 17 typedef struct FT_FaceRec_* FXFT_Face; |
17 typedef void* FXFT_Library; | 18 typedef void* FXFT_Library; |
18 | 19 |
19 class CFX_FaceCache; | 20 class CFX_FaceCache; |
20 class CFX_FontFaceInfo; | 21 class CFX_FontFaceInfo; |
21 class CFX_FontMapper; | 22 class CFX_FontMapper; |
22 class CFX_PathData; | 23 class CFX_PathData; |
23 class CFX_SizeGlyphCache; | 24 class CFX_SizeGlyphCache; |
24 class CFX_SubstFont; | 25 class CFX_SubstFont; |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 300 |
300 class CFX_FontMapper { | 301 class CFX_FontMapper { |
301 public: | 302 public: |
302 explicit CFX_FontMapper(CFX_FontMgr* mgr); | 303 explicit CFX_FontMapper(CFX_FontMgr* mgr); |
303 ~CFX_FontMapper(); | 304 ~CFX_FontMapper(); |
304 | 305 |
305 void SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo); | 306 void SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo); |
306 IFX_SystemFontInfo* GetSystemFontInfo() { return m_pFontInfo; } | 307 IFX_SystemFontInfo* GetSystemFontInfo() { return m_pFontInfo; } |
307 void AddInstalledFont(const CFX_ByteString& name, int charset); | 308 void AddInstalledFont(const CFX_ByteString& name, int charset); |
308 void LoadInstalledFonts(); | 309 void LoadInstalledFonts(); |
309 CFX_ByteStringArray m_InstalledTTFonts; | 310 std::vector<CFX_ByteString> m_InstalledTTFonts; |
310 void SetFontEnumerator(IFX_FontEnumerator* pFontEnumerator) { | 311 void SetFontEnumerator(IFX_FontEnumerator* pFontEnumerator) { |
311 m_pFontEnumerator = pFontEnumerator; | 312 m_pFontEnumerator = pFontEnumerator; |
312 } | 313 } |
313 IFX_FontEnumerator* GetFontEnumerator() const { return m_pFontEnumerator; } | 314 IFX_FontEnumerator* GetFontEnumerator() const { return m_pFontEnumerator; } |
314 FXFT_Face FindSubstFont(const CFX_ByteString& face_name, | 315 FXFT_Face FindSubstFont(const CFX_ByteString& face_name, |
315 FX_BOOL bTrueType, | 316 FX_BOOL bTrueType, |
316 FX_DWORD flags, | 317 FX_DWORD flags, |
317 int weight, | 318 int weight, |
318 int italic_angle, | 319 int italic_angle, |
319 int CharsetCP, | 320 int CharsetCP, |
320 CFX_SubstFont* pSubstFont); | 321 CFX_SubstFont* pSubstFont); |
321 #ifdef PDF_ENABLE_XFA | 322 #ifdef PDF_ENABLE_XFA |
322 FXFT_Face FindSubstFontByUnicode(FX_DWORD dwUnicode, | 323 FXFT_Face FindSubstFontByUnicode(FX_DWORD dwUnicode, |
323 FX_DWORD flags, | 324 FX_DWORD flags, |
324 int weight, | 325 int weight, |
325 int italic_angle); | 326 int italic_angle); |
326 #endif // PDF_ENABLE_XFA | 327 #endif // PDF_ENABLE_XFA |
327 FX_BOOL IsBuiltinFace(const FXFT_Face face) const; | 328 FX_BOOL IsBuiltinFace(const FXFT_Face face) const; |
328 int GetFaceSize() const { return m_FaceArray.GetSize(); } | 329 int GetFaceSize() const; |
329 CFX_ByteString GetFaceName(int index) const { return m_FaceArray[index]; } | 330 CFX_ByteString GetFaceName(int index) const { return m_FaceArray[index]; } |
330 | 331 |
331 private: | 332 private: |
332 static const size_t MM_FACE_COUNT = 2; | 333 static const size_t MM_FACE_COUNT = 2; |
333 static const size_t FOXIT_FACE_COUNT = 14; | 334 static const size_t FOXIT_FACE_COUNT = 14; |
334 | 335 |
335 CFX_ByteString GetPSNameFromTT(void* hFont); | 336 CFX_ByteString GetPSNameFromTT(void* hFont); |
336 CFX_ByteString MatchInstalledFonts(const CFX_ByteString& norm_name); | 337 CFX_ByteString MatchInstalledFonts(const CFX_ByteString& norm_name); |
337 FXFT_Face UseInternalSubst(CFX_SubstFont* pSubstFont, | 338 FXFT_Face UseInternalSubst(CFX_SubstFont* pSubstFont, |
338 int iBaseFont, | 339 int iBaseFont, |
339 int italic_angle, | 340 int italic_angle, |
340 int weight, | 341 int weight, |
341 int picthfamily); | 342 int picthfamily); |
342 | 343 |
343 FX_BOOL m_bListLoaded; | 344 FX_BOOL m_bListLoaded; |
344 FXFT_Face m_MMFaces[MM_FACE_COUNT]; | 345 FXFT_Face m_MMFaces[MM_FACE_COUNT]; |
345 CFX_ByteString m_LastFamily; | 346 CFX_ByteString m_LastFamily; |
346 CFX_DWordArray m_CharsetArray; | 347 CFX_DWordArray m_CharsetArray; |
347 CFX_ByteStringArray m_FaceArray; | 348 std::vector<CFX_ByteString> m_FaceArray; |
348 IFX_SystemFontInfo* m_pFontInfo; | 349 IFX_SystemFontInfo* m_pFontInfo; |
349 FXFT_Face m_FoxitFaces[FOXIT_FACE_COUNT]; | 350 FXFT_Face m_FoxitFaces[FOXIT_FACE_COUNT]; |
350 IFX_FontEnumerator* m_pFontEnumerator; | 351 IFX_FontEnumerator* m_pFontEnumerator; |
351 CFX_FontMgr* const m_pFontMgr; | 352 CFX_FontMgr* const m_pFontMgr; |
352 }; | 353 }; |
353 | 354 |
354 class IFX_SystemFontInfo { | 355 class IFX_SystemFontInfo { |
355 public: | 356 public: |
356 static IFX_SystemFontInfo* CreateDefault(const char** pUserPaths); | 357 static IFX_SystemFontInfo* CreateDefault(const char** pUserPaths); |
357 virtual void Release() = 0; | 358 virtual void Release() = 0; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 void* GetFont(const FX_CHAR* face) override; | 411 void* GetFont(const FX_CHAR* face) override; |
411 FX_DWORD GetFontData(void* hFont, | 412 FX_DWORD GetFontData(void* hFont, |
412 FX_DWORD table, | 413 FX_DWORD table, |
413 uint8_t* buffer, | 414 uint8_t* buffer, |
414 FX_DWORD size) override; | 415 FX_DWORD size) override; |
415 void DeleteFont(void* hFont) override; | 416 void DeleteFont(void* hFont) override; |
416 FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) override; | 417 FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) override; |
417 FX_BOOL GetFontCharset(void* hFont, int& charset) override; | 418 FX_BOOL GetFontCharset(void* hFont, int& charset) override; |
418 | 419 |
419 protected: | 420 protected: |
420 std::map<CFX_ByteString, CFX_FontFaceInfo*> m_FontList; | 421 void ScanPath(const CFX_ByteString& path); |
421 CFX_ByteStringArray m_PathList; | 422 void ScanFile(const CFX_ByteString& path); |
422 CFX_FontMapper* m_pMapper; | 423 void ReportFace(const CFX_ByteString& path, |
423 void ScanPath(CFX_ByteString& path); | |
424 void ScanFile(CFX_ByteString& path); | |
425 void ReportFace(CFX_ByteString& path, | |
426 FXSYS_FILE* pFile, | 424 FXSYS_FILE* pFile, |
427 FX_DWORD filesize, | 425 FX_DWORD filesize, |
428 FX_DWORD offset); | 426 FX_DWORD offset); |
429 void* GetSubstFont(const CFX_ByteString& face); | 427 void* GetSubstFont(const CFX_ByteString& face); |
430 void* FindFont(int weight, | 428 void* FindFont(int weight, |
431 FX_BOOL bItalic, | 429 FX_BOOL bItalic, |
432 int charset, | 430 int charset, |
433 int pitch_family, | 431 int pitch_family, |
434 const FX_CHAR* family, | 432 const FX_CHAR* family, |
435 FX_BOOL bMatchName); | 433 FX_BOOL bMatchName); |
| 434 |
| 435 std::map<CFX_ByteString, CFX_FontFaceInfo*> m_FontList; |
| 436 std::vector<CFX_ByteString> m_PathList; |
| 437 CFX_FontMapper* m_pMapper; |
436 }; | 438 }; |
| 439 |
437 class CFX_CountedFaceCache { | 440 class CFX_CountedFaceCache { |
438 public: | 441 public: |
439 CFX_FaceCache* m_Obj; | 442 CFX_FaceCache* m_Obj; |
440 FX_DWORD m_nCount; | 443 FX_DWORD m_nCount; |
441 }; | 444 }; |
442 | 445 |
443 class CFX_FontCache { | 446 class CFX_FontCache { |
444 public: | 447 public: |
445 ~CFX_FontCache(); | 448 ~CFX_FontCache(); |
446 CFX_FaceCache* GetCachedFace(CFX_Font* pFont); | 449 CFX_FaceCache* GetCachedFace(CFX_Font* pFont); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 | 535 |
533 protected: | 536 protected: |
534 virtual ~IFX_GSUBTable() {} | 537 virtual ~IFX_GSUBTable() {} |
535 }; | 538 }; |
536 | 539 |
537 CFX_ByteString GetNameFromTT(const uint8_t* name_table, FX_DWORD name); | 540 CFX_ByteString GetNameFromTT(const uint8_t* name_table, FX_DWORD name); |
538 | 541 |
539 int PDF_GetStandardFontName(CFX_ByteString* name); | 542 int PDF_GetStandardFontName(CFX_ByteString* name); |
540 | 543 |
541 #endif // CORE_INCLUDE_FXGE_FX_FONT_H_ | 544 #endif // CORE_INCLUDE_FXGE_FX_FONT_H_ |
OLD | NEW |