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 _FX_FONT_H_ | 7 #ifndef _FX_FONT_H_ |
8 #define _FX_FONT_H_ | 8 #define _FX_FONT_H_ |
9 #ifndef _FXCRT_EXTENSION_ | 9 #ifndef _FXCRT_EXTENSION_ |
10 #include "../../include/fxcrt/fx_ext.h" | 10 #include "../../include/fxcrt/fx_ext.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #define FXFONT_GREEK_CHARSET 161 | 44 #define FXFONT_GREEK_CHARSET 161 |
45 #define FXFONT_TURKISH_CHARSET 162 | 45 #define FXFONT_TURKISH_CHARSET 162 |
46 #define FXFONT_HEBREW_CHARSET 177 | 46 #define FXFONT_HEBREW_CHARSET 177 |
47 #define FXFONT_ARABIC_CHARSET 178 | 47 #define FXFONT_ARABIC_CHARSET 178 |
48 #define FXFONT_BALTIC_CHARSET 186 | 48 #define FXFONT_BALTIC_CHARSET 186 |
49 #define FXFONT_FF_FIXEDPITCH 1 | 49 #define FXFONT_FF_FIXEDPITCH 1 |
50 #define FXFONT_FF_ROMAN (1<<4) | 50 #define FXFONT_FF_ROMAN (1<<4) |
51 #define FXFONT_FF_SCRIPT (4<<4) | 51 #define FXFONT_FF_SCRIPT (4<<4) |
52 #define FXFONT_FW_NORMAL 400 | 52 #define FXFONT_FW_NORMAL 400 |
53 #define FXFONT_FW_BOLD 700 | 53 #define FXFONT_FW_BOLD 700 |
54 class CFX_Font : public CFX_Object | 54 class CFX_Font |
55 { | 55 { |
56 public: | 56 public: |
57 CFX_Font(); | 57 CFX_Font(); |
58 ~CFX_Font(); | 58 ~CFX_Font(); |
59 | 59 |
60 FX_BOOL LoadSubst(const CFX_ByteString&
face_name, FX_BOOL bTrueType, FX_DWORD flags, | 60 FX_BOOL LoadSubst(const CFX_ByteString&
face_name, FX_BOOL bTrueType, FX_DWORD flags, |
61 int weight, int italic_angle, int CharsetC
P, FX_BOOL bVertical = FALSE); | 61 int weight, int italic_angle, int CharsetC
P, FX_BOOL bVertical = FALSE); |
62 | 62 |
63 FX_BOOL LoadEmbedded(FX_LPCBYTE data, FX
_DWORD size); | 63 FX_BOOL LoadEmbedded(FX_LPCBYTE data, FX
_DWORD size); |
64 | 64 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 void DeleteFace(); | 143 void DeleteFace(); |
144 protected: | 144 protected: |
145 | 145 |
146 FX_BOOL m_bEmbedded; | 146 FX_BOOL m_bEmbedded; |
147 FX_BOOL m_bVertical; | 147 FX_BOOL m_bVertical; |
148 FX_BOOL m_bLogic; | 148 FX_BOOL m_bLogic; |
149 void* m_pOwnedStream; | 149 void* m_pOwnedStream; |
150 }; | 150 }; |
151 #define ENCODING_INTERNAL 0 | 151 #define ENCODING_INTERNAL 0 |
152 #define ENCODING_UNICODE 1 | 152 #define ENCODING_UNICODE 1 |
153 class IFX_FontEncoding : public CFX_Object | 153 class IFX_FontEncoding |
154 { | 154 { |
155 public: | 155 public: |
156 virtual ~IFX_FontEncoding() {} | 156 virtual ~IFX_FontEncoding() {} |
157 | 157 |
158 virtual FX_DWORD GlyphFromCharCode(FX_DWORD charcode) = 0; | 158 virtual FX_DWORD GlyphFromCharCode(FX_DWORD charcode) = 0; |
159 | 159 |
160 virtual CFX_WideString UnicodeFromCharCode(FX_DWORD charcode) const = 0
; | 160 virtual CFX_WideString UnicodeFromCharCode(FX_DWORD charcode) const = 0
; |
161 | 161 |
162 virtual FX_DWORD CharCodeFromUnicode(FX_WCHAR Unicode) const = 0; | 162 virtual FX_DWORD CharCodeFromUnicode(FX_WCHAR Unicode) const = 0; |
163 }; | 163 }; |
(...skipping 24 matching lines...) Expand all Loading... |
188 virtual FX_DWORD CharCodeFromGlyphIndex(FX_DWORD dwGlyphIndex) =
0; | 188 virtual FX_DWORD CharCodeFromGlyphIndex(FX_DWORD dwGlyphIndex) =
0; |
189 }; | 189 }; |
190 IFX_FontEncodingEx* FX_CreateFontEncodingEx(CFX_Font* pFont, FX_DWORD nEncod
ingID = FXFM_ENCODING_NONE); | 190 IFX_FontEncodingEx* FX_CreateFontEncodingEx(CFX_Font* pFont, FX_DWORD nEncod
ingID = FXFM_ENCODING_NONE); |
191 #define FXFONT_SUBST_MM 0x01 | 191 #define FXFONT_SUBST_MM 0x01 |
192 #define FXFONT_SUBST_GLYPHPATH 0x04 | 192 #define FXFONT_SUBST_GLYPHPATH 0x04 |
193 #define FXFONT_SUBST_CLEARTYPE 0x08 | 193 #define FXFONT_SUBST_CLEARTYPE 0x08 |
194 #define FXFONT_SUBST_TRANSFORM 0x10 | 194 #define FXFONT_SUBST_TRANSFORM 0x10 |
195 #define FXFONT_SUBST_NONSYMBOL 0x20 | 195 #define FXFONT_SUBST_NONSYMBOL 0x20 |
196 #define FXFONT_SUBST_EXACT 0x40 | 196 #define FXFONT_SUBST_EXACT 0x40 |
197 #define FXFONT_SUBST_STANDARD 0x80 | 197 #define FXFONT_SUBST_STANDARD 0x80 |
198 class CFX_SubstFont : public CFX_Object | 198 class CFX_SubstFont |
199 { | 199 { |
200 public: | 200 public: |
201 | 201 |
202 CFX_SubstFont(); | 202 CFX_SubstFont(); |
203 | 203 |
204 FX_LPVOID m_ExtHandle; | 204 FX_LPVOID m_ExtHandle; |
205 | 205 |
206 CFX_ByteString m_Family; | 206 CFX_ByteString m_Family; |
207 | 207 |
208 int m_Charset; | 208 int m_Charset; |
(...skipping 14 matching lines...) Expand all Loading... |
223 #define FX_FONT_FLAG_FIXEDPITCH 0x02 | 223 #define FX_FONT_FLAG_FIXEDPITCH 0x02 |
224 #define FX_FONT_FLAG_ITALIC 0x04 | 224 #define FX_FONT_FLAG_ITALIC 0x04 |
225 #define FX_FONT_FLAG_BOLD 0x08 | 225 #define FX_FONT_FLAG_BOLD 0x08 |
226 #define FX_FONT_FLAG_SYMBOLIC_SYMBOL 0x10 | 226 #define FX_FONT_FLAG_SYMBOLIC_SYMBOL 0x10 |
227 #define FX_FONT_FLAG_SYMBOLIC_DINGBATS 0x20 | 227 #define FX_FONT_FLAG_SYMBOLIC_DINGBATS 0x20 |
228 #define FX_FONT_FLAG_MULTIPLEMASTER 0x40 | 228 #define FX_FONT_FLAG_MULTIPLEMASTER 0x40 |
229 typedef struct { | 229 typedef struct { |
230 FX_LPCBYTE m_pFontData; | 230 FX_LPCBYTE m_pFontData; |
231 FX_DWORD m_dwSize; | 231 FX_DWORD m_dwSize; |
232 } FoxitFonts; | 232 } FoxitFonts; |
233 class CFX_FontMgr : public CFX_Object | 233 class CFX_FontMgr |
234 { | 234 { |
235 public: | 235 public: |
236 CFX_FontMgr(); | 236 CFX_FontMgr(); |
237 ~CFX_FontMgr(); | 237 ~CFX_FontMgr(); |
238 void InitFTLibrary(); | 238 void InitFTLibrary(); |
239 FXFT_Face GetCachedFace(const CFX_ByteString& face_name, | 239 FXFT_Face GetCachedFace(const CFX_ByteString& face_name, |
240 int weight, FX_BOOL bItalic, FX_LPBYTE& pFontD
ata); | 240 int weight, FX_BOOL bItalic, FX_LPBYTE& pFontD
ata); |
241 FXFT_Face AddCachedFace(const CFX_ByteString& face_name, | 241 FXFT_Face AddCachedFace(const CFX_ByteString& face_name, |
242 int weight, FX_BOOL bItalic, FX_LPBYTE pData,
FX_DWORD size, int face_index); | 242 int weight, FX_BOOL bItalic, FX_LPBYTE pData,
FX_DWORD size, int face_index); |
243 FXFT_Face GetCachedTTCFace(int ttc_size, FX_DWORD checksum, | 243 FXFT_Face GetCachedTTCFace(int ttc_size, FX_DWORD checksum, |
244 int font_offset, FX_LPBYTE& pFontData); | 244 int font_offset, FX_LPBYTE& pFontData); |
245 FXFT_Face AddCachedTTCFace(int ttc_size, FX_DWORD checksum, | 245 FXFT_Face AddCachedTTCFace(int ttc_size, FX_DWORD checksum, |
246 FX_LPBYTE pData, FX_DWORD size, int font_of
fset); | 246 FX_LPBYTE pData, FX_DWORD size, int font_of
fset); |
247 FXFT_Face GetFileFace(FX_LPCSTR filename, int face_index); | 247 FXFT_Face GetFileFace(FX_LPCSTR filename, int face_index); |
248 FXFT_Face GetFixedFace(FX_LPCBYTE pData, FX_DWORD size, int face_i
ndex); | 248 FXFT_Face GetFixedFace(FX_LPCBYTE pData, FX_DWORD size, int face_i
ndex); |
249 void ReleaseFace(FXFT_Face face); | 249 void ReleaseFace(FXFT_Face face); |
250 void SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo)
; | 250 void SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo)
; |
251 FXFT_Face FindSubstFont(const CFX_ByteString& face_name, FX_BOOL b
TrueType, FX_DWORD flags, | 251 FXFT_Face FindSubstFont(const CFX_ByteString& face_name, FX_BOOL b
TrueType, FX_DWORD flags, |
252 int weight, int italic_angle, int CharsetCP, C
FX_SubstFont* pSubstFont); | 252 int weight, int italic_angle, int CharsetCP, C
FX_SubstFont* pSubstFont); |
253 | 253 |
254 void FreeCache(); | 254 void FreeCache(); |
255 | 255 |
256 FX_BOOL GetStandardFont(FX_LPCBYTE& pFontData, FX_DWORD&
size, int index); | 256 FX_BOOL GetStandardFont(FX_LPCBYTE& pFontData, FX_DWORD&
size, int index); |
257 CFX_FontMapper* m_pBuiltinMapper; | 257 CFX_FontMapper* m_pBuiltinMapper; |
258 IFX_FontMapper* m_pExtMapper; | 258 IFX_FontMapper* m_pExtMapper; |
259 CFX_MapByteStringToPtr m_FaceMap; | 259 CFX_MapByteStringToPtr m_FaceMap; |
260 FXFT_Library m_FTLibrary; | 260 FXFT_Library m_FTLibrary; |
261 FoxitFonts m_ExternalFonts[16]; | 261 FoxitFonts m_ExternalFonts[16]; |
262 }; | 262 }; |
263 class IFX_FontMapper : public CFX_Object | 263 class IFX_FontMapper |
264 { | 264 { |
265 public: | 265 public: |
266 | 266 |
267 virtual ~IFX_FontMapper() {} | 267 virtual ~IFX_FontMapper() {} |
268 | 268 |
269 virtual FXFT_Face FindSubstFont(const CFX_ByteString& face_name, FX_BOOL b
TrueType, FX_DWORD flags, | 269 virtual FXFT_Face FindSubstFont(const CFX_ByteString& face_name, FX_BOOL b
TrueType, FX_DWORD flags, |
270 int weight, int italic_angle, int CharsetC
P, CFX_SubstFont* pSubstFont) = 0; | 270 int weight, int italic_angle, int CharsetC
P, CFX_SubstFont* pSubstFont) = 0; |
271 | 271 |
272 CFX_FontMgr* m_pFontMgr; | 272 CFX_FontMgr* m_pFontMgr; |
273 }; | 273 }; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 | 318 |
319 FX_BOOL m_bListLoaded; | 319 FX_BOOL m_bListLoaded; |
320 FXFT_Face m_MMFaces[2]; | 320 FXFT_Face m_MMFaces[2]; |
321 CFX_ByteString m_LastFamily; | 321 CFX_ByteString m_LastFamily; |
322 CFX_DWordArray m_CharsetArray; | 322 CFX_DWordArray m_CharsetArray; |
323 CFX_ByteStringArray m_FaceArray; | 323 CFX_ByteStringArray m_FaceArray; |
324 IFX_SystemFontInfo* m_pFontInfo; | 324 IFX_SystemFontInfo* m_pFontInfo; |
325 FXFT_Face m_FoxitFaces[14]; | 325 FXFT_Face m_FoxitFaces[14]; |
326 IFX_FontEnumerator* m_pFontEnumerator; | 326 IFX_FontEnumerator* m_pFontEnumerator; |
327 }; | 327 }; |
328 class IFX_SystemFontInfo : public CFX_Object | 328 class IFX_SystemFontInfo |
329 { | 329 { |
330 public: | 330 public: |
331 static IFX_SystemFontInfo* CreateDefault(); | 331 static IFX_SystemFontInfo* CreateDefault(); |
332 virtual void Release() = 0; | 332 virtual void Release() = 0; |
333 | 333 |
334 virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper) = 0; | 334 virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper) = 0; |
335 virtual void* MapFont(int weight, FX_BOOL bItalic, int charset
, int pitch_family, FX_LPCSTR face, FX_BOOL& bExact) = 0; | 335 virtual void* MapFont(int weight, FX_BOOL bItalic, int charset
, int pitch_family, FX_LPCSTR face, FX_BOOL& bExact) = 0; |
336 virtual void* MapFontByUnicode(FX_DWORD dwUnicode, int weight,
FX_BOOL bItalic, int pitch_family) | 336 virtual void* MapFontByUnicode(FX_DWORD dwUnicode, int weight,
FX_BOOL bItalic, int pitch_family) |
337 { | 337 { |
338 return NULL; | 338 return NULL; |
(...skipping 30 matching lines...) Expand all Loading... |
369 virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name); | 369 virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name); |
370 virtual FX_BOOL GetFontCharset(void* hFont, int& charset); | 370 virtual FX_BOOL GetFontCharset(void* hFont, int& charset); |
371 protected: | 371 protected: |
372 CFX_MapByteStringToPtr m_FontList; | 372 CFX_MapByteStringToPtr m_FontList; |
373 CFX_ByteStringArray m_PathList; | 373 CFX_ByteStringArray m_PathList; |
374 CFX_FontMapper* m_pMapper; | 374 CFX_FontMapper* m_pMapper; |
375 void ScanPath(CFX_ByteString& path); | 375 void ScanPath(CFX_ByteString& path); |
376 void ScanFile(CFX_ByteString& path); | 376 void ScanFile(CFX_ByteString& path); |
377 void ReportFace(CFX_ByteString& path, FXSYS_F
ILE* pFile, FX_DWORD filesize, FX_DWORD offset); | 377 void ReportFace(CFX_ByteString& path, FXSYS_F
ILE* pFile, FX_DWORD filesize, FX_DWORD offset); |
378 }; | 378 }; |
379 class CFX_CountedFaceCache : public CFX_Object | 379 class CFX_CountedFaceCache |
380 { | 380 { |
381 public: | 381 public: |
382 CFX_FaceCache* m_Obj; | 382 CFX_FaceCache* m_Obj; |
383 FX_DWORD m_nCount; | 383 FX_DWORD m_nCount; |
384 }; | 384 }; |
385 typedef CFX_MapPtrTemplate<FXFT_Face, CFX_CountedFaceCache*> CFX_FTCacheMap; | 385 typedef CFX_MapPtrTemplate<FXFT_Face, CFX_CountedFaceCache*> CFX_FTCacheMap; |
386 class CFX_FontCache : public CFX_Object | 386 class CFX_FontCache |
387 { | 387 { |
388 public: | 388 public: |
389 ~CFX_FontCache(); | 389 ~CFX_FontCache(); |
390 CFX_FaceCache* GetCachedFace(CFX_Font* pFont); | 390 CFX_FaceCache* GetCachedFace(CFX_Font* pFont); |
391 void ReleaseCachedFace(CFX_Font* pFon
t); | 391 void ReleaseCachedFace(CFX_Font* pFon
t); |
392 void FreeCache(FX_BOOL bRelease = FAL
SE); | 392 void FreeCache(FX_BOOL bRelease = FAL
SE); |
393 | 393 |
394 private: | 394 private: |
395 CFX_FTCacheMap m_FTFaceMap; | 395 CFX_FTCacheMap m_FTFaceMap; |
396 CFX_FTCacheMap m_ExtFaceMap; | 396 CFX_FTCacheMap m_ExtFaceMap; |
397 }; | 397 }; |
398 class CFX_AutoFontCache | 398 class CFX_AutoFontCache |
399 { | 399 { |
400 public: | 400 public: |
401 CFX_AutoFontCache(CFX_FontCache* pFontCache, CFX_Font* pFont) | 401 CFX_AutoFontCache(CFX_FontCache* pFontCache, CFX_Font* pFont) |
402 : m_pFontCache(pFontCache) | 402 : m_pFontCache(pFontCache) |
403 , m_pFont(pFont) | 403 , m_pFont(pFont) |
404 { | 404 { |
405 } | 405 } |
406 ~CFX_AutoFontCache() | 406 ~CFX_AutoFontCache() |
407 { | 407 { |
408 m_pFontCache->ReleaseCachedFace(m_pFont); | 408 m_pFontCache->ReleaseCachedFace(m_pFont); |
409 } | 409 } |
410 CFX_FontCache* m_pFontCache; | 410 CFX_FontCache* m_pFontCache; |
411 CFX_Font* m_pFont; | 411 CFX_Font* m_pFont; |
412 }; | 412 }; |
413 #define FX_FONTCACHE_DEFINE(pFontCache, pFont) CFX_AutoFontCache autoFontCache((
pFontCache), (pFont)) | 413 #define FX_FONTCACHE_DEFINE(pFontCache, pFont) CFX_AutoFontCache autoFontCache((
pFontCache), (pFont)) |
414 class CFX_GlyphBitmap : public CFX_Object | 414 class CFX_GlyphBitmap |
415 { | 415 { |
416 public: | 416 public: |
417 int m_Top; | 417 int m_Top; |
418 int m_Left; | 418 int m_Left; |
419 CFX_DIBitmap m_Bitmap; | 419 CFX_DIBitmap m_Bitmap; |
420 }; | 420 }; |
421 class CFX_FaceCache : public CFX_Object | 421 class CFX_FaceCache |
422 { | 422 { |
423 public: | 423 public: |
424 ~CFX_FaceCache(); | 424 ~CFX_FaceCache(); |
425 const CFX_GlyphBitmap* LoadGlyphBitmap(CFX_Font* pFont, FX_DWORD glyph_
index, FX_BOOL bFontStyle, const CFX_AffineMatrix* pMatrix, | 425 const CFX_GlyphBitmap* LoadGlyphBitmap(CFX_Font* pFont, FX_DWORD glyph_
index, FX_BOOL bFontStyle, const CFX_AffineMatrix* pMatrix, |
426 int dest_width, int anti_alias, int&
text_flags); | 426 int dest_width, int anti_alias, int&
text_flags); |
427 const CFX_PathData* LoadGlyphPath(CFX_Font* pFont, FX_DWORD glyph_in
dex, int dest_width); | 427 const CFX_PathData* LoadGlyphPath(CFX_Font* pFont, FX_DWORD glyph_in
dex, int dest_width); |
428 | 428 |
429 | 429 |
430 CFX_FaceCache(FXFT_Face face); | 430 CFX_FaceCache(FXFT_Face face); |
431 private: | 431 private: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 { | 464 { |
465 public: | 465 public: |
466 virtual void Release() = 0; | 466 virtual void Release() = 0; |
467 virtual FX_BOOL GetVerticalGlyph(FX_DWORD glyphnum, FX_DWORD* vglyphnum) = 0
; | 467 virtual FX_BOOL GetVerticalGlyph(FX_DWORD glyphnum, FX_DWORD* vglyphnum) = 0
; |
468 | 468 |
469 protected: | 469 protected: |
470 ~IFX_GSUBTable() { } | 470 ~IFX_GSUBTable() { } |
471 }; | 471 }; |
472 IFX_GSUBTable* FXGE_CreateGSUBTable(CFX_Font* pFont); | 472 IFX_GSUBTable* FXGE_CreateGSUBTable(CFX_Font* pFont); |
473 #endif | 473 #endif |
OLD | NEW |