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