OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 CORE_FPDFAPI_FPDF_FONT_INCLUDE_CPDF_FONT_H_ | 7 #ifndef CORE_FPDFAPI_FPDF_FONT_INCLUDE_CPDF_FONT_H_ |
8 #define CORE_FPDFAPI_FPDF_FONT_INCLUDE_CPDF_FONT_H_ | 8 #define CORE_FPDFAPI_FPDF_FONT_INCLUDE_CPDF_FONT_H_ |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 virtual bool IsCIDFont() const; | 52 virtual bool IsCIDFont() const; |
53 virtual const CPDF_Type1Font* AsType1Font() const; | 53 virtual const CPDF_Type1Font* AsType1Font() const; |
54 virtual CPDF_Type1Font* AsType1Font(); | 54 virtual CPDF_Type1Font* AsType1Font(); |
55 virtual const CPDF_TrueTypeFont* AsTrueTypeFont() const; | 55 virtual const CPDF_TrueTypeFont* AsTrueTypeFont() const; |
56 virtual CPDF_TrueTypeFont* AsTrueTypeFont(); | 56 virtual CPDF_TrueTypeFont* AsTrueTypeFont(); |
57 virtual const CPDF_Type3Font* AsType3Font() const; | 57 virtual const CPDF_Type3Font* AsType3Font() const; |
58 virtual CPDF_Type3Font* AsType3Font(); | 58 virtual CPDF_Type3Font* AsType3Font(); |
59 virtual const CPDF_CIDFont* AsCIDFont() const; | 59 virtual const CPDF_CIDFont* AsCIDFont() const; |
60 virtual CPDF_CIDFont* AsCIDFont(); | 60 virtual CPDF_CIDFont* AsCIDFont(); |
61 | 61 |
62 virtual FX_BOOL IsVertWriting() const; | 62 virtual bool IsVertWriting() const; |
63 virtual FX_BOOL IsUnicodeCompatible() const; | 63 virtual bool IsUnicodeCompatible() const; |
64 virtual uint32_t GetNextChar(const FX_CHAR* pString, | 64 virtual uint32_t GetNextChar(const FX_CHAR* pString, |
65 int nStrLen, | 65 int nStrLen, |
66 int& offset) const; | 66 int& offset) const; |
67 virtual int CountChar(const FX_CHAR* pString, int size) const; | 67 virtual int CountChar(const FX_CHAR* pString, int size) const; |
68 virtual int AppendChar(FX_CHAR* buf, uint32_t charcode) const; | 68 virtual int AppendChar(FX_CHAR* buf, uint32_t charcode) const; |
69 virtual int GetCharSize(uint32_t charcode) const; | 69 virtual int GetCharSize(uint32_t charcode) const; |
70 virtual int GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) = 0; | 70 virtual int GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) = 0; |
71 virtual int GlyphFromCharCodeExt(uint32_t charcode); | 71 virtual int GlyphFromCharCodeExt(uint32_t charcode); |
72 virtual CFX_WideString UnicodeFromCharCode(uint32_t charcode) const; | 72 virtual CFX_WideString UnicodeFromCharCode(uint32_t charcode) const; |
73 virtual uint32_t CharCodeFromUnicode(FX_WCHAR Unicode) const; | 73 virtual uint32_t CharCodeFromUnicode(FX_WCHAR Unicode) const; |
74 | 74 |
75 const CFX_ByteString& GetBaseFont() const { return m_BaseFont; } | 75 const CFX_ByteString& GetBaseFont() const { return m_BaseFont; } |
76 CFX_SubstFont* GetSubstFont() const { return m_Font.GetSubstFont(); } | 76 CFX_SubstFont* GetSubstFont() const { return m_Font.GetSubstFont(); } |
77 uint32_t GetFlags() const { return m_Flags; } | 77 uint32_t GetFlags() const { return m_Flags; } |
78 FX_BOOL IsEmbedded() const { return IsType3Font() || m_pFontFile != nullptr; } | 78 bool IsEmbedded() const { return IsType3Font() || m_pFontFile != nullptr; } |
79 CPDF_StreamAcc* GetFontFile() const { return m_pFontFile; } | 79 CPDF_StreamAcc* GetFontFile() const { return m_pFontFile; } |
80 CPDF_Dictionary* GetFontDict() const { return m_pFontDict; } | 80 CPDF_Dictionary* GetFontDict() const { return m_pFontDict; } |
81 FX_BOOL IsStandardFont() const; | 81 bool IsStandardFont() const; |
82 FXFT_Face GetFace() const { return m_Font.GetFace(); } | 82 FXFT_Face GetFace() const { return m_Font.GetFace(); } |
83 void AppendChar(CFX_ByteString& str, uint32_t charcode) const; | 83 void AppendChar(CFX_ByteString& str, uint32_t charcode) const; |
84 | 84 |
85 void GetFontBBox(FX_RECT& rect) const { rect = m_FontBBox; } | 85 void GetFontBBox(FX_RECT& rect) const { rect = m_FontBBox; } |
86 int GetTypeAscent() const { return m_Ascent; } | 86 int GetTypeAscent() const { return m_Ascent; } |
87 int GetTypeDescent() const { return m_Descent; } | 87 int GetTypeDescent() const { return m_Descent; } |
88 int GetItalicAngle() const { return m_ItalicAngle; } | 88 int GetItalicAngle() const { return m_ItalicAngle; } |
89 int GetStemV() const { return m_StemV; } | 89 int GetStemV() const { return m_StemV; } |
90 int GetStringWidth(const FX_CHAR* pString, int size); | 90 int GetStringWidth(const FX_CHAR* pString, int size); |
91 uint32_t FallbackFontFromCharcode(uint32_t charcode); | 91 uint32_t FallbackFontFromCharcode(uint32_t charcode); |
92 int FallbackGlyphFromCharcode(int fallbackFont, uint32_t charcode); | 92 int FallbackGlyphFromCharcode(int fallbackFont, uint32_t charcode); |
93 | 93 |
94 virtual int GetCharWidthF(uint32_t charcode, int level = 0) = 0; | 94 virtual int GetCharWidthF(uint32_t charcode, int level = 0) = 0; |
95 virtual FX_RECT GetCharBBox(uint32_t charcode, int level = 0) = 0; | 95 virtual FX_RECT GetCharBBox(uint32_t charcode, int level = 0) = 0; |
96 | 96 |
97 CPDF_Document* m_pDocument; | 97 CPDF_Document* m_pDocument; |
98 CFX_Font m_Font; | 98 CFX_Font m_Font; |
99 std::vector<std::unique_ptr<CFX_Font>> m_FontFallbacks; | 99 std::vector<std::unique_ptr<CFX_Font>> m_FontFallbacks; |
100 | 100 |
101 protected: | 101 protected: |
102 CPDF_Font(); | 102 CPDF_Font(); |
103 | 103 |
104 virtual FX_BOOL Load() = 0; | 104 virtual bool Load() = 0; |
105 | 105 |
106 FX_BOOL Initialize(); | |
107 void LoadUnicodeMap() const; // logically const only. | 106 void LoadUnicodeMap() const; // logically const only. |
108 void LoadPDFEncoding(CPDF_Object* pEncoding, | 107 void LoadPDFEncoding(CPDF_Object* pEncoding, |
109 int& iBaseEncoding, | 108 int& iBaseEncoding, |
110 std::vector<CFX_ByteString>* pCharNames, | 109 std::vector<CFX_ByteString>* pCharNames, |
111 FX_BOOL bEmbedded, | 110 bool bEmbedded, |
112 FX_BOOL bTrueType); | 111 bool bTrueType); |
113 void LoadFontDescriptor(CPDF_Dictionary* pDict); | 112 void LoadFontDescriptor(CPDF_Dictionary* pDict); |
114 void CheckFontMetrics(); | 113 void CheckFontMetrics(); |
115 | 114 |
116 const FX_CHAR* GetAdobeCharName(int iBaseEncoding, | 115 const FX_CHAR* GetAdobeCharName(int iBaseEncoding, |
117 const std::vector<CFX_ByteString>& charnames, | 116 const std::vector<CFX_ByteString>& charnames, |
118 int charcode); | 117 int charcode); |
119 | 118 |
120 CFX_ByteString m_BaseFont; | 119 CFX_ByteString m_BaseFont; |
121 CPDF_StreamAcc* m_pFontFile; | 120 CPDF_StreamAcc* m_pFontFile; |
122 CPDF_Dictionary* m_pFontDict; | 121 CPDF_Dictionary* m_pFontDict; |
123 mutable std::unique_ptr<CPDF_ToUnicodeMap> m_pToUnicodeMap; | 122 mutable std::unique_ptr<CPDF_ToUnicodeMap> m_pToUnicodeMap; |
124 mutable FX_BOOL m_bToUnicodeLoaded; | 123 mutable bool m_bToUnicodeLoaded; |
125 int m_Flags; | 124 int m_Flags; |
126 FX_RECT m_FontBBox; | 125 FX_RECT m_FontBBox; |
127 int m_StemV; | 126 int m_StemV; |
128 int m_Ascent; | 127 int m_Ascent; |
129 int m_Descent; | 128 int m_Descent; |
130 int m_ItalicAngle; | 129 int m_ItalicAngle; |
131 }; | 130 }; |
132 | 131 |
133 #endif // CORE_FPDFAPI_FPDF_FONT_INCLUDE_CPDF_FONT_H_ | 132 #endif // CORE_FPDFAPI_FPDF_FONT_INCLUDE_CPDF_FONT_H_ |
OLD | NEW |