• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 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_CFPF_SKIAFONTMGR_H_
8 #define CORE_FXGE_ANDROID_CFPF_SKIAFONTMGR_H_
9 
10 #include <map>
11 #include <vector>
12 
13 #include "core/fxcrt/fx_stream.h"
14 #include "core/fxcrt/fx_string.h"
15 #include "core/fxge/fx_font.h"
16 
17 #define FPF_MATCHFONT_REPLACEANSI 1
18 
19 class CFPF_SkiaFont;
20 class CFPF_SkiaFontDescriptor;
21 
22 class CFPF_SkiaFontMgr {
23  public:
24   CFPF_SkiaFontMgr();
25   ~CFPF_SkiaFontMgr();
26 
27   void LoadSystemFonts();
28   CFPF_SkiaFont* CreateFont(const ByteStringView& bsFamilyname,
29                             uint8_t uCharset,
30                             uint32_t dwStyle,
31                             uint32_t dwMatch = 0);
32 
33   bool InitFTLibrary();
34   FXFT_Face GetFontFace(const RetainPtr<IFX_SeekableReadStream>& pFileRead,
35                         int32_t iFaceIndex = 0);
36   FXFT_Face GetFontFace(const ByteStringView& bsFile, int32_t iFaceIndex = 0);
37   FXFT_Face GetFontFace(const uint8_t* pBuffer,
38                         size_t szBuffer,
39                         int32_t iFaceIndex = 0);
40 
41  private:
42   void ScanPath(const ByteString& path);
43   void ScanFile(const ByteString& file);
44   void ReportFace(FXFT_Face face, CFPF_SkiaFontDescriptor* pFontDesc);
45 
46   bool m_bLoaded;
47   FXFT_Library m_FTLibrary;
48   std::vector<CFPF_SkiaFontDescriptor*> m_FontFaces;
49   std::map<uint32_t, CFPF_SkiaFont*> m_FamilyFonts;
50 };
51 
52 #endif  // CORE_FXGE_ANDROID_CFPF_SKIAFONTMGR_H_
53