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 | 11 |
12 #include "../../../include/fxge/fpf.h" | 12 #include "../../../include/fxge/fpf.h" |
13 | 13 |
14 #define FPF_SKIAFONTTYPE_Unknown 0 | 14 #define FPF_SKIAFONTTYPE_Unknown 0 |
15 #define FPF_SKIAFONTTYPE_Path 1 | 15 #define FPF_SKIAFONTTYPE_Path 1 |
16 #define FPF_SKIAFONTTYPE_File 2 | 16 #define FPF_SKIAFONTTYPE_File 2 |
17 #define FPF_SKIAFONTTYPE_Buffer 3 | 17 #define FPF_SKIAFONTTYPE_Buffer 3 |
18 | 18 |
19 class CFPF_SkiaFontDescriptor { | 19 class CFPF_SkiaFontDescriptor { |
20 public: | 20 public: |
21 CFPF_SkiaFontDescriptor() | 21 CFPF_SkiaFontDescriptor() |
22 : m_pFamily(NULL), | 22 : m_pFamily(NULL), |
23 m_dwStyle(0), | 23 m_dwStyle(0), |
24 m_iFaceIndex(0), | 24 m_iFaceIndex(0), |
25 m_dwCharsets(0), | 25 m_dwCharsets(0), |
26 m_iGlyphNum(0) {} | 26 m_iGlyphNum(0) {} |
27 virtual ~CFPF_SkiaFontDescriptor() { | 27 virtual ~CFPF_SkiaFontDescriptor() { FX_Free(m_pFamily); } |
28 if (m_pFamily) { | |
29 FX_Free(m_pFamily); | |
30 } | |
31 } | |
32 | 28 |
33 virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_Unknown; } | 29 virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_Unknown; } |
34 | 30 |
35 void SetFamily(const FX_CHAR* pFamily) { | 31 void SetFamily(const FX_CHAR* pFamily) { |
36 if (m_pFamily) { | 32 FX_Free(m_pFamily); |
37 FX_Free(m_pFamily); | |
38 } | |
39 int32_t iSize = FXSYS_strlen(pFamily); | 33 int32_t iSize = FXSYS_strlen(pFamily); |
40 m_pFamily = FX_Alloc(FX_CHAR, iSize + 1); | 34 m_pFamily = FX_Alloc(FX_CHAR, iSize + 1); |
41 FXSYS_memcpy(m_pFamily, pFamily, iSize * sizeof(FX_CHAR)); | 35 FXSYS_memcpy(m_pFamily, pFamily, iSize * sizeof(FX_CHAR)); |
42 m_pFamily[iSize] = 0; | 36 m_pFamily[iSize] = 0; |
43 } | 37 } |
44 FX_CHAR* m_pFamily; | 38 FX_CHAR* m_pFamily; |
45 FX_DWORD m_dwStyle; | 39 FX_DWORD m_dwStyle; |
46 int32_t m_iFaceIndex; | 40 int32_t m_iFaceIndex; |
47 FX_DWORD m_dwCharsets; | 41 FX_DWORD m_dwCharsets; |
48 int32_t m_iGlyphNum; | 42 int32_t m_iGlyphNum; |
49 }; | 43 }; |
50 | 44 |
51 class CFPF_SkiaPathFont : public CFPF_SkiaFontDescriptor { | 45 class CFPF_SkiaPathFont : public CFPF_SkiaFontDescriptor { |
52 public: | 46 public: |
53 CFPF_SkiaPathFont() : m_pPath(NULL) {} | 47 CFPF_SkiaPathFont() : m_pPath(NULL) {} |
54 ~CFPF_SkiaPathFont() override { | 48 ~CFPF_SkiaPathFont() override { FX_Free(m_pPath); } |
55 if (m_pPath) { | |
56 FX_Free(m_pPath); | |
57 } | |
58 } | |
59 | 49 |
60 // CFPF_SkiaFontDescriptor | 50 // CFPF_SkiaFontDescriptor |
61 int32_t GetType() const override { return FPF_SKIAFONTTYPE_Path; } | 51 int32_t GetType() const override { return FPF_SKIAFONTTYPE_Path; } |
62 | 52 |
63 void SetPath(const FX_CHAR* pPath) { | 53 void SetPath(const FX_CHAR* pPath) { |
64 if (m_pPath) { | 54 FX_Free(m_pPath); |
65 FX_Free(m_pPath); | |
66 } | |
67 int32_t iSize = FXSYS_strlen(pPath); | 55 int32_t iSize = FXSYS_strlen(pPath); |
68 m_pPath = FX_Alloc(FX_CHAR, iSize + 1); | 56 m_pPath = FX_Alloc(FX_CHAR, iSize + 1); |
69 FXSYS_memcpy(m_pPath, pPath, iSize * sizeof(FX_CHAR)); | 57 FXSYS_memcpy(m_pPath, pPath, iSize * sizeof(FX_CHAR)); |
70 m_pPath[iSize] = 0; | 58 m_pPath[iSize] = 0; |
71 } | 59 } |
72 FX_CHAR* m_pPath; | 60 FX_CHAR* m_pPath; |
73 }; | 61 }; |
74 | 62 |
75 class CFPF_SkiaFileFont : public CFPF_SkiaFontDescriptor { | 63 class CFPF_SkiaFileFont : public CFPF_SkiaFontDescriptor { |
76 public: | 64 public: |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 void OutputSystemFonts(); | 109 void OutputSystemFonts(); |
122 FX_BOOL m_bLoaded; | 110 FX_BOOL m_bLoaded; |
123 CFX_PtrArray m_FontFaces; | 111 CFX_PtrArray m_FontFaces; |
124 FXFT_Library m_FTLibrary; | 112 FXFT_Library m_FTLibrary; |
125 CFX_MapPtrToPtr m_FamilyFonts; | 113 CFX_MapPtrToPtr m_FamilyFonts; |
126 }; | 114 }; |
127 | 115 |
128 #endif | 116 #endif |
129 | 117 |
130 #endif // CORE_SRC_FXGE_ANDROID_FPF_SKIAFONTMGR_H_ | 118 #endif // CORE_SRC_FXGE_ANDROID_FPF_SKIAFONTMGR_H_ |
OLD | NEW |