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> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 ~CFGAS_GEFont() override; | 49 ~CFGAS_GEFont() override; |
50 | 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) const; |
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 | 73 |
74 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 74 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
75 bool LoadFontInternal(const FX_WCHAR* pszFontFamily, | 75 bool LoadFontInternal(const FX_WCHAR* pszFontFamily, |
76 uint32_t dwFontStyles, | 76 uint32_t dwFontStyles, |
77 uint16_t wCodePage); | 77 uint16_t wCodePage); |
78 bool LoadFontInternal(const uint8_t* pBuffer, int32_t length); | 78 bool LoadFontInternal(const uint8_t* pBuffer, int32_t length); |
79 bool LoadFontInternal(const CFX_RetainPtr<IFGAS_Stream>& pFontStream, | 79 bool LoadFontInternal(const CFX_RetainPtr<IFGAS_Stream>& pFontStream, |
80 bool bSaveStream); | 80 bool bSaveStream); |
81 #endif | 81 #endif |
82 bool LoadFontInternal(CFX_Font* pExternalFont); | 82 bool LoadFontInternal(CFX_Font* pExternalFont); |
83 bool LoadFontInternal(std::unique_ptr<CFX_Font> pInternalFont); | 83 bool LoadFontInternal(std::unique_ptr<CFX_Font> pInternalFont); |
84 bool InitFont(); | 84 bool InitFont(); |
85 bool GetCharBBoxInternal(FX_WCHAR wUnicode, | 85 bool GetCharBBoxInternal(FX_WCHAR wUnicode, |
86 CFX_Rect& bbox, | 86 CFX_Rect* bbox, |
87 bool bRecursive, | 87 bool bRecursive, |
88 bool bCharCode = false); | 88 bool bCharCode = false); |
89 bool GetCharWidthInternal(FX_WCHAR wUnicode, | 89 bool GetCharWidthInternal(FX_WCHAR wUnicode, |
90 int32_t& iWidth, | 90 int32_t& iWidth, |
91 bool bRecursive, | 91 bool bRecursive, |
92 bool bCharCode); | 92 bool bCharCode); |
93 int32_t GetGlyphIndex(FX_WCHAR wUnicode, | 93 int32_t GetGlyphIndex(FX_WCHAR wUnicode, |
94 bool bRecursive, | 94 bool bRecursive, |
95 CFX_RetainPtr<CFGAS_GEFont>* ppFont, | 95 CFX_RetainPtr<CFGAS_GEFont>* ppFont, |
96 bool bCharCode = false); | 96 bool bCharCode = false); |
97 CFX_WideString GetFamilyName() const; | 97 CFX_WideString GetFamilyName() const; |
98 | 98 |
99 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 99 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
100 bool m_bUseLogFontStyle; | 100 bool m_bUseLogFontStyle; |
101 uint32_t m_dwLogFontStyle; | 101 uint32_t m_dwLogFontStyle; |
102 #endif | 102 #endif |
103 CFX_Font* m_pFont; | 103 CFX_Font* m_pFont; |
104 CFX_RetainPtr<CFGAS_GEFont> m_pSrcFont; // Only set by ctor, so no cycles. | 104 CFX_RetainPtr<CFGAS_GEFont> m_pSrcFont; // Only set by ctor, so no cycles. |
105 CFGAS_FontMgr* const m_pFontMgr; | 105 CFGAS_FontMgr* const m_pFontMgr; |
106 bool m_bExternalFont; | 106 bool m_bExternalFont; |
107 CFX_RetainPtr<IFGAS_Stream> m_pStream; | 107 CFX_RetainPtr<IFGAS_Stream> m_pStream; |
108 CFX_RetainPtr<IFX_SeekableReadStream> m_pFileRead; | 108 CFX_RetainPtr<IFX_SeekableReadStream> m_pFileRead; |
109 std::unique_ptr<CFX_UnicodeEncoding> m_pFontEncoding; | 109 std::unique_ptr<CFX_UnicodeEncoding> m_pFontEncoding; |
110 std::unique_ptr<CFX_DiscreteArrayTemplate<uint16_t>> m_pCharWidthMap; | 110 std::unique_ptr<CFX_DiscreteArrayTemplate<uint16_t>> m_pCharWidthMap; |
111 std::unique_ptr<CFX_MassArrayTemplate<CFX_Rect>> m_pRectArray; | 111 std::unique_ptr<CFX_MassArrayTemplate<CFX_Rect>> m_pRectArray; |
112 std::unique_ptr<CFX_MapPtrToPtr> m_pBBoxMap; | 112 std::map<FX_WCHAR, CFX_Rect*> m_BBoxMap; // Rect owned by m_pRectArray. |
113 CXFA_PDFFontMgr* m_pProvider; // not owned. | 113 CXFA_PDFFontMgr* m_pProvider; // not owned. |
114 std::vector<CFX_RetainPtr<CFGAS_GEFont>> m_SubstFonts; | 114 std::vector<CFX_RetainPtr<CFGAS_GEFont>> m_SubstFonts; |
115 std::map<FX_WCHAR, CFX_RetainPtr<CFGAS_GEFont>> m_FontMapper; | 115 std::map<FX_WCHAR, CFX_RetainPtr<CFGAS_GEFont>> m_FontMapper; |
116 }; | 116 }; |
117 | 117 |
118 #endif // XFA_FGAS_FONT_CFGAS_GEFONT_H_ | 118 #endif // XFA_FGAS_FONT_CFGAS_GEFONT_H_ |
OLD | NEW |