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