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 CORE_INCLUDE_FXGE_FX_FONT_H_ | 7 #ifndef CORE_INCLUDE_FXGE_FX_FONT_H_ |
8 #define CORE_INCLUDE_FXGE_FX_FONT_H_ | 8 #define CORE_INCLUDE_FXGE_FX_FONT_H_ |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 18 matching lines...) Expand all Loading... | |
29 #define FXFONT_FIXED_PITCH 0x01 | 29 #define FXFONT_FIXED_PITCH 0x01 |
30 #define FXFONT_SERIF 0x02 | 30 #define FXFONT_SERIF 0x02 |
31 #define FXFONT_SYMBOLIC 0x04 | 31 #define FXFONT_SYMBOLIC 0x04 |
32 #define FXFONT_SCRIPT 0x08 | 32 #define FXFONT_SCRIPT 0x08 |
33 #define FXFONT_ITALIC 0x40 | 33 #define FXFONT_ITALIC 0x40 |
34 #define FXFONT_BOLD 0x40000 | 34 #define FXFONT_BOLD 0x40000 |
35 #define FXFONT_USEEXTERNATTR 0x80000 | 35 #define FXFONT_USEEXTERNATTR 0x80000 |
36 #define FXFONT_CIDFONT 0x100000 | 36 #define FXFONT_CIDFONT 0x100000 |
37 #ifdef PDF_ENABLE_XFA | 37 #ifdef PDF_ENABLE_XFA |
38 #define FXFONT_EXACTMATCH 0x80000000 | 38 #define FXFONT_EXACTMATCH 0x80000000 |
39 #endif | 39 #endif // PDF_ENABLE_XFA |
40 #define FXFONT_ANSI_CHARSET 0 | 40 #define FXFONT_ANSI_CHARSET 0 |
41 #define FXFONT_DEFAULT_CHARSET 1 | 41 #define FXFONT_DEFAULT_CHARSET 1 |
42 #define FXFONT_SYMBOL_CHARSET 2 | 42 #define FXFONT_SYMBOL_CHARSET 2 |
43 #define FXFONT_SHIFTJIS_CHARSET 128 | 43 #define FXFONT_SHIFTJIS_CHARSET 128 |
44 #define FXFONT_HANGEUL_CHARSET 129 | 44 #define FXFONT_HANGEUL_CHARSET 129 |
45 #define FXFONT_GB2312_CHARSET 134 | 45 #define FXFONT_GB2312_CHARSET 134 |
46 #define FXFONT_CHINESEBIG5_CHARSET 136 | 46 #define FXFONT_CHINESEBIG5_CHARSET 136 |
47 #define FXFONT_THAI_CHARSET 222 | 47 #define FXFONT_THAI_CHARSET 222 |
48 #define FXFONT_EASTEUROPE_CHARSET 238 | 48 #define FXFONT_EASTEUROPE_CHARSET 238 |
49 #define FXFONT_RUSSIAN_CHARSET 204 | 49 #define FXFONT_RUSSIAN_CHARSET 204 |
(...skipping 14 matching lines...) Expand all Loading... | |
64 ~CFX_Font(); | 64 ~CFX_Font(); |
65 | 65 |
66 void LoadSubst(const CFX_ByteString& face_name, | 66 void LoadSubst(const CFX_ByteString& face_name, |
67 FX_BOOL bTrueType, | 67 FX_BOOL bTrueType, |
68 FX_DWORD flags, | 68 FX_DWORD flags, |
69 int weight, | 69 int weight, |
70 int italic_angle, | 70 int italic_angle, |
71 int CharsetCP, | 71 int CharsetCP, |
72 FX_BOOL bVertical = FALSE); | 72 FX_BOOL bVertical = FALSE); |
73 FX_BOOL LoadEmbedded(const uint8_t* data, FX_DWORD size); | 73 FX_BOOL LoadEmbedded(const uint8_t* data, FX_DWORD size); |
74 FXFT_Face GetFace() const { return m_Face; } | |
75 | |
74 #ifdef PDF_ENABLE_XFA | 76 #ifdef PDF_ENABLE_XFA |
75 | |
76 FX_BOOL LoadFile(IFX_FileRead* pFile, | 77 FX_BOOL LoadFile(IFX_FileRead* pFile, |
77 int nFaceIndex = 0, | 78 int nFaceIndex = 0, |
78 int* pFaceCount = NULL); | 79 int* pFaceCount = NULL); |
79 | 80 |
80 FX_BOOL LoadClone(const CFX_Font* pFont); | 81 FX_BOOL LoadClone(const CFX_Font* pFont); |
81 | |
82 #endif | |
83 FXFT_Face GetFace() const { return m_Face; } | |
84 #ifndef PDF_ENABLE_XFA | |
85 const CFX_SubstFont* GetSubstFont() const { return m_pSubstFont; } | |
86 #else | |
87 CFX_SubstFont* GetSubstFont() const { return m_pSubstFont; } | 82 CFX_SubstFont* GetSubstFont() const { return m_pSubstFont; } |
Lei Zhang
2015/11/25 21:49:01
For another CL: I wonder if we can make this match
Tom Sepez
2015/11/25 22:05:06
Yup, it touched a few places.
| |
88 void SetFace(FXFT_Face face) { m_Face = face; } | 83 void SetFace(FXFT_Face face) { m_Face = face; } |
89 void SetSubstFont(CFX_SubstFont* subst) { m_pSubstFont = subst; } | 84 void SetSubstFont(CFX_SubstFont* subst) { m_pSubstFont = subst; } |
90 #endif | 85 #else // PDF_ENABLE_XFA |
86 const CFX_SubstFont* GetSubstFont() const { return m_pSubstFont; } | |
87 #endif // PDF_ENABLE_XFA | |
88 | |
91 CFX_PathData* LoadGlyphPath(FX_DWORD glyph_index, int dest_width = 0); | 89 CFX_PathData* LoadGlyphPath(FX_DWORD glyph_index, int dest_width = 0); |
92 int GetGlyphWidth(FX_DWORD glyph_index); | 90 int GetGlyphWidth(FX_DWORD glyph_index); |
93 int GetAscent() const; | 91 int GetAscent() const; |
94 int GetDescent() const; | 92 int GetDescent() const; |
95 FX_BOOL GetGlyphBBox(FX_DWORD glyph_index, FX_RECT& bbox); | 93 FX_BOOL GetGlyphBBox(FX_DWORD glyph_index, FX_RECT& bbox); |
96 FX_BOOL IsItalic() const; | 94 FX_BOOL IsItalic() const; |
97 FX_BOOL IsBold() const; | 95 FX_BOOL IsBold() const; |
98 FX_BOOL IsFixedWidth() const; | 96 FX_BOOL IsFixedWidth() const; |
99 FX_BOOL IsVertical() const { return m_bVertical; } | 97 FX_BOOL IsVertical() const { return m_bVertical; } |
100 CFX_WideString GetPsName() const; | 98 CFX_WideString GetPsName() const; |
(...skipping 25 matching lines...) Expand all Loading... | |
126 uint8_t* m_pGsubData; | 124 uint8_t* m_pGsubData; |
127 FX_DWORD m_dwSize; | 125 FX_DWORD m_dwSize; |
128 CFX_BinaryBuf m_OtfFontData; | 126 CFX_BinaryBuf m_OtfFontData; |
129 void* m_hHandle; | 127 void* m_hHandle; |
130 void* m_pPlatformFont; | 128 void* m_pPlatformFont; |
131 void* m_pPlatformFontCollection; | 129 void* m_pPlatformFontCollection; |
132 void* m_pDwFont; | 130 void* m_pDwFont; |
133 FX_BOOL m_bDwLoaded; | 131 FX_BOOL m_bDwLoaded; |
134 FX_BOOL m_bEmbedded; | 132 FX_BOOL m_bEmbedded; |
135 FX_BOOL m_bVertical; | 133 FX_BOOL m_bVertical; |
134 | |
136 #ifdef PDF_ENABLE_XFA | 135 #ifdef PDF_ENABLE_XFA |
137 | |
138 protected: | 136 protected: |
139 FX_BOOL m_bLogic; | 137 FX_BOOL m_bLogic; |
140 void* m_pOwnedStream; | 138 void* m_pOwnedStream; |
141 #endif | 139 #endif // PDF_ENABLE_XFA |
142 }; | 140 }; |
143 | 141 |
144 #define ENCODING_INTERNAL 0 | 142 #define ENCODING_INTERNAL 0 |
145 #define ENCODING_UNICODE 1 | 143 #define ENCODING_UNICODE 1 |
146 | 144 |
147 #ifdef PDF_ENABLE_XFA | 145 #ifdef PDF_ENABLE_XFA |
148 #define FXFM_ENC_TAG(a, b, c, d) \ | 146 #define FXFM_ENC_TAG(a, b, c, d) \ |
149 (((FX_DWORD)(a) << 24) | ((FX_DWORD)(b) << 16) | ((FX_DWORD)(c) << 8) | \ | 147 (((FX_DWORD)(a) << 24) | ((FX_DWORD)(b) << 16) | ((FX_DWORD)(c) << 8) | \ |
150 (FX_DWORD)(d)) | 148 (FX_DWORD)(d)) |
151 #define FXFM_ENCODING_NONE FXFM_ENC_TAG(0, 0, 0, 0) | 149 #define FXFM_ENCODING_NONE FXFM_ENC_TAG(0, 0, 0, 0) |
152 #define FXFM_ENCODING_MS_SYMBOL FXFM_ENC_TAG('s', 'y', 'm', 'b') | 150 #define FXFM_ENCODING_MS_SYMBOL FXFM_ENC_TAG('s', 'y', 'm', 'b') |
153 #define FXFM_ENCODING_UNICODE FXFM_ENC_TAG('u', 'n', 'i', 'c') | 151 #define FXFM_ENCODING_UNICODE FXFM_ENC_TAG('u', 'n', 'i', 'c') |
154 #define FXFM_ENCODING_MS_SJIS FXFM_ENC_TAG('s', 'j', 'i', 's') | 152 #define FXFM_ENCODING_MS_SJIS FXFM_ENC_TAG('s', 'j', 'i', 's') |
155 #define FXFM_ENCODING_MS_GB2312 FXFM_ENC_TAG('g', 'b', ' ', ' ') | 153 #define FXFM_ENCODING_MS_GB2312 FXFM_ENC_TAG('g', 'b', ' ', ' ') |
156 #define FXFM_ENCODING_MS_BIG5 FXFM_ENC_TAG('b', 'i', 'g', '5') | 154 #define FXFM_ENCODING_MS_BIG5 FXFM_ENC_TAG('b', 'i', 'g', '5') |
157 #define FXFM_ENCODING_MS_WANSUNG FXFM_ENC_TAG('w', 'a', 'n', 's') | 155 #define FXFM_ENCODING_MS_WANSUNG FXFM_ENC_TAG('w', 'a', 'n', 's') |
158 #define FXFM_ENCODING_MS_JOHAB FXFM_ENC_TAG('j', 'o', 'h', 'a') | 156 #define FXFM_ENCODING_MS_JOHAB FXFM_ENC_TAG('j', 'o', 'h', 'a') |
159 #define FXFM_ENCODING_ADOBE_STANDARD FXFM_ENC_TAG('A', 'D', 'O', 'B') | 157 #define FXFM_ENCODING_ADOBE_STANDARD FXFM_ENC_TAG('A', 'D', 'O', 'B') |
160 #define FXFM_ENCODING_ADOBE_EXPERT FXFM_ENC_TAG('A', 'D', 'B', 'E') | 158 #define FXFM_ENCODING_ADOBE_EXPERT FXFM_ENC_TAG('A', 'D', 'B', 'E') |
161 #define FXFM_ENCODING_ADOBE_CUSTOM FXFM_ENC_TAG('A', 'D', 'B', 'C') | 159 #define FXFM_ENCODING_ADOBE_CUSTOM FXFM_ENC_TAG('A', 'D', 'B', 'C') |
162 #define FXFM_ENCODING_ADOBE_LATIN_1 FXFM_ENC_TAG('l', 'a', 't', '1') | 160 #define FXFM_ENCODING_ADOBE_LATIN_1 FXFM_ENC_TAG('l', 'a', 't', '1') |
163 #define FXFM_ENCODING_OLD_LATIN_2 FXFM_ENC_TAG('l', 'a', 't', '2') | 161 #define FXFM_ENCODING_OLD_LATIN_2 FXFM_ENC_TAG('l', 'a', 't', '2') |
164 #define FXFM_ENCODING_APPLE_ROMAN FXFM_ENC_TAG('a', 'r', 'm', 'n') | 162 #define FXFM_ENCODING_APPLE_ROMAN FXFM_ENC_TAG('a', 'r', 'm', 'n') |
163 #endif // PDF_ENABLE_XFA | |
165 | 164 |
166 #endif | |
167 class CFX_UnicodeEncoding { | 165 class CFX_UnicodeEncoding { |
168 public: | 166 public: |
169 explicit CFX_UnicodeEncoding(CFX_Font* pFont); | 167 explicit CFX_UnicodeEncoding(CFX_Font* pFont); |
170 virtual ~CFX_UnicodeEncoding(); | 168 virtual ~CFX_UnicodeEncoding(); |
171 | 169 |
172 virtual FX_DWORD GlyphFromCharCode(FX_DWORD charcode); | 170 virtual FX_DWORD GlyphFromCharCode(FX_DWORD charcode); |
173 | 171 |
174 protected: | 172 protected: |
175 // Unowned, not nullptr. | 173 // Unowned, not nullptr. |
176 CFX_Font* m_pFont; | 174 CFX_Font* m_pFont; |
177 }; | 175 }; |
178 | 176 |
179 #ifdef PDF_ENABLE_XFA | 177 #ifdef PDF_ENABLE_XFA |
180 class CFX_UnicodeEncodingEx : public CFX_UnicodeEncoding { | 178 class CFX_UnicodeEncodingEx : public CFX_UnicodeEncoding { |
181 public: | 179 public: |
182 CFX_UnicodeEncodingEx(CFX_Font* pFont, FX_DWORD EncodingID); | 180 CFX_UnicodeEncodingEx(CFX_Font* pFont, FX_DWORD EncodingID); |
183 ~CFX_UnicodeEncodingEx() override; | 181 ~CFX_UnicodeEncodingEx() override; |
184 | 182 |
185 // CFX_UnicodeEncoding: | 183 // CFX_UnicodeEncoding: |
186 FX_DWORD GlyphFromCharCode(FX_DWORD charcode) override; | 184 FX_DWORD GlyphFromCharCode(FX_DWORD charcode) override; |
187 | 185 |
188 FX_DWORD CharCodeFromUnicode(FX_WCHAR Unicode) const; | 186 FX_DWORD CharCodeFromUnicode(FX_WCHAR Unicode) const; |
189 | 187 |
190 private: | 188 private: |
191 FX_DWORD m_nEncodingID; | 189 FX_DWORD m_nEncodingID; |
192 }; | 190 }; |
193 | |
194 CFX_UnicodeEncodingEx* FX_CreateFontEncodingEx( | 191 CFX_UnicodeEncodingEx* FX_CreateFontEncodingEx( |
195 CFX_Font* pFont, | 192 CFX_Font* pFont, |
196 FX_DWORD nEncodingID = FXFM_ENCODING_NONE); | 193 FX_DWORD nEncodingID = FXFM_ENCODING_NONE); |
194 #endif // PDF_ENABLE_XFA | |
197 | 195 |
198 #endif | |
199 #define FXFONT_SUBST_MM 0x01 | 196 #define FXFONT_SUBST_MM 0x01 |
200 #define FXFONT_SUBST_GLYPHPATH 0x04 | 197 #define FXFONT_SUBST_GLYPHPATH 0x04 |
201 #define FXFONT_SUBST_CLEARTYPE 0x08 | 198 #define FXFONT_SUBST_CLEARTYPE 0x08 |
202 #define FXFONT_SUBST_TRANSFORM 0x10 | 199 #define FXFONT_SUBST_TRANSFORM 0x10 |
203 #define FXFONT_SUBST_NONSYMBOL 0x20 | 200 #define FXFONT_SUBST_NONSYMBOL 0x20 |
204 #define FXFONT_SUBST_EXACT 0x40 | 201 #define FXFONT_SUBST_EXACT 0x40 |
205 #define FXFONT_SUBST_STANDARD 0x80 | 202 #define FXFONT_SUBST_STANDARD 0x80 |
206 | 203 |
207 class CFX_SubstFont { | 204 class CFX_SubstFont { |
208 public: | 205 public: |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 int weight, | 317 int weight, |
321 int italic_angle, | 318 int italic_angle, |
322 int CharsetCP, | 319 int CharsetCP, |
323 CFX_SubstFont* pSubstFont); | 320 CFX_SubstFont* pSubstFont); |
324 #ifdef PDF_ENABLE_XFA | 321 #ifdef PDF_ENABLE_XFA |
325 FXFT_Face FindSubstFontByUnicode(FX_DWORD dwUnicode, | 322 FXFT_Face FindSubstFontByUnicode(FX_DWORD dwUnicode, |
326 FX_DWORD flags, | 323 FX_DWORD flags, |
327 int weight, | 324 int weight, |
328 int italic_angle); | 325 int italic_angle); |
329 FX_BOOL IsBuiltinFace(const FXFT_Face face) const; | 326 FX_BOOL IsBuiltinFace(const FXFT_Face face) const; |
330 #endif | 327 #endif // PDF_ENABLE_XFA |
331 | 328 |
332 private: | 329 private: |
333 static const size_t MM_FACE_COUNT = 2; | 330 static const size_t MM_FACE_COUNT = 2; |
334 static const size_t FOXIT_FACE_COUNT = 14; | 331 static const size_t FOXIT_FACE_COUNT = 14; |
335 | 332 |
336 CFX_ByteString GetPSNameFromTT(void* hFont); | 333 CFX_ByteString GetPSNameFromTT(void* hFont); |
337 CFX_ByteString MatchInstalledFonts(const CFX_ByteString& norm_name); | 334 CFX_ByteString MatchInstalledFonts(const CFX_ByteString& norm_name); |
338 FXFT_Face UseInternalSubst(CFX_SubstFont* pSubstFont, | 335 FXFT_Face UseInternalSubst(CFX_SubstFont* pSubstFont, |
339 int iBaseFont, | 336 int iBaseFont, |
340 int italic_angle, | 337 int italic_angle, |
(...skipping 23 matching lines...) Expand all Loading... | |
364 int pitch_family, | 361 int pitch_family, |
365 const FX_CHAR* face, | 362 const FX_CHAR* face, |
366 int& iExact) = 0; | 363 int& iExact) = 0; |
367 #ifdef PDF_ENABLE_XFA | 364 #ifdef PDF_ENABLE_XFA |
368 virtual void* MapFontByUnicode(FX_DWORD dwUnicode, | 365 virtual void* MapFontByUnicode(FX_DWORD dwUnicode, |
369 int weight, | 366 int weight, |
370 FX_BOOL bItalic, | 367 FX_BOOL bItalic, |
371 int pitch_family) { | 368 int pitch_family) { |
372 return NULL; | 369 return NULL; |
373 } | 370 } |
374 #endif | 371 #endif // PDF_ENABLE_XFA |
375 virtual void* GetFont(const FX_CHAR* face) = 0; | 372 virtual void* GetFont(const FX_CHAR* face) = 0; |
376 virtual FX_DWORD GetFontData(void* hFont, | 373 virtual FX_DWORD GetFontData(void* hFont, |
377 FX_DWORD table, | 374 FX_DWORD table, |
378 uint8_t* buffer, | 375 uint8_t* buffer, |
379 FX_DWORD size) = 0; | 376 FX_DWORD size) = 0; |
380 virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) = 0; | 377 virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) = 0; |
381 virtual FX_BOOL GetFontCharset(void* hFont, int& charset) = 0; | 378 virtual FX_BOOL GetFontCharset(void* hFont, int& charset) = 0; |
382 virtual int GetFaceIndex(void* hFont) { return 0; } | 379 virtual int GetFaceIndex(void* hFont) { return 0; } |
383 virtual void DeleteFont(void* hFont) = 0; | 380 virtual void DeleteFont(void* hFont) = 0; |
384 virtual void* RetainFont(void* hFont) { return NULL; } | 381 virtual void* RetainFont(void* hFont) { return NULL; } |
(...skipping 15 matching lines...) Expand all Loading... | |
400 FX_BOOL bItalic, | 397 FX_BOOL bItalic, |
401 int charset, | 398 int charset, |
402 int pitch_family, | 399 int pitch_family, |
403 const FX_CHAR* face, | 400 const FX_CHAR* face, |
404 int& bExact) override; | 401 int& bExact) override; |
405 #ifdef PDF_ENABLE_XFA | 402 #ifdef PDF_ENABLE_XFA |
406 void* MapFontByUnicode(FX_DWORD dwUnicode, | 403 void* MapFontByUnicode(FX_DWORD dwUnicode, |
407 int weight, | 404 int weight, |
408 FX_BOOL bItalic, | 405 FX_BOOL bItalic, |
409 int pitch_family) override; | 406 int pitch_family) override; |
410 #endif | 407 #endif // PDF_ENABLE_XFA |
411 void* GetFont(const FX_CHAR* face) override; | 408 void* GetFont(const FX_CHAR* face) override; |
412 FX_DWORD GetFontData(void* hFont, | 409 FX_DWORD GetFontData(void* hFont, |
413 FX_DWORD table, | 410 FX_DWORD table, |
414 uint8_t* buffer, | 411 uint8_t* buffer, |
415 FX_DWORD size) override; | 412 FX_DWORD size) override; |
416 void DeleteFont(void* hFont) override; | 413 void DeleteFont(void* hFont) override; |
417 FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) override; | 414 FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) override; |
418 FX_BOOL GetFontCharset(void* hFont, int& charset) override; | 415 FX_BOOL GetFontCharset(void* hFont, int& charset) override; |
419 | 416 |
420 protected: | 417 protected: |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
533 | 530 |
534 protected: | 531 protected: |
535 virtual ~IFX_GSUBTable() {} | 532 virtual ~IFX_GSUBTable() {} |
536 }; | 533 }; |
537 | 534 |
538 CFX_ByteString GetNameFromTT(const uint8_t* name_table, FX_DWORD name); | 535 CFX_ByteString GetNameFromTT(const uint8_t* name_table, FX_DWORD name); |
539 | 536 |
540 int PDF_GetStandardFontName(CFX_ByteString* name); | 537 int PDF_GetStandardFontName(CFX_ByteString* name); |
541 | 538 |
542 #endif // CORE_INCLUDE_FXGE_FX_FONT_H_ | 539 #endif // CORE_INCLUDE_FXGE_FX_FONT_H_ |
OLD | NEW |