Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: core/fxge/android/fpf_skiafontmgr.h

Issue 2448293002: Name core/fxge/android files appropriately and use one file per class (Closed)
Patch Set: Fix build Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_FXGE_ANDROID_FPF_SKIAFONTMGR_H_
8 #define CORE_FXGE_ANDROID_FPF_SKIAFONTMGR_H_
9
10 #include "core/fxcrt/fx_system.h"
11
12 #if _FX_OS_ == _FX_ANDROID_
13
14 #include <map>
15 #include <vector>
16
17 #include "core/fxge/fx_font.h"
18
19 #define FPF_SKIAFONTTYPE_Unknown 0
20 #define FPF_SKIAFONTTYPE_Path 1
21 #define FPF_SKIAFONTTYPE_File 2
22 #define FPF_SKIAFONTTYPE_Buffer 3
23
24 #define FPF_MATCHFONT_REPLACEANSI 1
25
26 class CFPF_SkiaFont;
27
28 class CFPF_SkiaFontDescriptor {
29 public:
30 CFPF_SkiaFontDescriptor()
31 : m_pFamily(nullptr),
32 m_dwStyle(0),
33 m_iFaceIndex(0),
34 m_dwCharsets(0),
35 m_iGlyphNum(0) {}
36 virtual ~CFPF_SkiaFontDescriptor() { FX_Free(m_pFamily); }
37
38 virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_Unknown; }
39
40 void SetFamily(const FX_CHAR* pFamily) {
41 FX_Free(m_pFamily);
42 int32_t iSize = FXSYS_strlen(pFamily);
43 m_pFamily = FX_Alloc(FX_CHAR, iSize + 1);
44 FXSYS_memcpy(m_pFamily, pFamily, iSize * sizeof(FX_CHAR));
45 m_pFamily[iSize] = 0;
46 }
47 FX_CHAR* m_pFamily;
48 uint32_t m_dwStyle;
49 int32_t m_iFaceIndex;
50 uint32_t m_dwCharsets;
51 int32_t m_iGlyphNum;
52 };
53
54 class CFPF_SkiaPathFont : public CFPF_SkiaFontDescriptor {
55 public:
56 CFPF_SkiaPathFont() : m_pPath(nullptr) {}
57 ~CFPF_SkiaPathFont() override { FX_Free(m_pPath); }
58
59 // CFPF_SkiaFontDescriptor
60 int32_t GetType() const override { return FPF_SKIAFONTTYPE_Path; }
61
62 void SetPath(const FX_CHAR* pPath) {
63 FX_Free(m_pPath);
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 };
71
72 class CFPF_SkiaFileFont : public CFPF_SkiaFontDescriptor {
73 public:
74 CFPF_SkiaFileFont() : m_pFile(nullptr) {}
75
76 // CFPF_SkiaFontDescriptor
77 int32_t GetType() const override { return FPF_SKIAFONTTYPE_File; }
78 IFX_SeekableReadStream* m_pFile;
79 };
80
81 class CFPF_SkiaBufferFont : public CFPF_SkiaFontDescriptor {
82 public:
83 CFPF_SkiaBufferFont() : m_pBuffer(nullptr), m_szBuffer(0) {}
84
85 // CFPF_SkiaFontDescriptor
86 int32_t GetType() const override { return FPF_SKIAFONTTYPE_Buffer; }
87
88 void* m_pBuffer;
89 size_t m_szBuffer;
90 };
91
92 class CFPF_SkiaFontMgr {
93 public:
94 CFPF_SkiaFontMgr();
95 ~CFPF_SkiaFontMgr();
96
97 void LoadSystemFonts();
98 CFPF_SkiaFont* CreateFont(const CFX_ByteStringC& bsFamilyname,
99 uint8_t uCharset,
100 uint32_t dwStyle,
101 uint32_t dwMatch = 0);
102
103 bool InitFTLibrary();
104 FXFT_Face GetFontFace(IFX_SeekableReadStream* pFileRead,
105 int32_t iFaceIndex = 0);
106 FXFT_Face GetFontFace(const CFX_ByteStringC& bsFile, int32_t iFaceIndex = 0);
107 FXFT_Face GetFontFace(const uint8_t* pBuffer,
108 size_t szBuffer,
109 int32_t iFaceIndex = 0);
110
111 private:
112 void ScanPath(const CFX_ByteString& path);
113 void ScanFile(const CFX_ByteString& file);
114 void ReportFace(FXFT_Face face, CFPF_SkiaFontDescriptor* pFontDesc);
115
116 bool m_bLoaded;
117 FXFT_Library m_FTLibrary;
118 std::vector<CFPF_SkiaFontDescriptor*> m_FontFaces;
119 std::map<uint32_t, CFPF_SkiaFont*> m_FamilyFonts;
120 };
121
122 #endif // _FX_OS_ == _FX_ANDROID_
123
124 #endif // CORE_FXGE_ANDROID_FPF_SKIAFONTMGR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698