| 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_SRC_FXGE_ANDROID_FPF_SKIAFONTMGR_H_ | |
| 8 #define CORE_SRC_FXGE_ANDROID_FPF_SKIAFONTMGR_H_ | |
| 9 | |
| 10 #include "core/include/fxcrt/fx_system.h" | |
| 11 | |
| 12 #if _FX_OS_ == _FX_ANDROID_ | |
| 13 | |
| 14 #include <map> | |
| 15 #include <vector> | |
| 16 | |
| 17 #include "core/include/fxge/fpf.h" | |
| 18 #include "core/include/fxge/fx_font.h" | |
| 19 | |
| 20 #define FPF_SKIAFONTTYPE_Unknown 0 | |
| 21 #define FPF_SKIAFONTTYPE_Path 1 | |
| 22 #define FPF_SKIAFONTTYPE_File 2 | |
| 23 #define FPF_SKIAFONTTYPE_Buffer 3 | |
| 24 | |
| 25 class CFPF_SkiaFont; | |
| 26 | |
| 27 class CFPF_SkiaFontDescriptor { | |
| 28 public: | |
| 29 CFPF_SkiaFontDescriptor() | |
| 30 : m_pFamily(NULL), | |
| 31 m_dwStyle(0), | |
| 32 m_iFaceIndex(0), | |
| 33 m_dwCharsets(0), | |
| 34 m_iGlyphNum(0) {} | |
| 35 virtual ~CFPF_SkiaFontDescriptor() { FX_Free(m_pFamily); } | |
| 36 | |
| 37 virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_Unknown; } | |
| 38 | |
| 39 void SetFamily(const FX_CHAR* pFamily) { | |
| 40 FX_Free(m_pFamily); | |
| 41 int32_t iSize = FXSYS_strlen(pFamily); | |
| 42 m_pFamily = FX_Alloc(FX_CHAR, iSize + 1); | |
| 43 FXSYS_memcpy(m_pFamily, pFamily, iSize * sizeof(FX_CHAR)); | |
| 44 m_pFamily[iSize] = 0; | |
| 45 } | |
| 46 FX_CHAR* m_pFamily; | |
| 47 FX_DWORD m_dwStyle; | |
| 48 int32_t m_iFaceIndex; | |
| 49 FX_DWORD m_dwCharsets; | |
| 50 int32_t m_iGlyphNum; | |
| 51 }; | |
| 52 | |
| 53 class CFPF_SkiaPathFont : public CFPF_SkiaFontDescriptor { | |
| 54 public: | |
| 55 CFPF_SkiaPathFont() : m_pPath(NULL) {} | |
| 56 ~CFPF_SkiaPathFont() override { FX_Free(m_pPath); } | |
| 57 | |
| 58 // CFPF_SkiaFontDescriptor | |
| 59 int32_t GetType() const override { return FPF_SKIAFONTTYPE_Path; } | |
| 60 | |
| 61 void SetPath(const FX_CHAR* pPath) { | |
| 62 FX_Free(m_pPath); | |
| 63 int32_t iSize = FXSYS_strlen(pPath); | |
| 64 m_pPath = FX_Alloc(FX_CHAR, iSize + 1); | |
| 65 FXSYS_memcpy(m_pPath, pPath, iSize * sizeof(FX_CHAR)); | |
| 66 m_pPath[iSize] = 0; | |
| 67 } | |
| 68 FX_CHAR* m_pPath; | |
| 69 }; | |
| 70 | |
| 71 class CFPF_SkiaFileFont : public CFPF_SkiaFontDescriptor { | |
| 72 public: | |
| 73 CFPF_SkiaFileFont() : m_pFile(NULL) {} | |
| 74 | |
| 75 // CFPF_SkiaFontDescriptor | |
| 76 int32_t GetType() const override { return FPF_SKIAFONTTYPE_File; } | |
| 77 IFX_FileRead* m_pFile; | |
| 78 }; | |
| 79 | |
| 80 class CFPF_SkiaBufferFont : public CFPF_SkiaFontDescriptor { | |
| 81 public: | |
| 82 CFPF_SkiaBufferFont() : m_pBuffer(NULL), m_szBuffer(0) {} | |
| 83 | |
| 84 // CFPF_SkiaFontDescriptor | |
| 85 int32_t GetType() const override { return FPF_SKIAFONTTYPE_Buffer; } | |
| 86 | |
| 87 void* m_pBuffer; | |
| 88 size_t m_szBuffer; | |
| 89 }; | |
| 90 | |
| 91 class CFPF_SkiaFontMgr : public IFPF_FontMgr { | |
| 92 public: | |
| 93 CFPF_SkiaFontMgr(); | |
| 94 ~CFPF_SkiaFontMgr() override; | |
| 95 | |
| 96 // IFPF_FontMgr | |
| 97 void LoadSystemFonts() override; | |
| 98 void LoadPrivateFont(IFX_FileRead* pFontFile) override; | |
| 99 void LoadPrivateFont(const CFX_ByteStringC& bsFileName) override; | |
| 100 void LoadPrivateFont(void* pBuffer, size_t szBuffer) override; | |
| 101 IFPF_Font* CreateFont(const CFX_ByteStringC& bsFamilyname, | |
| 102 uint8_t uCharset, | |
| 103 FX_DWORD dwStyle, | |
| 104 FX_DWORD dwMatch = 0) override; | |
| 105 | |
| 106 FX_BOOL InitFTLibrary(); | |
| 107 FXFT_Face GetFontFace(IFX_FileRead* pFileRead, int32_t iFaceIndex = 0); | |
| 108 FXFT_Face GetFontFace(const CFX_ByteStringC& bsFile, int32_t iFaceIndex = 0); | |
| 109 FXFT_Face GetFontFace(const uint8_t* pBuffer, | |
| 110 size_t szBuffer, | |
| 111 int32_t iFaceIndex = 0); | |
| 112 | |
| 113 protected: | |
| 114 void ScanPath(const CFX_ByteStringC& path); | |
| 115 void ScanFile(const CFX_ByteStringC& file); | |
| 116 void ReportFace(FXFT_Face face, CFPF_SkiaFontDescriptor* pFontDesc); | |
| 117 void OutputSystemFonts(); | |
| 118 | |
| 119 FX_BOOL m_bLoaded; | |
| 120 FXFT_Library m_FTLibrary; | |
| 121 std::vector<CFPF_SkiaFontDescriptor*> m_FontFaces; | |
| 122 std::map<FX_DWORD, CFPF_SkiaFont*> m_FamilyFonts; | |
| 123 }; | |
| 124 | |
| 125 #endif | |
| 126 | |
| 127 #endif // CORE_SRC_FXGE_ANDROID_FPF_SKIAFONTMGR_H_ | |
| OLD | NEW |