Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: core/include/fxge/fx_font.h

Issue 1398383002: core/ difference with XFA (for information only). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: After bidi Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 17 matching lines...) Expand all
28 class IFX_SystemFontInfo; 28 class IFX_SystemFontInfo;
29 29
30 #define FXFONT_FIXED_PITCH 0x01 30 #define FXFONT_FIXED_PITCH 0x01
31 #define FXFONT_SERIF 0x02 31 #define FXFONT_SERIF 0x02
32 #define FXFONT_SYMBOLIC 0x04 32 #define FXFONT_SYMBOLIC 0x04
33 #define FXFONT_SCRIPT 0x08 33 #define FXFONT_SCRIPT 0x08
34 #define FXFONT_ITALIC 0x40 34 #define FXFONT_ITALIC 0x40
35 #define FXFONT_BOLD 0x40000 35 #define FXFONT_BOLD 0x40000
36 #define FXFONT_USEEXTERNATTR 0x80000 36 #define FXFONT_USEEXTERNATTR 0x80000
37 #define FXFONT_CIDFONT 0x100000 37 #define FXFONT_CIDFONT 0x100000
38 #ifdef PDF_ENABLE_XFA
39 #define FXFONT_EXACTMATCH 0x80000000
40 #endif
38 #define FXFONT_ANSI_CHARSET 0 41 #define FXFONT_ANSI_CHARSET 0
39 #define FXFONT_DEFAULT_CHARSET 1 42 #define FXFONT_DEFAULT_CHARSET 1
40 #define FXFONT_SYMBOL_CHARSET 2 43 #define FXFONT_SYMBOL_CHARSET 2
41 #define FXFONT_SHIFTJIS_CHARSET 128 44 #define FXFONT_SHIFTJIS_CHARSET 128
42 #define FXFONT_HANGEUL_CHARSET 129 45 #define FXFONT_HANGEUL_CHARSET 129
43 #define FXFONT_GB2312_CHARSET 134 46 #define FXFONT_GB2312_CHARSET 134
44 #define FXFONT_CHINESEBIG5_CHARSET 136 47 #define FXFONT_CHINESEBIG5_CHARSET 136
45 #define FXFONT_THAI_CHARSET 222 48 #define FXFONT_THAI_CHARSET 222
46 #define FXFONT_EASTEUROPE_CHARSET 238 49 #define FXFONT_EASTEUROPE_CHARSET 238
47 #define FXFONT_RUSSIAN_CHARSET 204 50 #define FXFONT_RUSSIAN_CHARSET 204
(...skipping 14 matching lines...) Expand all
62 ~CFX_Font(); 65 ~CFX_Font();
63 66
64 void LoadSubst(const CFX_ByteString& face_name, 67 void LoadSubst(const CFX_ByteString& face_name,
65 FX_BOOL bTrueType, 68 FX_BOOL bTrueType,
66 FX_DWORD flags, 69 FX_DWORD flags,
67 int weight, 70 int weight,
68 int italic_angle, 71 int italic_angle,
69 int CharsetCP, 72 int CharsetCP,
70 FX_BOOL bVertical = FALSE); 73 FX_BOOL bVertical = FALSE);
71 FX_BOOL LoadEmbedded(const uint8_t* data, FX_DWORD size); 74 FX_BOOL LoadEmbedded(const uint8_t* data, FX_DWORD size);
75 #ifdef PDF_ENABLE_XFA
76
77 FX_BOOL LoadFile(IFX_FileRead* pFile,
78 int nFaceIndex = 0,
79 int* pFaceCount = NULL);
80
81 FX_BOOL LoadClone(const CFX_Font* pFont);
82
83 #endif
72 FXFT_Face GetFace() const { return m_Face; } 84 FXFT_Face GetFace() const { return m_Face; }
85 #ifndef PDF_ENABLE_XFA
73 const CFX_SubstFont* GetSubstFont() const { return m_pSubstFont; } 86 const CFX_SubstFont* GetSubstFont() const { return m_pSubstFont; }
87 #else
88 CFX_SubstFont* GetSubstFont() const { return m_pSubstFont; }
89 void SetFace(FXFT_Face face) { m_Face = face; }
90 void SetSubstFont(CFX_SubstFont* subst) { m_pSubstFont = subst; }
91 #endif
74 CFX_PathData* LoadGlyphPath(FX_DWORD glyph_index, int dest_width = 0); 92 CFX_PathData* LoadGlyphPath(FX_DWORD glyph_index, int dest_width = 0);
75 int GetGlyphWidth(FX_DWORD glyph_index); 93 int GetGlyphWidth(FX_DWORD glyph_index);
76 int GetAscent() const; 94 int GetAscent() const;
77 int GetDescent() const; 95 int GetDescent() const;
78 FX_BOOL GetGlyphBBox(FX_DWORD glyph_index, FX_RECT& bbox); 96 FX_BOOL GetGlyphBBox(FX_DWORD glyph_index, FX_RECT& bbox);
79 FX_BOOL IsItalic() const; 97 FX_BOOL IsItalic() const;
80 FX_BOOL IsBold() const; 98 FX_BOOL IsBold() const;
81 FX_BOOL IsFixedWidth() const; 99 FX_BOOL IsFixedWidth() const;
82 FX_BOOL IsVertical() const { return m_bVertical; } 100 FX_BOOL IsVertical() const { return m_bVertical; }
83 CFX_WideString GetPsName() const; 101 CFX_WideString GetPsName() const;
(...skipping 25 matching lines...) Expand all
109 uint8_t* m_pGsubData; 127 uint8_t* m_pGsubData;
110 FX_DWORD m_dwSize; 128 FX_DWORD m_dwSize;
111 CFX_BinaryBuf m_OtfFontData; 129 CFX_BinaryBuf m_OtfFontData;
112 void* m_hHandle; 130 void* m_hHandle;
113 void* m_pPlatformFont; 131 void* m_pPlatformFont;
114 void* m_pPlatformFontCollection; 132 void* m_pPlatformFontCollection;
115 void* m_pDwFont; 133 void* m_pDwFont;
116 FX_BOOL m_bDwLoaded; 134 FX_BOOL m_bDwLoaded;
117 FX_BOOL m_bEmbedded; 135 FX_BOOL m_bEmbedded;
118 FX_BOOL m_bVertical; 136 FX_BOOL m_bVertical;
137 #ifdef PDF_ENABLE_XFA
138
139 protected:
140 FX_BOOL m_bLogic;
141 void* m_pOwnedStream;
142 #endif
119 }; 143 };
120 144
121 #define ENCODING_INTERNAL 0 145 #define ENCODING_INTERNAL 0
122 #define ENCODING_UNICODE 1 146 #define ENCODING_UNICODE 1
123 147
148 #ifdef PDF_ENABLE_XFA
149 #define FXFM_ENC_TAG(a, b, c, d) \
150 (((FX_DWORD)(a) << 24) | ((FX_DWORD)(b) << 16) | ((FX_DWORD)(c) << 8) | \
151 (FX_DWORD)(d))
152 #define FXFM_ENCODING_NONE FXFM_ENC_TAG(0, 0, 0, 0)
153 #define FXFM_ENCODING_MS_SYMBOL FXFM_ENC_TAG('s', 'y', 'm', 'b')
154 #define FXFM_ENCODING_UNICODE FXFM_ENC_TAG('u', 'n', 'i', 'c')
155 #define FXFM_ENCODING_MS_SJIS FXFM_ENC_TAG('s', 'j', 'i', 's')
156 #define FXFM_ENCODING_MS_GB2312 FXFM_ENC_TAG('g', 'b', ' ', ' ')
157 #define FXFM_ENCODING_MS_BIG5 FXFM_ENC_TAG('b', 'i', 'g', '5')
158 #define FXFM_ENCODING_MS_WANSUNG FXFM_ENC_TAG('w', 'a', 'n', 's')
159 #define FXFM_ENCODING_MS_JOHAB FXFM_ENC_TAG('j', 'o', 'h', 'a')
160 #define FXFM_ENCODING_ADOBE_STANDARD FXFM_ENC_TAG('A', 'D', 'O', 'B')
161 #define FXFM_ENCODING_ADOBE_EXPERT FXFM_ENC_TAG('A', 'D', 'B', 'E')
162 #define FXFM_ENCODING_ADOBE_CUSTOM FXFM_ENC_TAG('A', 'D', 'B', 'C')
163 #define FXFM_ENCODING_ADOBE_LATIN_1 FXFM_ENC_TAG('l', 'a', 't', '1')
164 #define FXFM_ENCODING_OLD_LATIN_2 FXFM_ENC_TAG('l', 'a', 't', '2')
165 #define FXFM_ENCODING_APPLE_ROMAN FXFM_ENC_TAG('a', 'r', 'm', 'n')
166
167 #endif
124 class CFX_UnicodeEncoding { 168 class CFX_UnicodeEncoding {
125 public: 169 public:
126 explicit CFX_UnicodeEncoding(CFX_Font* pFont); 170 explicit CFX_UnicodeEncoding(CFX_Font* pFont);
171 #ifndef PDF_ENABLE_XFA
127 ~CFX_UnicodeEncoding(); 172 ~CFX_UnicodeEncoding();
173 #else
174 virtual ~CFX_UnicodeEncoding();
175 #endif
128 176
177 #ifndef PDF_ENABLE_XFA
129 FX_DWORD GlyphFromCharCode(FX_DWORD charcode); 178 FX_DWORD GlyphFromCharCode(FX_DWORD charcode);
179 #else
180 virtual FX_DWORD GlyphFromCharCode(FX_DWORD charcode);
181 #endif
130 182
183 #ifndef PDF_ENABLE_XFA
131 private: 184 private:
185 #else
186 protected:
187 #endif
132 // Unowned, not nullptr. 188 // Unowned, not nullptr.
133 CFX_Font* m_pFont; 189 CFX_Font* m_pFont;
134 }; 190 };
135 191
192 #ifdef PDF_ENABLE_XFA
193 class CFX_UnicodeEncodingEx : public CFX_UnicodeEncoding {
194 public:
195 CFX_UnicodeEncodingEx(CFX_Font* pFont, FX_DWORD EncodingID);
196 ~CFX_UnicodeEncodingEx() override;
197
198 // CFX_UnicodeEncoding:
199 FX_DWORD GlyphFromCharCode(FX_DWORD charcode) override;
200
201 FX_DWORD CharCodeFromUnicode(FX_WCHAR Unicode) const;
202
203 private:
204 FX_DWORD m_nEncodingID;
205 };
206
207 CFX_UnicodeEncodingEx* FX_CreateFontEncodingEx(
208 CFX_Font* pFont,
209 FX_DWORD nEncodingID = FXFM_ENCODING_NONE);
210
211 #endif
136 #define FXFONT_SUBST_MM 0x01 212 #define FXFONT_SUBST_MM 0x01
137 #define FXFONT_SUBST_GLYPHPATH 0x04 213 #define FXFONT_SUBST_GLYPHPATH 0x04
138 #define FXFONT_SUBST_CLEARTYPE 0x08 214 #define FXFONT_SUBST_CLEARTYPE 0x08
139 #define FXFONT_SUBST_TRANSFORM 0x10 215 #define FXFONT_SUBST_TRANSFORM 0x10
140 #define FXFONT_SUBST_NONSYMBOL 0x20 216 #define FXFONT_SUBST_NONSYMBOL 0x20
141 #define FXFONT_SUBST_EXACT 0x40 217 #define FXFONT_SUBST_EXACT 0x40
142 #define FXFONT_SUBST_STANDARD 0x80 218 #define FXFONT_SUBST_STANDARD 0x80
143 class CFX_SubstFont { 219 class CFX_SubstFont {
144 public: 220 public:
145 CFX_SubstFont(); 221 CFX_SubstFont();
(...skipping 25 matching lines...) Expand all
171 #define FX_FONT_FLAG_MULTIPLEMASTER 0x40 247 #define FX_FONT_FLAG_MULTIPLEMASTER 0x40
172 typedef struct { 248 typedef struct {
173 const uint8_t* m_pFontData; 249 const uint8_t* m_pFontData;
174 FX_DWORD m_dwSize; 250 FX_DWORD m_dwSize;
175 } FoxitFonts; 251 } FoxitFonts;
176 class CFX_FontMgr { 252 class CFX_FontMgr {
177 public: 253 public:
178 CFX_FontMgr(); 254 CFX_FontMgr();
179 ~CFX_FontMgr(); 255 ~CFX_FontMgr();
180 256
257 #ifdef PDF_ENABLE_XFA
258 void InitFTLibrary();
259
260 #endif
181 FXFT_Face GetCachedFace(const CFX_ByteString& face_name, 261 FXFT_Face GetCachedFace(const CFX_ByteString& face_name,
182 int weight, 262 int weight,
183 FX_BOOL bItalic, 263 FX_BOOL bItalic,
184 uint8_t*& pFontData); 264 uint8_t*& pFontData);
185 FXFT_Face AddCachedFace(const CFX_ByteString& face_name, 265 FXFT_Face AddCachedFace(const CFX_ByteString& face_name,
186 int weight, 266 int weight,
187 FX_BOOL bItalic, 267 FX_BOOL bItalic,
188 uint8_t* pData, 268 uint8_t* pData,
189 FX_DWORD size, 269 FX_DWORD size,
190 int face_index); 270 int face_index);
(...skipping 15 matching lines...) Expand all
206 FX_DWORD flags, 286 FX_DWORD flags,
207 int weight, 287 int weight,
208 int italic_angle, 288 int italic_angle,
209 int CharsetCP, 289 int CharsetCP,
210 CFX_SubstFont* pSubstFont); 290 CFX_SubstFont* pSubstFont);
211 FX_BOOL GetStandardFont(const uint8_t*& pFontData, FX_DWORD& size, int index); 291 FX_BOOL GetStandardFont(const uint8_t*& pFontData, FX_DWORD& size, int index);
212 CFX_FontMapper* GetBuiltinMapper() const { return m_pBuiltinMapper.get(); } 292 CFX_FontMapper* GetBuiltinMapper() const { return m_pBuiltinMapper.get(); }
213 FXFT_Library GetFTLibrary() const { return m_FTLibrary; } 293 FXFT_Library GetFTLibrary() const { return m_FTLibrary; }
214 294
215 private: 295 private:
296 #ifndef PDF_ENABLE_XFA
216 void InitFTLibrary(); 297 void InitFTLibrary();
217 298
299 #endif
218 nonstd::unique_ptr<CFX_FontMapper> m_pBuiltinMapper; 300 nonstd::unique_ptr<CFX_FontMapper> m_pBuiltinMapper;
219 std::map<CFX_ByteString, CTTFontDesc*> m_FaceMap; 301 std::map<CFX_ByteString, CTTFontDesc*> m_FaceMap;
220 FXFT_Library m_FTLibrary; 302 FXFT_Library m_FTLibrary;
221 }; 303 };
222 304
223 class IFX_FontEnumerator { 305 class IFX_FontEnumerator {
224 public: 306 public:
225 virtual void HitFont() = 0; 307 virtual void HitFont() = 0;
226 308
227 virtual void Finish() = 0; 309 virtual void Finish() = 0;
(...skipping 25 matching lines...) Expand all
253 m_pFontEnumerator = pFontEnumerator; 335 m_pFontEnumerator = pFontEnumerator;
254 } 336 }
255 IFX_FontEnumerator* GetFontEnumerator() const { return m_pFontEnumerator; } 337 IFX_FontEnumerator* GetFontEnumerator() const { return m_pFontEnumerator; }
256 FXFT_Face FindSubstFont(const CFX_ByteString& face_name, 338 FXFT_Face FindSubstFont(const CFX_ByteString& face_name,
257 FX_BOOL bTrueType, 339 FX_BOOL bTrueType,
258 FX_DWORD flags, 340 FX_DWORD flags,
259 int weight, 341 int weight,
260 int italic_angle, 342 int italic_angle,
261 int CharsetCP, 343 int CharsetCP,
262 CFX_SubstFont* pSubstFont); 344 CFX_SubstFont* pSubstFont);
345 #ifdef PDF_ENABLE_XFA
346 FXFT_Face FindSubstFontByUnicode(FX_DWORD dwUnicode,
347 FX_DWORD flags,
348 int weight,
349 int italic_angle);
350 FX_BOOL IsBuiltinFace(const FXFT_Face face) const;
351 #endif
263 352
264 private: 353 private:
265 static const size_t MM_FACE_COUNT = 2; 354 static const size_t MM_FACE_COUNT = 2;
266 static const size_t FOXIT_FACE_COUNT = 14; 355 static const size_t FOXIT_FACE_COUNT = 14;
267 356
268 CFX_ByteString GetPSNameFromTT(void* hFont); 357 CFX_ByteString GetPSNameFromTT(void* hFont);
269 CFX_ByteString MatchInstalledFonts(const CFX_ByteString& norm_name); 358 CFX_ByteString MatchInstalledFonts(const CFX_ByteString& norm_name);
270 FXFT_Face UseInternalSubst(CFX_SubstFont* pSubstFont, 359 FXFT_Face UseInternalSubst(CFX_SubstFont* pSubstFont,
271 int iBaseFont, 360 int iBaseFont,
272 int italic_angle, 361 int italic_angle,
(...skipping 16 matching lines...) Expand all
289 static IFX_SystemFontInfo* CreateDefault(const char** pUserPaths); 378 static IFX_SystemFontInfo* CreateDefault(const char** pUserPaths);
290 virtual void Release() = 0; 379 virtual void Release() = 0;
291 380
292 virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper) = 0; 381 virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper) = 0;
293 virtual void* MapFont(int weight, 382 virtual void* MapFont(int weight,
294 FX_BOOL bItalic, 383 FX_BOOL bItalic,
295 int charset, 384 int charset,
296 int pitch_family, 385 int pitch_family,
297 const FX_CHAR* face, 386 const FX_CHAR* face,
298 int& iExact) = 0; 387 int& iExact) = 0;
388 #ifdef PDF_ENABLE_XFA
389 virtual void* MapFontByUnicode(FX_DWORD dwUnicode,
390 int weight,
391 FX_BOOL bItalic,
392 int pitch_family) {
393 return NULL;
394 }
395 #endif
299 virtual void* GetFont(const FX_CHAR* face) = 0; 396 virtual void* GetFont(const FX_CHAR* face) = 0;
300 virtual FX_DWORD GetFontData(void* hFont, 397 virtual FX_DWORD GetFontData(void* hFont,
301 FX_DWORD table, 398 FX_DWORD table,
302 uint8_t* buffer, 399 uint8_t* buffer,
303 FX_DWORD size) = 0; 400 FX_DWORD size) = 0;
304 virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) = 0; 401 virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) = 0;
305 virtual FX_BOOL GetFontCharset(void* hFont, int& charset) = 0; 402 virtual FX_BOOL GetFontCharset(void* hFont, int& charset) = 0;
306 virtual int GetFaceIndex(void* hFont) { return 0; } 403 virtual int GetFaceIndex(void* hFont) { return 0; }
307 virtual void DeleteFont(void* hFont) = 0; 404 virtual void DeleteFont(void* hFont) = 0;
308 virtual void* RetainFont(void* hFont) { return NULL; } 405 virtual void* RetainFont(void* hFont) { return NULL; }
309 406
310 protected: 407 protected:
311 virtual ~IFX_SystemFontInfo() {} 408 virtual ~IFX_SystemFontInfo() {}
312 }; 409 };
313 410
314 class CFX_FolderFontInfo : public IFX_SystemFontInfo { 411 class CFX_FolderFontInfo : public IFX_SystemFontInfo {
315 public: 412 public:
316 CFX_FolderFontInfo(); 413 CFX_FolderFontInfo();
317 ~CFX_FolderFontInfo() override; 414 ~CFX_FolderFontInfo() override;
415 #ifdef PDF_ENABLE_XFA
416
417 #endif
318 void AddPath(const CFX_ByteStringC& path); 418 void AddPath(const CFX_ByteStringC& path);
319 419
320 // IFX_SytemFontInfo: 420 // IFX_SytemFontInfo:
321 void Release() override; 421 void Release() override;
322 FX_BOOL EnumFontList(CFX_FontMapper* pMapper) override; 422 FX_BOOL EnumFontList(CFX_FontMapper* pMapper) override;
323 void* MapFont(int weight, 423 void* MapFont(int weight,
324 FX_BOOL bItalic, 424 FX_BOOL bItalic,
325 int charset, 425 int charset,
326 int pitch_family, 426 int pitch_family,
327 const FX_CHAR* face, 427 const FX_CHAR* face,
328 int& bExact) override; 428 int& bExact) override;
429 #ifdef PDF_ENABLE_XFA
430 void* MapFontByUnicode(FX_DWORD dwUnicode,
431 int weight,
432 FX_BOOL bItalic,
433 int pitch_family) override;
434 #endif
329 void* GetFont(const FX_CHAR* face) override; 435 void* GetFont(const FX_CHAR* face) override;
330 FX_DWORD GetFontData(void* hFont, 436 FX_DWORD GetFontData(void* hFont,
331 FX_DWORD table, 437 FX_DWORD table,
332 uint8_t* buffer, 438 uint8_t* buffer,
333 FX_DWORD size) override; 439 FX_DWORD size) override;
334 void DeleteFont(void* hFont) override; 440 void DeleteFont(void* hFont) override;
335 FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) override; 441 FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) override;
336 FX_BOOL GetFontCharset(void* hFont, int& charset) override; 442 FX_BOOL GetFontCharset(void* hFont, int& charset) override;
337 443
338 protected: 444 protected:
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 554
449 protected: 555 protected:
450 virtual ~IFX_GSUBTable() {} 556 virtual ~IFX_GSUBTable() {}
451 }; 557 };
452 558
453 CFX_ByteString GetNameFromTT(const uint8_t* name_table, FX_DWORD name); 559 CFX_ByteString GetNameFromTT(const uint8_t* name_table, FX_DWORD name);
454 560
455 int PDF_GetStandardFontName(CFX_ByteString* name); 561 int PDF_GetStandardFontName(CFX_ByteString* name);
456 562
457 #endif // CORE_INCLUDE_FXGE_FX_FONT_H_ 563 #endif // CORE_INCLUDE_FXGE_FX_FONT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698