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