| 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 public: | 16 public: |
| 17 CFPF_SkiaFontDescriptor() | 17 CFPF_SkiaFontDescriptor() |
| 18 : m_pFamily(NULL), | 18 : m_pFamily(NULL), |
| 19 m_dwStyle(0), | 19 m_dwStyle(0), |
| 20 m_iFaceIndex(0), | 20 m_iFaceIndex(0), |
| 21 m_dwCharsets(0), | 21 m_dwCharsets(0), |
| 22 m_iGlyphNum(0) {} | 22 m_iGlyphNum(0) {} |
| 23 virtual ~CFPF_SkiaFontDescriptor() { | 23 virtual ~CFPF_SkiaFontDescriptor() { |
| 24 if (m_pFamily) { | |
| 25 FX_Free(m_pFamily); | 24 FX_Free(m_pFamily); |
| 26 } | |
| 27 } | 25 } |
| 28 virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_Unknown; } | 26 virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_Unknown; } |
| 29 void SetFamily(const FX_CHAR* pFamily) { | 27 void SetFamily(const FX_CHAR* pFamily) { |
| 30 if (m_pFamily) { | |
| 31 FX_Free(m_pFamily); | 28 FX_Free(m_pFamily); |
| 32 } | |
| 33 int32_t iSize = FXSYS_strlen(pFamily); | 29 int32_t iSize = FXSYS_strlen(pFamily); |
| 34 m_pFamily = FX_Alloc(FX_CHAR, iSize + 1); | 30 m_pFamily = FX_Alloc(FX_CHAR, iSize + 1); |
| 35 FXSYS_memcpy(m_pFamily, pFamily, iSize * sizeof(FX_CHAR)); | 31 FXSYS_memcpy(m_pFamily, pFamily, iSize * sizeof(FX_CHAR)); |
| 36 m_pFamily[iSize] = 0; | 32 m_pFamily[iSize] = 0; |
| 37 } | 33 } |
| 38 FX_CHAR* m_pFamily; | 34 FX_CHAR* m_pFamily; |
| 39 FX_DWORD m_dwStyle; | 35 FX_DWORD m_dwStyle; |
| 40 int32_t m_iFaceIndex; | 36 int32_t m_iFaceIndex; |
| 41 FX_DWORD m_dwCharsets; | 37 FX_DWORD m_dwCharsets; |
| 42 int32_t m_iGlyphNum; | 38 int32_t m_iGlyphNum; |
| 43 }; | 39 }; |
| 44 class CFPF_SkiaPathFont : public CFPF_SkiaFontDescriptor { | 40 class CFPF_SkiaPathFont : public CFPF_SkiaFontDescriptor { |
| 45 public: | 41 public: |
| 46 CFPF_SkiaPathFont() : m_pPath(NULL) {} | 42 CFPF_SkiaPathFont() : m_pPath(NULL) {} |
| 47 virtual ~CFPF_SkiaPathFont() { | 43 virtual ~CFPF_SkiaPathFont() { |
| 48 if (m_pPath) { | |
| 49 FX_Free(m_pPath); | 44 FX_Free(m_pPath); |
| 50 } | |
| 51 } | 45 } |
| 52 virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_Path; } | 46 virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_Path; } |
| 53 void SetPath(const FX_CHAR* pPath) { | 47 void SetPath(const FX_CHAR* pPath) { |
| 54 if (m_pPath) { | |
| 55 FX_Free(m_pPath); | 48 FX_Free(m_pPath); |
| 56 } | |
| 57 int32_t iSize = FXSYS_strlen(pPath); | 49 int32_t iSize = FXSYS_strlen(pPath); |
| 58 m_pPath = FX_Alloc(FX_CHAR, iSize + 1); | 50 m_pPath = FX_Alloc(FX_CHAR, iSize + 1); |
| 59 FXSYS_memcpy(m_pPath, pPath, iSize * sizeof(FX_CHAR)); | 51 FXSYS_memcpy(m_pPath, pPath, iSize * sizeof(FX_CHAR)); |
| 60 m_pPath[iSize] = 0; | 52 m_pPath[iSize] = 0; |
| 61 } | 53 } |
| 62 FX_CHAR* m_pPath; | 54 FX_CHAR* m_pPath; |
| 63 }; | 55 }; |
| 64 class CFPF_SkiaFileFont : public CFPF_SkiaFontDescriptor { | 56 class CFPF_SkiaFileFont : public CFPF_SkiaFontDescriptor { |
| 65 public: | 57 public: |
| 66 CFPF_SkiaFileFont() : m_pFile(NULL) {} | 58 CFPF_SkiaFileFont() : m_pFile(NULL) {} |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 void ReportFace(FXFT_Face face, CFPF_SkiaFontDescriptor* pFontDesc); | 92 void ReportFace(FXFT_Face face, CFPF_SkiaFontDescriptor* pFontDesc); |
| 101 void OutputSystemFonts(); | 93 void OutputSystemFonts(); |
| 102 FX_BOOL m_bLoaded; | 94 FX_BOOL m_bLoaded; |
| 103 CFX_PtrArray m_FontFaces; | 95 CFX_PtrArray m_FontFaces; |
| 104 FXFT_Library m_FTLibrary; | 96 FXFT_Library m_FTLibrary; |
| 105 CFX_MapPtrToPtr m_FamilyFonts; | 97 CFX_MapPtrToPtr m_FamilyFonts; |
| 106 }; | 98 }; |
| 107 #endif | 99 #endif |
| 108 | 100 |
| 109 #endif // CORE_SRC_FXGE_ANDROID_FPF_SKIAFONTMGR_H_ | 101 #endif // CORE_SRC_FXGE_ANDROID_FPF_SKIAFONTMGR_H_ |
| OLD | NEW |