summaryrefslogtreecommitdiff
path: root/core/fxge/android/cfpf_skiafontmgr.h
blob: 99aafd7bd2941c5af735d6553a804926f2d75772 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2016 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef CORE_FXGE_ANDROID_CFPF_SKIAFONTMGR_H_
#define CORE_FXGE_ANDROID_CFPF_SKIAFONTMGR_H_

#include <map>
#include <memory>
#include <vector>

#include "core/fxcrt/fx_string.h"
#include "core/fxge/fx_font.h"

#define FPF_MATCHFONT_REPLACEANSI 1

class CFPF_SkiaFont;
class CFPF_SkiaPathFont;

class CFPF_SkiaFontMgr {
 public:
  CFPF_SkiaFontMgr();
  ~CFPF_SkiaFontMgr();

  void LoadSystemFonts();
  CFPF_SkiaFont* CreateFont(const ByteStringView& bsFamilyname,
                            uint8_t uCharset,
                            uint32_t dwStyle,
                            uint32_t dwMatch);

  bool InitFTLibrary();
  FXFT_Face GetFontFace(const ByteStringView& bsFile, int32_t iFaceIndex);

 private:
  void ScanPath(const ByteString& path);
  void ScanFile(const ByteString& file);
  std::unique_ptr<CFPF_SkiaPathFont> ReportFace(FXFT_Face face,
                                                const ByteString& file);

  bool m_bLoaded = false;
  FXFT_Library m_FTLibrary = nullptr;
  std::vector<std::unique_ptr<CFPF_SkiaPathFont>> m_FontFaces;
  std::map<uint32_t, CFPF_SkiaFont*> m_FamilyFonts;
};

#endif  // CORE_FXGE_ANDROID_CFPF_SKIAFONTMGR_H_