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