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_SKIAFONT_H_
8 #define CORE_FXGE_ANDROID_CFPF_SKIAFONT_H_
9 
10 #include "core/fxcrt/fx_string.h"
11 #include "core/fxcrt/fx_system.h"
12 #include "core/fxcrt/unowned_ptr.h"
13 #include "core/fxge/cfx_face.h"
14 #include "core/fxge/fx_freetype.h"
15 #include "third_party/base/span.h"
16 
17 class CFPF_SkiaFontMgr;
18 class CFPF_SkiaPathFont;
19 struct FX_RECT;
20 
21 class CFPF_SkiaFont {
22  public:
23   CFPF_SkiaFont(CFPF_SkiaFontMgr* pFontMgr,
24                 const CFPF_SkiaPathFont* pFont,
25                 uint32_t dwStyle,
26                 uint8_t uCharset);
27   ~CFPF_SkiaFont();
28 
IsValid()29   bool IsValid() const { return !!m_Face; }
30 
31   ByteString GetFamilyName();
32   ByteString GetPsName();
GetFontStyle()33   uint32_t GetFontStyle() const { return m_dwStyle; }
GetCharset()34   uint8_t GetCharset() const { return m_uCharset; }
35   int32_t GetGlyphIndex(wchar_t wUnicode);
36   int32_t GetGlyphWidth(int32_t iGlyphIndex);
37   int32_t GetAscent() const;
38   int32_t GetDescent() const;
39   bool GetGlyphBBox(int32_t iGlyphIndex, FX_RECT& rtBBox);
40   bool GetBBox(FX_RECT& rtBBox);
41   int32_t GetHeight() const;
42   int32_t GetItalicAngle() const;
43   uint32_t GetFontData(uint32_t dwTable, pdfium::span<uint8_t> pBuffer);
GetFaceRec()44   FXFT_FaceRec* GetFaceRec() const { return m_Face->GetRec(); }
45 
46  private:
47   UnownedPtr<CFPF_SkiaFontMgr> const m_pFontMgr;
48   UnownedPtr<const CFPF_SkiaPathFont> const m_pFont;
49   RetainPtr<CFX_Face> const m_Face;
50   const uint32_t m_dwStyle;
51   const uint8_t m_uCharset;
52 };
53 
54 #endif  // CORE_FXGE_ANDROID_CFPF_SKIAFONT_H_
55