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

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

Issue 1411833003: XFA: Manually apply changes to fpdf_text.h and fx_font.h from master (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Fix NULL comparisons. 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
« no previous file with comments | « core/include/fpdftext/fpdf_text.h ('k') | core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 16 matching lines...) Expand all
27 class IFX_FontEncoding; 27 class IFX_FontEncoding;
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_EXACTMATCH 0x80000000 38 #define FXFONT_EXACTMATCH 0x80000000
38 #define FXFONT_CIDFONT 0x100000
39 #define FXFONT_ANSI_CHARSET 0 39 #define FXFONT_ANSI_CHARSET 0
40 #define FXFONT_DEFAULT_CHARSET 1 40 #define FXFONT_DEFAULT_CHARSET 1
41 #define FXFONT_SYMBOL_CHARSET 2 41 #define FXFONT_SYMBOL_CHARSET 2
42 #define FXFONT_SHIFTJIS_CHARSET 128 42 #define FXFONT_SHIFTJIS_CHARSET 128
43 #define FXFONT_HANGEUL_CHARSET 129 43 #define FXFONT_HANGEUL_CHARSET 129
44 #define FXFONT_GB2312_CHARSET 134 44 #define FXFONT_GB2312_CHARSET 134
45 #define FXFONT_CHINESEBIG5_CHARSET 136 45 #define FXFONT_CHINESEBIG5_CHARSET 136
46 #define FXFONT_THAI_CHARSET 222 46 #define FXFONT_THAI_CHARSET 222
47 #define FXFONT_EASTEUROPE_CHARSET 238 47 #define FXFONT_EASTEUROPE_CHARSET 238
48 #define FXFONT_RUSSIAN_CHARSET 204 48 #define FXFONT_RUSSIAN_CHARSET 204
49 #define FXFONT_GREEK_CHARSET 161 49 #define FXFONT_GREEK_CHARSET 161
50 #define FXFONT_TURKISH_CHARSET 162 50 #define FXFONT_TURKISH_CHARSET 162
51 #define FXFONT_HEBREW_CHARSET 177 51 #define FXFONT_HEBREW_CHARSET 177
52 #define FXFONT_ARABIC_CHARSET 178 52 #define FXFONT_ARABIC_CHARSET 178
53 #define FXFONT_BALTIC_CHARSET 186 53 #define FXFONT_BALTIC_CHARSET 186
54 #define FXFONT_FF_FIXEDPITCH 1 54 #define FXFONT_FF_FIXEDPITCH 1
55 #define FXFONT_FF_ROMAN (1 << 4) 55 #define FXFONT_FF_ROMAN (1 << 4)
56 #define FXFONT_FF_SCRIPT (4 << 4) 56 #define FXFONT_FF_SCRIPT (4 << 4)
57 #define FXFONT_FW_NORMAL 400 57 #define FXFONT_FW_NORMAL 400
58 #define FXFONT_FW_BOLD 700 58 #define FXFONT_FW_BOLD 700
59
59 class CFX_Font { 60 class CFX_Font {
60 public: 61 public:
61 CFX_Font(); 62 CFX_Font();
62 ~CFX_Font(); 63 ~CFX_Font();
63 64
64 void LoadSubst(const CFX_ByteString& face_name, 65 void LoadSubst(const CFX_ByteString& face_name,
65 FX_BOOL bTrueType, 66 FX_BOOL bTrueType,
66 FX_DWORD flags, 67 FX_DWORD flags,
67 int weight, 68 int weight,
68 int italic_angle, 69 int italic_angle,
69 int CharsetCP, 70 int CharsetCP,
70 FX_BOOL bVertical = FALSE); 71 FX_BOOL bVertical = FALSE);
71 FX_BOOL LoadEmbedded(const uint8_t* data, FX_DWORD size); 72 FX_BOOL LoadEmbedded(const uint8_t* data, FX_DWORD size);
72 73
73 FX_BOOL LoadFile(IFX_FileRead* pFile, 74 FX_BOOL LoadFile(IFX_FileRead* pFile,
74 int nFaceIndex = 0, 75 int nFaceIndex = 0,
75 int* pFaceCount = NULL); 76 int* pFaceCount = NULL);
76 77
77 FX_BOOL LoadClone(const CFX_Font* pFont); 78 FX_BOOL LoadClone(const CFX_Font* pFont);
78 79
79 FXFT_Face GetFace() const { return m_Face; } 80 FXFT_Face GetFace() const { return m_Face; }
81 CFX_SubstFont* GetSubstFont() const { return m_pSubstFont; }
82 void SetFace(FXFT_Face face) { m_Face = face; }
83 void SetSubstFont(CFX_SubstFont* subst) { m_pSubstFont = subst; }
84 CFX_PathData* LoadGlyphPath(FX_DWORD glyph_index, int dest_width = 0);
85 int GetGlyphWidth(FX_DWORD glyph_index);
86 int GetAscent() const;
87 int GetDescent() const;
88 FX_BOOL GetGlyphBBox(FX_DWORD glyph_index, FX_RECT& bbox);
89 FX_BOOL IsItalic() const;
90 FX_BOOL IsBold() const;
91 FX_BOOL IsFixedWidth() const;
92 FX_BOOL IsVertical() const { return m_bVertical; }
93 CFX_WideString GetPsName() const;
94 CFX_ByteString GetFamilyName() const;
95 CFX_ByteString GetFaceName() const;
96 FX_BOOL IsTTFont() const;
97 FX_BOOL GetBBox(FX_RECT& bbox);
98 int GetHeight() const;
99 int GetULPos() const;
100 int GetULthickness() const;
101 int GetMaxAdvanceWidth() const;
102 FX_BOOL IsEmbedded() const { return m_bEmbedded; }
103 uint8_t* GetSubData() const { return m_pGsubData; }
104 void SetSubData(uint8_t* data) { m_pGsubData = data; }
105 void* GetPlatformFont() const { return m_pPlatformFont; }
106 void SetPlatformFont(void* font) { m_pPlatformFont = font; }
107 uint8_t* GetFontData() const { return m_pFontData; }
108 FX_DWORD GetSize() const { return m_dwSize; }
109 void AdjustMMParams(int glyph_index, int width, int weight);
80 110
81 const CFX_SubstFont* GetSubstFont() const { return m_pSubstFont; } 111 private:
82 112 void ReleasePlatformResource();
83 CFX_PathData* LoadGlyphPath(FX_DWORD glyph_index, int dest_width = 0); 113 void DeleteFace();
84
85 int GetGlyphWidth(FX_DWORD glyph_index);
86
87 int GetAscent() const;
88
89 int GetDescent() const;
90
91 FX_BOOL GetGlyphBBox(FX_DWORD glyph_index, FX_RECT& bbox);
92
93 FX_BOOL IsItalic();
94
95 FX_BOOL IsBold();
96
97 FX_BOOL IsFixedWidth();
98
99 FX_BOOL IsVertical() const { return m_bVertical; }
100
101 CFX_WideString GetPsName() const;
102
103 CFX_ByteString GetFamilyName() const;
104
105 CFX_ByteString GetFaceName() const;
106
107 FX_BOOL IsTTFont();
108
109 FX_BOOL GetBBox(FX_RECT& bbox);
110
111 int GetHeight();
112
113 int GetULPos();
114
115 int GetULthickness();
116
117 int GetMaxAdvanceWidth();
118 114
119 FXFT_Face m_Face; 115 FXFT_Face m_Face;
120
121 CFX_SubstFont* m_pSubstFont; 116 CFX_SubstFont* m_pSubstFont;
122 FX_BOOL IsEmbedded() { return m_bEmbedded; }
123
124 void AdjustMMParams(int glyph_index, int width, int weight);
125 uint8_t* m_pFontDataAllocation; 117 uint8_t* m_pFontDataAllocation;
126 uint8_t* m_pFontData; 118 uint8_t* m_pFontData;
127 uint8_t* m_pGsubData; 119 uint8_t* m_pGsubData;
128 FX_DWORD m_dwSize; 120 FX_DWORD m_dwSize;
129 CFX_BinaryBuf m_OtfFontData; 121 CFX_BinaryBuf m_OtfFontData;
130 void* m_hHandle; 122 void* m_hHandle;
131 void* m_pPlatformFont; 123 void* m_pPlatformFont;
132 void* m_pPlatformFontCollection; 124 void* m_pPlatformFontCollection;
133 void* m_pDwFont; 125 void* m_pDwFont;
134 FX_BOOL m_bDwLoaded; 126 FX_BOOL m_bDwLoaded;
135 void ReleasePlatformResource(); 127 FX_BOOL m_bEmbedded;
136 128 FX_BOOL m_bVertical;
137 void DeleteFace();
138 129
139 protected: 130 protected:
140 FX_BOOL m_bEmbedded;
141 FX_BOOL m_bVertical;
142 FX_BOOL m_bLogic; 131 FX_BOOL m_bLogic;
143 void* m_pOwnedStream; 132 void* m_pOwnedStream;
144 }; 133 };
134
145 #define ENCODING_INTERNAL 0 135 #define ENCODING_INTERNAL 0
146 #define ENCODING_UNICODE 1 136 #define ENCODING_UNICODE 1
147 137
148 #define FXFM_ENC_TAG(a, b, c, d) \ 138 #define FXFM_ENC_TAG(a, b, c, d) \
149 (((FX_DWORD)(a) << 24) | ((FX_DWORD)(b) << 16) | ((FX_DWORD)(c) << 8) | \ 139 (((FX_DWORD)(a) << 24) | ((FX_DWORD)(b) << 16) | ((FX_DWORD)(c) << 8) | \
150 (FX_DWORD)(d)) 140 (FX_DWORD)(d))
151 #define FXFM_ENCODING_NONE FXFM_ENC_TAG(0, 0, 0, 0) 141 #define FXFM_ENCODING_NONE FXFM_ENC_TAG(0, 0, 0, 0)
152 #define FXFM_ENCODING_MS_SYMBOL FXFM_ENC_TAG('s', 'y', 'm', 'b') 142 #define FXFM_ENCODING_MS_SYMBOL FXFM_ENC_TAG('s', 'y', 'm', 'b')
153 #define FXFM_ENCODING_UNICODE FXFM_ENC_TAG('u', 'n', 'i', 'c') 143 #define FXFM_ENCODING_UNICODE FXFM_ENC_TAG('u', 'n', 'i', 'c')
154 #define FXFM_ENCODING_MS_SJIS FXFM_ENC_TAG('s', 'j', 'i', 's') 144 #define FXFM_ENCODING_MS_SJIS FXFM_ENC_TAG('s', 'j', 'i', 's')
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 typedef struct { 222 typedef struct {
233 const uint8_t* m_pFontData; 223 const uint8_t* m_pFontData;
234 FX_DWORD m_dwSize; 224 FX_DWORD m_dwSize;
235 } FoxitFonts; 225 } FoxitFonts;
236 class CFX_FontMgr { 226 class CFX_FontMgr {
237 public: 227 public:
238 CFX_FontMgr(); 228 CFX_FontMgr();
239 ~CFX_FontMgr(); 229 ~CFX_FontMgr();
240 230
241 void InitFTLibrary(); 231 void InitFTLibrary();
232
242 FXFT_Face GetCachedFace(const CFX_ByteString& face_name, 233 FXFT_Face GetCachedFace(const CFX_ByteString& face_name,
243 int weight, 234 int weight,
244 FX_BOOL bItalic, 235 FX_BOOL bItalic,
245 uint8_t*& pFontData); 236 uint8_t*& pFontData);
246 FXFT_Face AddCachedFace(const CFX_ByteString& face_name, 237 FXFT_Face AddCachedFace(const CFX_ByteString& face_name,
247 int weight, 238 int weight,
248 FX_BOOL bItalic, 239 FX_BOOL bItalic,
249 uint8_t* pData, 240 uint8_t* pData,
250 FX_DWORD size, 241 FX_DWORD size,
251 int face_index); 242 int face_index);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 296
306 void SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo); 297 void SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo);
307 IFX_SystemFontInfo* GetSystemFontInfo() { return m_pFontInfo; } 298 IFX_SystemFontInfo* GetSystemFontInfo() { return m_pFontInfo; }
308 void AddInstalledFont(const CFX_ByteString& name, int charset); 299 void AddInstalledFont(const CFX_ByteString& name, int charset);
309 void LoadInstalledFonts(); 300 void LoadInstalledFonts();
310 CFX_ByteStringArray m_InstalledTTFonts; 301 CFX_ByteStringArray m_InstalledTTFonts;
311 void SetFontEnumerator(IFX_FontEnumerator* pFontEnumerator) { 302 void SetFontEnumerator(IFX_FontEnumerator* pFontEnumerator) {
312 m_pFontEnumerator = pFontEnumerator; 303 m_pFontEnumerator = pFontEnumerator;
313 } 304 }
314 IFX_FontEnumerator* GetFontEnumerator() const { return m_pFontEnumerator; } 305 IFX_FontEnumerator* GetFontEnumerator() const { return m_pFontEnumerator; }
315
316 FXFT_Face FindSubstFont(const CFX_ByteString& face_name, 306 FXFT_Face FindSubstFont(const CFX_ByteString& face_name,
317 FX_BOOL bTrueType, 307 FX_BOOL bTrueType,
318 FX_DWORD flags, 308 FX_DWORD flags,
319 int weight, 309 int weight,
320 int italic_angle, 310 int italic_angle,
321 int CharsetCP, 311 int CharsetCP,
322 CFX_SubstFont* pSubstFont); 312 CFX_SubstFont* pSubstFont);
323 FXFT_Face FindSubstFontByUnicode(FX_DWORD dwUnicode, 313 FXFT_Face FindSubstFontByUnicode(FX_DWORD dwUnicode,
324 FX_DWORD flags, 314 FX_DWORD flags,
325 int weight, 315 int weight,
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 514
525 protected: 515 protected:
526 virtual ~IFX_GSUBTable() {} 516 virtual ~IFX_GSUBTable() {}
527 }; 517 };
528 518
529 CFX_ByteString GetNameFromTT(const uint8_t* name_table, FX_DWORD name); 519 CFX_ByteString GetNameFromTT(const uint8_t* name_table, FX_DWORD name);
530 520
531 int PDF_GetStandardFontName(CFX_ByteString* name); 521 int PDF_GetStandardFontName(CFX_ByteString* name);
532 522
533 #endif // CORE_INCLUDE_FXGE_FX_FONT_H_ 523 #endif // CORE_INCLUDE_FXGE_FX_FONT_H_
OLDNEW
« no previous file with comments | « core/include/fpdftext/fpdf_text.h ('k') | core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698