| 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_FGAS_GEFONT_H_ | 7 #ifndef XFA_FGAS_FONT_CFGAS_GEFONT_H_ |
| 8 #define XFA_FGAS_FONT_FGAS_GEFONT_H_ | 8 #define XFA_FGAS_FONT_CFGAS_GEFONT_H_ |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 | 11 |
| 12 #include "core/fxcrt/fx_memory.h" | 12 #include "core/fxcrt/fx_memory.h" |
| 13 #include "xfa/fgas/crt/fgas_utils.h" | 13 #include "xfa/fgas/crt/fgas_utils.h" |
| 14 #include "xfa/fgas/font/cfgas_fontmgr.h" | 14 #include "xfa/fgas/font/cfgas_fontmgr.h" |
| 15 | 15 |
| 16 #define FXFONT_SUBST_ITALIC 0x02 | 16 #define FXFONT_SUBST_ITALIC 0x02 |
| 17 | 17 |
| 18 class CFX_UnicodeEncoding; | 18 class CFX_UnicodeEncoding; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 35 static CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream, | 35 static CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream, |
| 36 CFGAS_FontMgr* pFontMgr, | 36 CFGAS_FontMgr* pFontMgr, |
| 37 bool bSaveStream); | 37 bool bSaveStream); |
| 38 #endif | 38 #endif |
| 39 | 39 |
| 40 ~CFGAS_GEFont(); | 40 ~CFGAS_GEFont(); |
| 41 | 41 |
| 42 void Release(); | 42 void Release(); |
| 43 CFGAS_GEFont* Retain(); | 43 CFGAS_GEFont* Retain(); |
| 44 CFGAS_GEFont* Derive(uint32_t dwFontStyles, uint16_t wCodePage = 0); | 44 CFGAS_GEFont* Derive(uint32_t dwFontStyles, uint16_t wCodePage = 0); |
| 45 void GetFamilyName(CFX_WideString& wsFamily) const; | |
| 46 uint32_t GetFontStyles() const; | 45 uint32_t GetFontStyles() const; |
| 47 bool GetCharWidth(FX_WCHAR wUnicode, int32_t& iWidth, bool bCharCode); | 46 bool GetCharWidth(FX_WCHAR wUnicode, int32_t& iWidth, bool bCharCode); |
| 48 int32_t GetGlyphIndex(FX_WCHAR wUnicode, bool bCharCode = false); | 47 int32_t GetGlyphIndex(FX_WCHAR wUnicode, bool bCharCode = false); |
| 49 int32_t GetAscent() const; | 48 int32_t GetAscent() const; |
| 50 int32_t GetDescent() const; | 49 int32_t GetDescent() const; |
| 51 bool GetCharBBox(FX_WCHAR wUnicode, CFX_Rect& bbox, bool bCharCode = false); | 50 bool GetCharBBox(FX_WCHAR wUnicode, CFX_Rect& bbox, bool bCharCode = false); |
| 52 bool GetBBox(CFX_Rect& bbox); | 51 bool GetBBox(CFX_Rect& bbox); |
| 53 int32_t GetItalicAngle() const; | |
| 54 void Reset(); | |
| 55 CFGAS_GEFont* GetSubstFont(int32_t iGlyphIndex) const; | 52 CFGAS_GEFont* GetSubstFont(int32_t iGlyphIndex) const; |
| 56 CFX_Font* GetDevFont() const { return m_pFont; } | 53 CFX_Font* GetDevFont() const { return m_pFont; } |
| 57 void SetFontProvider(CXFA_PDFFontMgr* pProvider) { m_pProvider = pProvider; } | 54 void SetFontProvider(CXFA_PDFFontMgr* pProvider) { m_pProvider = pProvider; } |
| 58 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 55 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| 59 void SetLogicalFontStyle(uint32_t dwLogFontStyle) { | 56 void SetLogicalFontStyle(uint32_t dwLogFontStyle) { |
| 60 m_bUseLogFontStyle = true; | 57 m_bUseLogFontStyle = true; |
| 61 m_dwLogFontStyle = dwLogFontStyle; | 58 m_dwLogFontStyle = dwLogFontStyle; |
| 62 } | 59 } |
| 63 #endif | 60 #endif |
| 64 | 61 |
| 65 protected: | 62 private: |
| 66 explicit CFGAS_GEFont(CFGAS_FontMgr* pFontMgr); | 63 explicit CFGAS_GEFont(CFGAS_FontMgr* pFontMgr); |
| 67 CFGAS_GEFont(CFGAS_GEFont* src, uint32_t dwFontStyles); | 64 CFGAS_GEFont(CFGAS_GEFont* src, uint32_t dwFontStyles); |
| 68 | 65 |
| 69 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 66 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 70 bool LoadFontInternal(const FX_WCHAR* pszFontFamily, | 67 bool LoadFontInternal(const FX_WCHAR* pszFontFamily, |
| 71 uint32_t dwFontStyles, | 68 uint32_t dwFontStyles, |
| 72 uint16_t wCodePage); | 69 uint16_t wCodePage); |
| 73 bool LoadFontInternal(const uint8_t* pBuffer, int32_t length); | 70 bool LoadFontInternal(const uint8_t* pBuffer, int32_t length); |
| 74 bool LoadFontInternal(IFX_Stream* pFontStream, bool bSaveStream); | 71 bool LoadFontInternal(IFX_Stream* pFontStream, bool bSaveStream); |
| 75 #endif | 72 #endif |
| 76 bool LoadFontInternal(CFX_Font* pExternalFont); | 73 bool LoadFontInternal(CFX_Font* pExternalFont); |
| 77 bool LoadFontInternal(std::unique_ptr<CFX_Font> pInternalFont); | 74 bool LoadFontInternal(std::unique_ptr<CFX_Font> pInternalFont); |
| 78 bool InitFont(); | 75 bool InitFont(); |
| 79 bool GetCharBBoxInternal(FX_WCHAR wUnicode, | 76 bool GetCharBBoxInternal(FX_WCHAR wUnicode, |
| 80 CFX_Rect& bbox, | 77 CFX_Rect& bbox, |
| 81 bool bRecursive, | 78 bool bRecursive, |
| 82 bool bCharCode = false); | 79 bool bCharCode = false); |
| 83 bool GetCharWidthInternal(FX_WCHAR wUnicode, | 80 bool GetCharWidthInternal(FX_WCHAR wUnicode, |
| 84 int32_t& iWidth, | 81 int32_t& iWidth, |
| 85 bool bRecursive, | 82 bool bRecursive, |
| 86 bool bCharCode); | 83 bool bCharCode); |
| 87 int32_t GetGlyphIndex(FX_WCHAR wUnicode, | 84 int32_t GetGlyphIndex(FX_WCHAR wUnicode, |
| 88 bool bRecursive, | 85 bool bRecursive, |
| 89 CFGAS_GEFont** ppFont, | 86 CFGAS_GEFont** ppFont, |
| 90 bool bCharCode = false); | 87 bool bCharCode = false); |
| 88 CFX_WideString GetFamilyName() const; |
| 91 | 89 |
| 92 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 90 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| 93 bool m_bUseLogFontStyle; | 91 bool m_bUseLogFontStyle; |
| 94 uint32_t m_dwLogFontStyle; | 92 uint32_t m_dwLogFontStyle; |
| 95 #endif | 93 #endif |
| 96 CFX_Font* m_pFont; | 94 CFX_Font* m_pFont; |
| 97 CFGAS_GEFont* const m_pSrcFont; | 95 CFGAS_GEFont* const m_pSrcFont; |
| 98 CFGAS_FontMgr* const m_pFontMgr; | 96 CFGAS_FontMgr* const m_pFontMgr; |
| 99 int32_t m_iRefCount; | 97 int32_t m_iRefCount; |
| 100 bool m_bExternalFont; | 98 bool m_bExternalFont; |
| 101 std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> m_pStream; | 99 std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> m_pStream; |
| 102 std::unique_ptr<IFX_SeekableReadStream, | 100 std::unique_ptr<IFX_SeekableReadStream, |
| 103 ReleaseDeleter<IFX_SeekableReadStream>> | 101 ReleaseDeleter<IFX_SeekableReadStream>> |
| 104 m_pFileRead; | 102 m_pFileRead; |
| 105 std::unique_ptr<CFX_UnicodeEncoding> m_pFontEncoding; | 103 std::unique_ptr<CFX_UnicodeEncoding> m_pFontEncoding; |
| 106 std::unique_ptr<CFX_DiscreteArrayTemplate<uint16_t>> m_pCharWidthMap; | 104 std::unique_ptr<CFX_DiscreteArrayTemplate<uint16_t>> m_pCharWidthMap; |
| 107 std::unique_ptr<CFX_MassArrayTemplate<CFX_Rect>> m_pRectArray; | 105 std::unique_ptr<CFX_MassArrayTemplate<CFX_Rect>> m_pRectArray; |
| 108 std::unique_ptr<CFX_MapPtrToPtr> m_pBBoxMap; | 106 std::unique_ptr<CFX_MapPtrToPtr> m_pBBoxMap; |
| 109 CXFA_PDFFontMgr* m_pProvider; // not owned. | 107 CXFA_PDFFontMgr* m_pProvider; // not owned. |
| 110 CFX_ArrayTemplate<CFGAS_GEFont*> m_SubstFonts; | 108 CFX_ArrayTemplate<CFGAS_GEFont*> m_SubstFonts; |
| 111 std::map<FX_WCHAR, CFGAS_GEFont*> m_FontMapper; | 109 std::map<FX_WCHAR, CFGAS_GEFont*> m_FontMapper; |
| 112 }; | 110 }; |
| 113 | 111 |
| 114 #endif // XFA_FGAS_FONT_FGAS_GEFONT_H_ | 112 #endif // XFA_FGAS_FONT_CFGAS_GEFONT_H_ |
| OLD | NEW |