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