• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 _FX_GRAPHOBJS_IMP
8 #define _FX_GRAPHOBJS_IMP
9 #ifndef _FXPLUS
10 class CFX_GEFontMgr;
11 #ifndef FXFONT_SUBST_ITALIC
12 #define FXFONT_SUBST_ITALIC 0x02
13 #endif
14 class CFX_GEFont : public IFX_Font, public CFX_ThreadLock {
15  public:
16   CFX_GEFont(const CFX_GEFont& src, FX_DWORD dwFontStyles);
17   CFX_GEFont(IFX_FontMgr* pFontMgr);
18   ~CFX_GEFont();
19   virtual void Release();
20   virtual IFX_Font* Retain();
21   FX_BOOL LoadFont(const FX_WCHAR* pszFontFamily,
22                    FX_DWORD dwFontStyles,
23                    FX_WORD wCodePage);
24   FX_BOOL LoadFont(const uint8_t* pBuffer, int32_t length);
25   FX_BOOL LoadFont(const FX_WCHAR* pszFileName);
26   FX_BOOL LoadFont(IFX_Stream* pFontStream, FX_BOOL bSaveStream);
27   FX_BOOL LoadFont(CFX_Font* pExtFont, FX_BOOL bTakeOver = FALSE);
28   virtual IFX_Font* Derive(FX_DWORD dwFontStyles, FX_WORD wCodePage = 0);
29   virtual void GetFamilyName(CFX_WideString& wsFamily) const;
30   virtual void GetPsName(CFX_WideString& wsName) const;
31   virtual FX_DWORD GetFontStyles() const;
32   virtual uint8_t GetCharSet() const;
33   virtual FX_BOOL GetCharWidth(FX_WCHAR wUnicode,
34                                int32_t& iWidth,
35                                FX_BOOL bCharCode = FALSE);
36   virtual int32_t GetGlyphIndex(FX_WCHAR wUnicode, FX_BOOL bCharCode = FALSE);
37   virtual int32_t GetAscent() const;
38   virtual int32_t GetDescent() const;
39   virtual FX_BOOL GetCharBBox(FX_WCHAR wUnicode,
40                               CFX_Rect& bbox,
41                               FX_BOOL bCharCode = FALSE);
42   virtual FX_BOOL GetBBox(CFX_Rect& bbox);
43   virtual int32_t GetItalicAngle() const;
44   virtual void Reset();
45   virtual IFX_Font* GetSubstFont(int32_t iGlyphIndex) const;
GetDevFont()46   virtual void* GetDevFont() const { return (void*)m_pFont; }
SetFontProvider(IFX_FontProvider * pProvider)47   virtual void SetFontProvider(IFX_FontProvider* pProvider) {
48     m_pProvider = pProvider;
49   }
50 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
SetLogicalFontStyle(FX_DWORD dwLogFontStyle)51   virtual void SetLogicalFontStyle(FX_DWORD dwLogFontStyle) {
52     m_bUseLogFontStyle = TRUE;
53     m_dwLogFontStyle = dwLogFontStyle;
54   };
55 #endif
56  protected:
57 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
58   FX_BOOL m_bUseLogFontStyle;
59   FX_DWORD m_dwLogFontStyle;
60 #endif
61   CFX_Font* m_pFont;
62   IFX_FontMgr* m_pFontMgr;
63   int32_t m_iRefCount;
64   FX_BOOL m_bExtFont;
65   IFX_Stream* m_pStream;
66   IFX_FileRead* m_pFileRead;
67   CFX_UnicodeEncoding* m_pFontEncoding;
68   CFX_WordDiscreteArray* m_pCharWidthMap;
69   CFX_RectMassArray* m_pRectArray;
70   CFX_MapPtrToPtr* m_pBBoxMap;
71   IFX_FontProvider* m_pProvider;
72   FX_WORD m_wCharSet;
73   CFX_PtrArray m_SubstFonts;
74   CFX_MapPtrToPtr m_FontMapper;
75   FX_BOOL InitFont();
76   FX_BOOL GetCharBBox(FX_WCHAR wUnicode,
77                       CFX_Rect& bbox,
78                       FX_BOOL bRecursive,
79                       FX_BOOL bCharCode = FALSE);
80   FX_BOOL GetCharWidth(FX_WCHAR wUnicode,
81                        int32_t& iWidth,
82                        FX_BOOL bRecursive,
83                        FX_BOOL bCharCode = FALSE);
84   int32_t GetGlyphIndex(FX_WCHAR wUnicode,
85                         FX_BOOL bRecursive,
86                         IFX_Font** ppFont,
87                         FX_BOOL bCharCode = FALSE);
88 };
89 #endif
90 #endif
91