| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef XFA_FGAS_FONT_CFGAS_GEFONT_H_ | 7 #ifndef XFA_FGAS_FONT_CFGAS_GEFONT_H_ |
| 8 #define XFA_FGAS_FONT_CFGAS_GEFONT_H_ | 8 #define XFA_FGAS_FONT_CFGAS_GEFONT_H_ |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "core/fxcrt/cfx_retain_ptr.h" | 14 #include "core/fxcrt/cfx_retain_ptr.h" |
| 15 #include "core/fxcrt/fx_memory.h" | 15 #include "core/fxcrt/fx_memory.h" |
| 16 #include "xfa/fgas/crt/fgas_utils.h" | 16 #include "xfa/fgas/crt/fgas_utils.h" |
| 17 #include "xfa/fgas/font/cfgas_fontmgr.h" | 17 #include "xfa/fgas/font/cfgas_fontmgr.h" |
| 18 | 18 |
| 19 #define FXFONT_SUBST_ITALIC 0x02 | 19 #define FXFONT_SUBST_ITALIC 0x02 |
| 20 | 20 |
| 21 class CFGAS_FontMgr; | 21 class CFGAS_FontMgr; |
| 22 class CFX_UnicodeEncoding; | 22 class CFX_UnicodeEncoding; |
| 23 class CXFA_PDFFontMgr; | 23 class CXFA_PDFFontMgr; |
| 24 | 24 |
| 25 class CFGAS_GEFont : public CFX_Retainable { | 25 class CFGAS_GEFont : public CFX_Retainable { |
| 26 public: | 26 public: |
| 27 template <typename T, typename... Args> | 27 template <typename T, typename... Args> |
| 28 friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args); | 28 friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args); |
| 29 template <typename T> |
| 30 friend class CFX_RetainPtr; |
| 29 | 31 |
| 30 static CFX_RetainPtr<CFGAS_GEFont> LoadFont(const FX_WCHAR* pszFontFamily, | 32 static CFX_RetainPtr<CFGAS_GEFont> LoadFont(const FX_WCHAR* pszFontFamily, |
| 31 uint32_t dwFontStyles, | 33 uint32_t dwFontStyles, |
| 32 uint16_t wCodePage, | 34 uint16_t wCodePage, |
| 33 CFGAS_FontMgr* pFontMgr); | 35 CFGAS_FontMgr* pFontMgr); |
| 34 static CFX_RetainPtr<CFGAS_GEFont> LoadFont(CFX_Font* pExternalFont, | 36 static CFX_RetainPtr<CFGAS_GEFont> LoadFont(CFX_Font* pExternalFont, |
| 35 CFGAS_FontMgr* pFontMgr); | 37 CFGAS_FontMgr* pFontMgr); |
| 36 static CFX_RetainPtr<CFGAS_GEFont> LoadFont( | 38 static CFX_RetainPtr<CFGAS_GEFont> LoadFont( |
| 37 std::unique_ptr<CFX_Font> pInternalFont, | 39 std::unique_ptr<CFX_Font> pInternalFont, |
| 38 CFGAS_FontMgr* pFontMgr); | 40 CFGAS_FontMgr* pFontMgr); |
| 39 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 41 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 40 static CFX_RetainPtr<CFGAS_GEFont> LoadFont(const uint8_t* pBuffer, | 42 static CFX_RetainPtr<CFGAS_GEFont> LoadFont(const uint8_t* pBuffer, |
| 41 int32_t iLength, | 43 int32_t iLength, |
| 42 CFGAS_FontMgr* pFontMgr); | 44 CFGAS_FontMgr* pFontMgr); |
| 43 static CFX_RetainPtr<CFGAS_GEFont> LoadFont( | 45 static CFX_RetainPtr<CFGAS_GEFont> LoadFont( |
| 44 const CFX_RetainPtr<IFGAS_Stream>& pFontStream, | 46 const CFX_RetainPtr<IFGAS_Stream>& pFontStream, |
| 45 CFGAS_FontMgr* pFontMgr, | 47 CFGAS_FontMgr* pFontMgr, |
| 46 bool bSaveStream); | 48 bool bSaveStream); |
| 47 #endif | 49 #endif |
| 48 | 50 |
| 49 ~CFGAS_GEFont() override; | |
| 50 | |
| 51 CFX_RetainPtr<CFGAS_GEFont> Derive(uint32_t dwFontStyles, | 51 CFX_RetainPtr<CFGAS_GEFont> Derive(uint32_t dwFontStyles, |
| 52 uint16_t wCodePage = 0); | 52 uint16_t wCodePage = 0); |
| 53 uint32_t GetFontStyles() const; | 53 uint32_t GetFontStyles() const; |
| 54 bool GetCharWidth(FX_WCHAR wUnicode, int32_t& iWidth, bool bCharCode); | 54 bool GetCharWidth(FX_WCHAR wUnicode, int32_t& iWidth, bool bCharCode); |
| 55 int32_t GetGlyphIndex(FX_WCHAR wUnicode, bool bCharCode = false); | 55 int32_t GetGlyphIndex(FX_WCHAR wUnicode, bool bCharCode = false); |
| 56 int32_t GetAscent() const; | 56 int32_t GetAscent() const; |
| 57 int32_t GetDescent() const; | 57 int32_t GetDescent() const; |
| 58 bool GetCharBBox(FX_WCHAR wUnicode, CFX_Rect* bbox, bool bCharCode = false); | 58 bool GetCharBBox(FX_WCHAR wUnicode, CFX_Rect* bbox, bool bCharCode = false); |
| 59 bool GetBBox(CFX_Rect* bbox); | 59 bool GetBBox(CFX_Rect* bbox); |
| 60 CFX_RetainPtr<CFGAS_GEFont> GetSubstFont(int32_t iGlyphIndex) const; | 60 CFX_RetainPtr<CFGAS_GEFont> GetSubstFont(int32_t iGlyphIndex); |
| 61 CFX_Font* GetDevFont() const { return m_pFont; } | 61 CFX_Font* GetDevFont() const { return m_pFont; } |
| 62 void SetFontProvider(CXFA_PDFFontMgr* pProvider) { m_pProvider = pProvider; } | 62 void SetFontProvider(CXFA_PDFFontMgr* pProvider) { m_pProvider = pProvider; } |
| 63 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 63 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| 64 void SetLogicalFontStyle(uint32_t dwLogFontStyle) { | 64 void SetLogicalFontStyle(uint32_t dwLogFontStyle) { |
| 65 m_bUseLogFontStyle = true; | 65 m_bUseLogFontStyle = true; |
| 66 m_dwLogFontStyle = dwLogFontStyle; | 66 m_dwLogFontStyle = dwLogFontStyle; |
| 67 } | 67 } |
| 68 #endif | 68 #endif |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 explicit CFGAS_GEFont(CFGAS_FontMgr* pFontMgr); | 71 explicit CFGAS_GEFont(CFGAS_FontMgr* pFontMgr); |
| 72 CFGAS_GEFont(const CFX_RetainPtr<CFGAS_GEFont>& src, uint32_t dwFontStyles); | 72 CFGAS_GEFont(const CFX_RetainPtr<CFGAS_GEFont>& src, uint32_t dwFontStyles); |
| 73 ~CFGAS_GEFont() override; |
| 73 | 74 |
| 74 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 75 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 75 bool LoadFontInternal(const FX_WCHAR* pszFontFamily, | 76 bool LoadFontInternal(const FX_WCHAR* pszFontFamily, |
| 76 uint32_t dwFontStyles, | 77 uint32_t dwFontStyles, |
| 77 uint16_t wCodePage); | 78 uint16_t wCodePage); |
| 78 bool LoadFontInternal(const uint8_t* pBuffer, int32_t length); | 79 bool LoadFontInternal(const uint8_t* pBuffer, int32_t length); |
| 79 bool LoadFontInternal(const CFX_RetainPtr<IFGAS_Stream>& pFontStream, | 80 bool LoadFontInternal(const CFX_RetainPtr<IFGAS_Stream>& pFontStream, |
| 80 bool bSaveStream); | 81 bool bSaveStream); |
| 81 #endif | 82 #endif |
| 82 bool LoadFontInternal(CFX_Font* pExternalFont); | 83 bool LoadFontInternal(CFX_Font* pExternalFont); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 109 std::unique_ptr<CFX_UnicodeEncoding> m_pFontEncoding; | 110 std::unique_ptr<CFX_UnicodeEncoding> m_pFontEncoding; |
| 110 std::unique_ptr<CFX_DiscreteArrayTemplate<uint16_t>> m_pCharWidthMap; | 111 std::unique_ptr<CFX_DiscreteArrayTemplate<uint16_t>> m_pCharWidthMap; |
| 111 std::unique_ptr<CFX_MassArrayTemplate<CFX_Rect>> m_pRectArray; | 112 std::unique_ptr<CFX_MassArrayTemplate<CFX_Rect>> m_pRectArray; |
| 112 std::map<FX_WCHAR, CFX_Rect*> m_BBoxMap; // Rect owned by m_pRectArray. | 113 std::map<FX_WCHAR, CFX_Rect*> m_BBoxMap; // Rect owned by m_pRectArray. |
| 113 CXFA_PDFFontMgr* m_pProvider; // not owned. | 114 CXFA_PDFFontMgr* m_pProvider; // not owned. |
| 114 std::vector<CFX_RetainPtr<CFGAS_GEFont>> m_SubstFonts; | 115 std::vector<CFX_RetainPtr<CFGAS_GEFont>> m_SubstFonts; |
| 115 std::map<FX_WCHAR, CFX_RetainPtr<CFGAS_GEFont>> m_FontMapper; | 116 std::map<FX_WCHAR, CFX_RetainPtr<CFGAS_GEFont>> m_FontMapper; |
| 116 }; | 117 }; |
| 117 | 118 |
| 118 #endif // XFA_FGAS_FONT_CFGAS_GEFONT_H_ | 119 #endif // XFA_FGAS_FONT_CFGAS_GEFONT_H_ |
| OLD | NEW |