| 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> |
| 11 | 11 |
| 12 #include "../fxcrt/fx_system.h" | 12 #include "../fxcrt/fx_system.h" |
| 13 #include "fx_dib.h" | 13 #include "fx_dib.h" |
| 14 | 14 |
| 15 typedef struct FT_FaceRec_* FXFT_Face; | 15 typedef struct FT_FaceRec_* FXFT_Face; |
| 16 typedef void* FXFT_Library; | 16 typedef void* FXFT_Library; |
| 17 class IFX_FontEncoding; | 17 class IFX_FontEncoding; |
| 18 class CFX_PathData; | 18 class CFX_PathData; |
| 19 class CFX_SubstFont; | 19 class CFX_SubstFont; |
| 20 class CFX_FaceCache; | 20 class CFX_FaceCache; |
| 21 class CFX_FontMapper; | 21 class CFX_FontMapper; |
| 22 class IFX_SystemFontInfo; | 22 class IFX_SystemFontInfo; |
| 23 class CFontFileFaceInfo; | 23 class CFontFileFaceInfo; |
| 24 #define FXFONT_FIXED_PITCH» » 0x01 | 24 #define FXFONT_FIXED_PITCH 0x01 |
| 25 #define FXFONT_SERIF» » » 0x02 | 25 #define FXFONT_SERIF 0x02 |
| 26 #define FXFONT_SYMBOLIC»» » 0x04 | 26 #define FXFONT_SYMBOLIC 0x04 |
| 27 #define FXFONT_SCRIPT» » » 0x08 | 27 #define FXFONT_SCRIPT 0x08 |
| 28 #define FXFONT_ITALIC» » » 0x40 | 28 #define FXFONT_ITALIC 0x40 |
| 29 #define FXFONT_BOLD» » » » 0x40000 | 29 #define FXFONT_BOLD 0x40000 |
| 30 #define FXFONT_USEEXTERNATTR» 0x80000 | 30 #define FXFONT_USEEXTERNATTR 0x80000 |
| 31 #define FXFONT_CIDFONT» » » 0x100000 | 31 #define FXFONT_CIDFONT 0x100000 |
| 32 #define FXFONT_ANSI_CHARSET» » 0 | 32 #define FXFONT_ANSI_CHARSET 0 |
| 33 #define FXFONT_DEFAULT_CHARSET» 1 | 33 #define FXFONT_DEFAULT_CHARSET 1 |
| 34 #define FXFONT_SYMBOL_CHARSET» 2 | 34 #define FXFONT_SYMBOL_CHARSET 2 |
| 35 #define FXFONT_SHIFTJIS_CHARSET»128 | 35 #define FXFONT_SHIFTJIS_CHARSET 128 |
| 36 #define FXFONT_HANGEUL_CHARSET» 129 | 36 #define FXFONT_HANGEUL_CHARSET 129 |
| 37 #define FXFONT_GB2312_CHARSET» 134 | 37 #define FXFONT_GB2312_CHARSET 134 |
| 38 #define FXFONT_CHINESEBIG5_CHARSET» 136 | 38 #define FXFONT_CHINESEBIG5_CHARSET 136 |
| 39 #define FXFONT_THAI_CHARSET» » 222 | 39 #define FXFONT_THAI_CHARSET 222 |
| 40 #define FXFONT_EASTEUROPE_CHARSET» 238 | 40 #define FXFONT_EASTEUROPE_CHARSET 238 |
| 41 #define FXFONT_RUSSIAN_CHARSET» 204 | 41 #define FXFONT_RUSSIAN_CHARSET 204 |
| 42 #define FXFONT_GREEK_CHARSET» 161 | 42 #define FXFONT_GREEK_CHARSET 161 |
| 43 #define FXFONT_TURKISH_CHARSET» 162 | 43 #define FXFONT_TURKISH_CHARSET 162 |
| 44 #define FXFONT_HEBREW_CHARSET» 177 | 44 #define FXFONT_HEBREW_CHARSET 177 |
| 45 #define FXFONT_ARABIC_CHARSET» 178 | 45 #define FXFONT_ARABIC_CHARSET 178 |
| 46 #define FXFONT_BALTIC_CHARSET» 186 | 46 #define FXFONT_BALTIC_CHARSET 186 |
| 47 #define FXFONT_FF_FIXEDPITCH» 1 | 47 #define FXFONT_FF_FIXEDPITCH 1 |
| 48 #define FXFONT_FF_ROMAN»» » (1<<4) | 48 #define FXFONT_FF_ROMAN (1 << 4) |
| 49 #define FXFONT_FF_SCRIPT» » (4<<4) | 49 #define FXFONT_FF_SCRIPT (4 << 4) |
| 50 #define FXFONT_FW_NORMAL» » 400 | 50 #define FXFONT_FW_NORMAL 400 |
| 51 #define FXFONT_FW_BOLD» » » 700 | 51 #define FXFONT_FW_BOLD 700 |
| 52 class CFX_Font | 52 class CFX_Font { |
| 53 { | 53 public: |
| 54 public: | 54 CFX_Font(); |
| 55 CFX_Font(); | 55 ~CFX_Font(); |
| 56 ~CFX_Font(); | 56 |
| 57 | 57 FX_BOOL LoadSubst(const CFX_ByteString& face_name, |
| 58 FX_BOOL» » » » » LoadSubst(const CFX_ByteString&
face_name, FX_BOOL bTrueType, FX_DWORD flags, | 58 FX_BOOL bTrueType, |
| 59 int weight, int italic_angle, int CharsetC
P, FX_BOOL bVertical = FALSE); | 59 FX_DWORD flags, |
| 60 | 60 int weight, |
| 61 FX_BOOL» » » » » LoadEmbedded(const uint8_t* data
, FX_DWORD size); | 61 int italic_angle, |
| 62 | 62 int CharsetCP, |
| 63 FX_BOOL» » » » » LoadFile(IFX_FileRead* pFile); | 63 FX_BOOL bVertical = FALSE); |
| 64 | 64 |
| 65 FXFT_Face» » » » GetFace() const | 65 FX_BOOL LoadEmbedded(const uint8_t* data, FX_DWORD size); |
| 66 { | 66 |
| 67 return m_Face; | 67 FX_BOOL LoadFile(IFX_FileRead* pFile); |
| 68 } | 68 |
| 69 | 69 FXFT_Face GetFace() const { return m_Face; } |
| 70 | 70 |
| 71 const CFX_SubstFont*» GetSubstFont() const | 71 const CFX_SubstFont* GetSubstFont() const { return m_pSubstFont; } |
| 72 { | 72 |
| 73 return m_pSubstFont; | 73 CFX_PathData* LoadGlyphPath(FX_DWORD glyph_index, int dest_width = 0); |
| 74 } | 74 |
| 75 | 75 int GetGlyphWidth(FX_DWORD glyph_index); |
| 76 CFX_PathData*» » » LoadGlyphPath(FX_DWORD glyph_index, int
dest_width = 0); | 76 |
| 77 | 77 int GetAscent() const; |
| 78 int»» » » » » GetGlyphWidth(FX_DWORD glyph_ind
ex); | 78 |
| 79 | 79 int GetDescent() const; |
| 80 int»» » » » » GetAscent() const; | 80 |
| 81 | 81 FX_BOOL GetGlyphBBox(FX_DWORD glyph_index, FX_RECT& bbox); |
| 82 int»» » » » » GetDescent() const; | 82 |
| 83 | 83 FX_BOOL IsItalic(); |
| 84 FX_BOOL GetGlyphBBox(FX_DWORD glyph_index, FX_RECT &bbox); | 84 |
| 85 | 85 FX_BOOL IsBold(); |
| 86 FX_BOOL IsItalic(); | 86 |
| 87 | 87 FX_BOOL IsFixedWidth(); |
| 88 FX_BOOL IsBold(); | 88 |
| 89 | 89 FX_BOOL IsVertical() const { return m_bVertical; } |
| 90 FX_BOOL IsFixedWidth(); | 90 |
| 91 | 91 CFX_WideString GetPsName() const; |
| 92 FX_BOOL» » » » » IsVertical() const | 92 |
| 93 { | 93 CFX_ByteString GetFamilyName() const; |
| 94 return m_bVertical; | 94 |
| 95 } | 95 CFX_ByteString GetFaceName() const; |
| 96 | 96 |
| 97 CFX_WideString GetPsName() const; | 97 FX_BOOL IsTTFont(); |
| 98 | 98 |
| 99 | 99 FX_BOOL GetBBox(FX_RECT& bbox); |
| 100 CFX_ByteString GetFamilyName() const; | 100 |
| 101 | 101 int GetHeight(); |
| 102 CFX_ByteString GetFaceName() const; | 102 |
| 103 | 103 int GetULPos(); |
| 104 | 104 |
| 105 FX_BOOL IsTTFont(); | 105 int GetULthickness(); |
| 106 | 106 |
| 107 FX_BOOL GetBBox(FX_RECT &bbox); | 107 int GetMaxAdvanceWidth(); |
| 108 | 108 |
| 109 int GetHeight(); | 109 FXFT_Face m_Face; |
| 110 | 110 |
| 111 int GetULPos(); | 111 CFX_SubstFont* m_pSubstFont; |
| 112 | 112 FX_BOOL IsEmbedded() { return m_bEmbedded; } |
| 113 int GetULthickness(); | 113 |
| 114 | 114 void AdjustMMParams(int glyph_index, int width, int weight); |
| 115 int GetMaxAdvanceWidth(); | 115 uint8_t* m_pFontDataAllocation; |
| 116 | 116 uint8_t* m_pFontData; |
| 117 FXFT_Face» » » » m_Face; | 117 uint8_t* m_pGsubData; |
| 118 | 118 FX_DWORD m_dwSize; |
| 119 CFX_SubstFont*» » » m_pSubstFont; | 119 CFX_BinaryBuf m_OtfFontData; |
| 120 FX_BOOL» » » » » IsEmbedded() | 120 void* m_hHandle; |
| 121 { | 121 void* m_pPlatformFont; |
| 122 return m_bEmbedded; | 122 void* m_pPlatformFontCollection; |
| 123 } | 123 void* m_pDwFont; |
| 124 | 124 FX_BOOL m_bDwLoaded; |
| 125 void» » » » » AdjustMMParams(int glyph_index,
int width, int weight); | 125 void ReleasePlatformResource(); |
| 126 uint8_t*» » » » m_pFontDataAllocation; | 126 |
| 127 uint8_t* m_pFontData; | 127 void DeleteFace(); |
| 128 uint8_t*» » » » m_pGsubData; | 128 |
| 129 FX_DWORD m_dwSize; | 129 protected: |
| 130 CFX_BinaryBuf m_OtfFontData; | 130 FX_BOOL m_bEmbedded; |
| 131 void* m_hHandle; | 131 FX_BOOL m_bVertical; |
| 132 void* m_pPlatformFont; | 132 void* m_pOwnedStream; |
| 133 void* m_pPlatformFontCollection; | 133 }; |
| 134 void* m_pDwFont; | 134 #define ENCODING_INTERNAL 0 |
| 135 FX_BOOL m_bDwLoaded; | 135 #define ENCODING_UNICODE 1 |
| 136 void ReleasePlatformResource(); | 136 class IFX_FontEncoding { |
| 137 | 137 public: |
| 138 void» » » » » DeleteFace(); | 138 virtual ~IFX_FontEncoding() {} |
| 139 protected: | 139 |
| 140 | 140 virtual FX_DWORD GlyphFromCharCode(FX_DWORD charcode) = 0; |
| 141 FX_BOOL» » » » » m_bEmbedded; | 141 |
| 142 FX_BOOL» » » » » m_bVertical; | 142 virtual CFX_WideString UnicodeFromCharCode(FX_DWORD charcode) const = 0; |
| 143 void*» » » » » m_pOwnedStream; | 143 |
| 144 }; | 144 virtual FX_DWORD CharCodeFromUnicode(FX_WCHAR Unicode) const = 0; |
| 145 #define ENCODING_INTERNAL» » 0 | |
| 146 #define ENCODING_UNICODE» » 1 | |
| 147 class IFX_FontEncoding | |
| 148 { | |
| 149 public: | |
| 150 virtual ~IFX_FontEncoding() {} | |
| 151 | |
| 152 virtual FX_DWORD» » GlyphFromCharCode(FX_DWORD charcode) = 0; | |
| 153 | |
| 154 virtual CFX_WideString» UnicodeFromCharCode(FX_DWORD charcode) const = 0
; | |
| 155 | |
| 156 virtual FX_DWORD» » CharCodeFromUnicode(FX_WCHAR Unicode) const = 0; | |
| 157 }; | 145 }; |
| 158 IFX_FontEncoding* FXGE_CreateUnicodeEncoding(CFX_Font* pFont); | 146 IFX_FontEncoding* FXGE_CreateUnicodeEncoding(CFX_Font* pFont); |
| 159 #define FXFONT_SUBST_MM»» » » 0x01 | 147 #define FXFONT_SUBST_MM 0x01 |
| 160 #define FXFONT_SUBST_GLYPHPATH» » 0x04 | 148 #define FXFONT_SUBST_GLYPHPATH 0x04 |
| 161 #define FXFONT_SUBST_CLEARTYPE» » 0x08 | 149 #define FXFONT_SUBST_CLEARTYPE 0x08 |
| 162 #define FXFONT_SUBST_TRANSFORM» » 0x10 | 150 #define FXFONT_SUBST_TRANSFORM 0x10 |
| 163 #define FXFONT_SUBST_NONSYMBOL» » 0x20 | 151 #define FXFONT_SUBST_NONSYMBOL 0x20 |
| 164 #define FXFONT_SUBST_EXACT» » » 0x40 | 152 #define FXFONT_SUBST_EXACT 0x40 |
| 165 #define FXFONT_SUBST_STANDARD» » 0x80 | 153 #define FXFONT_SUBST_STANDARD 0x80 |
| 166 class CFX_SubstFont | 154 class CFX_SubstFont { |
| 167 { | 155 public: |
| 168 public: | 156 CFX_SubstFont(); |
| 169 | 157 |
| 170 CFX_SubstFont(); | 158 void* m_ExtHandle; |
| 171 | 159 |
| 172 void*» » » » m_ExtHandle; | 160 CFX_ByteString m_Family; |
| 173 | 161 |
| 174 CFX_ByteString» » » m_Family; | 162 int m_Charset; |
| 175 | 163 |
| 176 int»» » » » » m_Charset; | 164 FX_DWORD m_SubstFlags; |
| 177 | 165 |
| 178 FX_DWORD» » » » m_SubstFlags; | 166 int m_Weight; |
| 179 | 167 |
| 180 int»» » » » » m_Weight; | 168 int m_ItalicAngle; |
| 181 | 169 |
| 182 int»» » » » » m_ItalicAngle; | 170 FX_BOOL m_bSubstOfCJK; |
| 183 | 171 |
| 184 FX_BOOL» » » » » m_bSubstOfCJK; | 172 int m_WeightCJK; |
| 185 | 173 |
| 186 int»» » » » » m_WeightCJK; | 174 FX_BOOL m_bItlicCJK; |
| 187 | 175 }; |
| 188 FX_BOOL» » » » » m_bItlicCJK; | 176 #define FX_FONT_FLAG_SERIF 0x01 |
| 189 }; | 177 #define FX_FONT_FLAG_FIXEDPITCH 0x02 |
| 190 #define FX_FONT_FLAG_SERIF 0x01 | 178 #define FX_FONT_FLAG_ITALIC 0x04 |
| 191 #define FX_FONT_FLAG_FIXEDPITCH»» » 0x02 | 179 #define FX_FONT_FLAG_BOLD 0x08 |
| 192 #define FX_FONT_FLAG_ITALIC» » » » 0x04 | 180 #define FX_FONT_FLAG_SYMBOLIC_SYMBOL 0x10 |
| 193 #define FX_FONT_FLAG_BOLD» » » » 0x08 | 181 #define FX_FONT_FLAG_SYMBOLIC_DINGBATS 0x20 |
| 194 #define FX_FONT_FLAG_SYMBOLIC_SYMBOL» 0x10 | 182 #define FX_FONT_FLAG_MULTIPLEMASTER 0x40 |
| 195 #define FX_FONT_FLAG_SYMBOLIC_DINGBATS» 0x20 | |
| 196 #define FX_FONT_FLAG_MULTIPLEMASTER» » 0x40 | |
| 197 typedef struct { | 183 typedef struct { |
| 198 const uint8_t*» m_pFontData; | 184 const uint8_t* m_pFontData; |
| 199 FX_DWORD» m_dwSize; | 185 FX_DWORD m_dwSize; |
| 200 } FoxitFonts; | 186 } FoxitFonts; |
| 201 class CFX_FontMgr | 187 class CFX_FontMgr { |
| 202 { | 188 public: |
| 203 public: | 189 CFX_FontMgr(); |
| 204 CFX_FontMgr(); | 190 ~CFX_FontMgr(); |
| 205 ~CFX_FontMgr(); | 191 void InitFTLibrary(); |
| 206 void InitFTLibrary(); | 192 FXFT_Face GetCachedFace(const CFX_ByteString& face_name, |
| 207 FXFT_Face GetCachedFace(const CFX_ByteString& face_name, | 193 int weight, |
| 208 int weight, FX_BOOL bItalic, uint8_t*& pFontDa
ta); | 194 FX_BOOL bItalic, |
| 209 FXFT_Face AddCachedFace(const CFX_ByteString& face_name, | 195 uint8_t*& pFontData); |
| 210 int weight, FX_BOOL bItalic, uint8_t* pData, F
X_DWORD size, int face_index); | 196 FXFT_Face AddCachedFace(const CFX_ByteString& face_name, |
| 211 FXFT_Face GetCachedTTCFace(int ttc_size, FX_DWORD checksum, | 197 int weight, |
| 212 int font_offset, uint8_t*& pFontData); | 198 FX_BOOL bItalic, |
| 213 FXFT_Face AddCachedTTCFace(int ttc_size, FX_DWORD checksum, | 199 uint8_t* pData, |
| 214 uint8_t* pData, FX_DWORD size, int font_off
set); | 200 FX_DWORD size, |
| 215 FXFT_Face GetFileFace(const FX_CHAR* filename, int face_index); | 201 int face_index); |
| 216 FXFT_Face GetFixedFace(const uint8_t* pData, FX_DWORD size, int fa
ce_index); | 202 FXFT_Face GetCachedTTCFace(int ttc_size, |
| 217 void ReleaseFace(FXFT_Face face); | 203 FX_DWORD checksum, |
| 218 void SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo)
; | 204 int font_offset, |
| 219 FXFT_Face FindSubstFont(const CFX_ByteString& face_name, FX_BOOL b
TrueType, FX_DWORD flags, | 205 uint8_t*& pFontData); |
| 220 int weight, int italic_angle, int CharsetCP, C
FX_SubstFont* pSubstFont); | 206 FXFT_Face AddCachedTTCFace(int ttc_size, |
| 221 | 207 FX_DWORD checksum, |
| 222 void FreeCache(); | 208 uint8_t* pData, |
| 223 | 209 FX_DWORD size, |
| 224 FX_BOOL GetStandardFont(const uint8_t*& pFontData, FX_DW
ORD& size, int index); | 210 int font_offset); |
| 225 CFX_FontMapper* m_pBuiltinMapper; | 211 FXFT_Face GetFileFace(const FX_CHAR* filename, int face_index); |
| 226 CFX_MapByteStringToPtr m_FaceMap; | 212 FXFT_Face GetFixedFace(const uint8_t* pData, FX_DWORD size, int face_index); |
| 227 FXFT_Library m_FTLibrary; | 213 void ReleaseFace(FXFT_Face face); |
| 228 FoxitFonts m_ExternalFonts[16]; | 214 void SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo); |
| 229 }; | 215 FXFT_Face FindSubstFont(const CFX_ByteString& face_name, |
| 230 class IFX_FontEnumerator | 216 FX_BOOL bTrueType, |
| 231 { | 217 FX_DWORD flags, |
| 232 public: | 218 int weight, |
| 233 virtual ~IFX_FontEnumerator() { } | 219 int italic_angle, |
| 234 | 220 int CharsetCP, |
| 235 virtual void HitFont() = 0; | 221 CFX_SubstFont* pSubstFont); |
| 236 | 222 |
| 237 virtual void Finish() = 0; | 223 void FreeCache(); |
| 238 }; | 224 |
| 239 class IFX_AdditionalFontEnum | 225 FX_BOOL GetStandardFont(const uint8_t*& pFontData, FX_DWORD& size, int index); |
| 240 { | 226 CFX_FontMapper* m_pBuiltinMapper; |
| 241 public: | 227 CFX_MapByteStringToPtr m_FaceMap; |
| 242 virtual ~IFX_AdditionalFontEnum() { } | 228 FXFT_Library m_FTLibrary; |
| 243 virtual int CountFiles() = 0; | 229 FoxitFonts m_ExternalFonts[16]; |
| 244 virtual IFX_FileStream* GetFontFile(int index) = 0; | 230 }; |
| 245 }; | 231 class IFX_FontEnumerator { |
| 246 class CFX_FontMapper | 232 public: |
| 247 { | 233 virtual ~IFX_FontEnumerator() {} |
| 248 public: | 234 |
| 249 CFX_FontMapper(CFX_FontMgr* mgr); | 235 virtual void HitFont() = 0; |
| 250 ~CFX_FontMapper(); | 236 |
| 251 | 237 virtual void Finish() = 0; |
| 252 void SetSystemFontInfo(IFX_SystemFontInfo* pF
ontInfo); | 238 }; |
| 253 IFX_SystemFontInfo* GetSystemFontInfo() | 239 class IFX_AdditionalFontEnum { |
| 254 { | 240 public: |
| 255 return m_pFontInfo; | 241 virtual ~IFX_AdditionalFontEnum() {} |
| 256 } | 242 virtual int CountFiles() = 0; |
| 257 void AddInstalledFont(const CFX_ByteString& n
ame, int charset); | 243 virtual IFX_FileStream* GetFontFile(int index) = 0; |
| 258 void LoadInstalledFonts(); | 244 }; |
| 259 CFX_ByteStringArray m_InstalledTTFonts; | 245 class CFX_FontMapper { |
| 260 void SetFontEnumerator(IFX_FontEnumerator* pF
ontEnumerator) | 246 public: |
| 261 { | 247 CFX_FontMapper(CFX_FontMgr* mgr); |
| 262 m_pFontEnumerator = pFontEnumerator; | 248 ~CFX_FontMapper(); |
| 263 } | 249 |
| 264 IFX_FontEnumerator* GetFontEnumerator() const | 250 void SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo); |
| 265 { | 251 IFX_SystemFontInfo* GetSystemFontInfo() { return m_pFontInfo; } |
| 266 return m_pFontEnumerator; | 252 void AddInstalledFont(const CFX_ByteString& name, int charset); |
| 267 } | 253 void LoadInstalledFonts(); |
| 268 FXFT_Face FindSubstFont(const CFX_ByteString& face_name, FX_BOOL bTrueType,
FX_DWORD flags, | 254 CFX_ByteStringArray m_InstalledTTFonts; |
| 269 int weight, int italic_angle, int CharsetCP, CFX_Sub
stFont* pSubstFont); | 255 void SetFontEnumerator(IFX_FontEnumerator* pFontEnumerator) { |
| 270 private: | 256 m_pFontEnumerator = pFontEnumerator; |
| 271 CFX_ByteString GetPSNameFromTT(void* hFont); | 257 } |
| 272 CFX_ByteString MatchInstalledFonts(const CFX_ByteString& norm_n
ame); | 258 IFX_FontEnumerator* GetFontEnumerator() const { return m_pFontEnumerator; } |
| 273 FXFT_Face UseInternalSubst(CFX_SubstFont* pSubstFont, int
iBaseFont, int italic_angle, int weight, int picthfamily); | 259 FXFT_Face FindSubstFont(const CFX_ByteString& face_name, |
| 274 | 260 FX_BOOL bTrueType, |
| 275 FX_BOOL m_bListLoaded; | 261 FX_DWORD flags, |
| 276 FXFT_Face m_MMFaces[2]; | 262 int weight, |
| 277 CFX_ByteString m_LastFamily; | 263 int italic_angle, |
| 278 CFX_DWordArray m_CharsetArray; | 264 int CharsetCP, |
| 279 CFX_ByteStringArray m_FaceArray; | 265 CFX_SubstFont* pSubstFont); |
| 280 IFX_SystemFontInfo* m_pFontInfo; | 266 |
| 281 FXFT_Face m_FoxitFaces[14]; | 267 private: |
| 282 IFX_FontEnumerator* m_pFontEnumerator; | 268 CFX_ByteString GetPSNameFromTT(void* hFont); |
| 283 CFX_FontMgr* const m_pFontMgr; | 269 CFX_ByteString MatchInstalledFonts(const CFX_ByteString& norm_name); |
| 284 }; | 270 FXFT_Face UseInternalSubst(CFX_SubstFont* pSubstFont, |
| 285 class IFX_SystemFontInfo | 271 int iBaseFont, |
| 286 { | 272 int italic_angle, |
| 287 public: | 273 int weight, |
| 288 static IFX_SystemFontInfo* CreateDefault(); | 274 int picthfamily); |
| 289 virtual void Release() = 0; | 275 |
| 290 | 276 FX_BOOL m_bListLoaded; |
| 291 virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper) = 0; | 277 FXFT_Face m_MMFaces[2]; |
| 292 virtual void* MapFont(int weight, FX_BOOL bItalic, int charset
, int pitch_family, const FX_CHAR* face, int& iExact) = 0; | 278 CFX_ByteString m_LastFamily; |
| 293 virtual void* GetFont(const FX_CHAR* face) = 0; | 279 CFX_DWordArray m_CharsetArray; |
| 294 virtual FX_DWORD GetFontData(void* hFont, FX_DWORD table, uint8_t* buffer
, FX_DWORD size) = 0; | 280 CFX_ByteStringArray m_FaceArray; |
| 295 virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) =
0; | 281 IFX_SystemFontInfo* m_pFontInfo; |
| 296 virtual FX_BOOL GetFontCharset(void* hFont, int& charset) = 0; | 282 FXFT_Face m_FoxitFaces[14]; |
| 297 virtual int GetFaceIndex(void* hFont) | 283 IFX_FontEnumerator* m_pFontEnumerator; |
| 298 { | 284 CFX_FontMgr* const m_pFontMgr; |
| 299 return 0; | 285 }; |
| 300 } | 286 class IFX_SystemFontInfo { |
| 301 virtual void DeleteFont(void* hFont) = 0; | 287 public: |
| 302 virtual void* RetainFont(void* hFont) | 288 static IFX_SystemFontInfo* CreateDefault(); |
| 303 { | 289 virtual void Release() = 0; |
| 304 return NULL; | 290 |
| 305 } | 291 virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper) = 0; |
| 306 protected: | 292 virtual void* MapFont(int weight, |
| 307 ~IFX_SystemFontInfo() { } | 293 FX_BOOL bItalic, |
| 308 }; | 294 int charset, |
| 309 class CFX_FolderFontInfo : public IFX_SystemFontInfo | 295 int pitch_family, |
| 310 { | 296 const FX_CHAR* face, |
| 311 public: | 297 int& iExact) = 0; |
| 312 CFX_FolderFontInfo(); | 298 virtual void* GetFont(const FX_CHAR* face) = 0; |
| 313 virtual ~CFX_FolderFontInfo(); | 299 virtual FX_DWORD GetFontData(void* hFont, |
| 314 void AddPath(const CFX_ByteStringC& path); | 300 FX_DWORD table, |
| 315 | 301 uint8_t* buffer, |
| 316 // IFX_SytemFontInfo: | 302 FX_DWORD size) = 0; |
| 317 void Release() override; | 303 virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) = 0; |
| 318 FX_BOOL EnumFontList(CFX_FontMapper* pMapper) override; | 304 virtual FX_BOOL GetFontCharset(void* hFont, int& charset) = 0; |
| 319 void* MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, | 305 virtual int GetFaceIndex(void* hFont) { return 0; } |
| 320 const FX_CHAR* face, int& bExact) override; | 306 virtual void DeleteFont(void* hFont) = 0; |
| 321 void* GetFont(const FX_CHAR* face) override; | 307 virtual void* RetainFont(void* hFont) { return NULL; } |
| 322 FX_DWORD GetFontData(void* hFont, FX_DWORD table, | 308 |
| 323 uint8_t* buffer, FX_DWORD size) override; | 309 protected: |
| 324 void DeleteFont(void* hFont) override; | 310 ~IFX_SystemFontInfo() {} |
| 325 FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) override; | 311 }; |
| 326 FX_BOOL GetFontCharset(void* hFont, int& charset) override; | 312 class CFX_FolderFontInfo : public IFX_SystemFontInfo { |
| 327 | 313 public: |
| 328 protected: | 314 CFX_FolderFontInfo(); |
| 329 CFX_MapByteStringToPtr m_FontList; | 315 virtual ~CFX_FolderFontInfo(); |
| 330 CFX_ByteStringArray m_PathList; | 316 void AddPath(const CFX_ByteStringC& path); |
| 331 CFX_FontMapper* m_pMapper; | 317 |
| 332 void ScanPath(CFX_ByteString& path); | 318 // IFX_SytemFontInfo: |
| 333 void ScanFile(CFX_ByteString& path); | 319 void Release() override; |
| 334 void ReportFace(CFX_ByteString& path, FXSYS_F
ILE* pFile, FX_DWORD filesize, FX_DWORD offset); | 320 FX_BOOL EnumFontList(CFX_FontMapper* pMapper) override; |
| 335 }; | 321 void* MapFont(int weight, |
| 336 class CFX_CountedFaceCache | 322 FX_BOOL bItalic, |
| 337 { | 323 int charset, |
| 338 public: | 324 int pitch_family, |
| 339 CFX_FaceCache* m_Obj; | 325 const FX_CHAR* face, |
| 340 FX_DWORD m_nCount; | 326 int& bExact) override; |
| 341 }; | 327 void* GetFont(const FX_CHAR* face) override; |
| 342 | 328 FX_DWORD GetFontData(void* hFont, |
| 343 class CFX_FontCache | 329 FX_DWORD table, |
| 344 { | 330 uint8_t* buffer, |
| 345 public: | 331 FX_DWORD size) override; |
| 346 ~CFX_FontCache(); | 332 void DeleteFont(void* hFont) override; |
| 347 CFX_FaceCache* GetCachedFace(CFX_Font* pFont); | 333 FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) override; |
| 348 void ReleaseCachedFace(CFX_Font* pFon
t); | 334 FX_BOOL GetFontCharset(void* hFont, int& charset) override; |
| 349 void FreeCache(FX_BOOL bRelease = FAL
SE); | 335 |
| 350 | 336 protected: |
| 351 private: | 337 CFX_MapByteStringToPtr m_FontList; |
| 352 using CFX_FTCacheMap = std::map<FXFT_Face, CFX_CountedFaceCache*>; | 338 CFX_ByteStringArray m_PathList; |
| 353 CFX_FTCacheMap m_FTFaceMap; | 339 CFX_FontMapper* m_pMapper; |
| 354 CFX_FTCacheMap m_ExtFaceMap; | 340 void ScanPath(CFX_ByteString& path); |
| 355 }; | 341 void ScanFile(CFX_ByteString& path); |
| 356 class CFX_AutoFontCache | 342 void ReportFace(CFX_ByteString& path, |
| 357 { | 343 FXSYS_FILE* pFile, |
| 358 public: | 344 FX_DWORD filesize, |
| 359 CFX_AutoFontCache(CFX_FontCache* pFontCache, CFX_Font* pFont) | 345 FX_DWORD offset); |
| 360 : m_pFontCache(pFontCache) | 346 }; |
| 361 , m_pFont(pFont) | 347 class CFX_CountedFaceCache { |
| 362 { | 348 public: |
| 363 } | 349 CFX_FaceCache* m_Obj; |
| 364 ~CFX_AutoFontCache() | 350 FX_DWORD m_nCount; |
| 365 { | 351 }; |
| 366 m_pFontCache->ReleaseCachedFace(m_pFont); | 352 |
| 367 } | 353 class CFX_FontCache { |
| 368 CFX_FontCache* m_pFontCache; | 354 public: |
| 369 CFX_Font* m_pFont; | 355 ~CFX_FontCache(); |
| 370 }; | 356 CFX_FaceCache* GetCachedFace(CFX_Font* pFont); |
| 371 #define FX_FONTCACHE_DEFINE(pFontCache, pFont) CFX_AutoFontCache autoFontCache((
pFontCache), (pFont)) | 357 void ReleaseCachedFace(CFX_Font* pFont); |
| 372 class CFX_GlyphBitmap | 358 void FreeCache(FX_BOOL bRelease = FALSE); |
| 373 { | 359 |
| 374 public: | 360 private: |
| 375 int m_Top; | 361 using CFX_FTCacheMap = std::map<FXFT_Face, CFX_CountedFaceCache*>; |
| 376 int m_Left; | 362 CFX_FTCacheMap m_FTFaceMap; |
| 377 CFX_DIBitmap m_Bitmap; | 363 CFX_FTCacheMap m_ExtFaceMap; |
| 378 }; | 364 }; |
| 379 class CFX_FaceCache | 365 class CFX_AutoFontCache { |
| 380 { | 366 public: |
| 381 public: | 367 CFX_AutoFontCache(CFX_FontCache* pFontCache, CFX_Font* pFont) |
| 382 ~CFX_FaceCache(); | 368 : m_pFontCache(pFontCache), m_pFont(pFont) {} |
| 383 const CFX_GlyphBitmap* LoadGlyphBitmap(CFX_Font* pFont, FX_DWORD glyph_
index, FX_BOOL bFontStyle, const CFX_AffineMatrix* pMatrix, | 369 ~CFX_AutoFontCache() { m_pFontCache->ReleaseCachedFace(m_pFont); } |
| 384 int dest_width, int anti_alias, int&
text_flags); | 370 CFX_FontCache* m_pFontCache; |
| 385 const CFX_PathData* LoadGlyphPath(CFX_Font* pFont, FX_DWORD glyph_in
dex, int dest_width); | 371 CFX_Font* m_pFont; |
| 386 | 372 }; |
| 387 | 373 #define FX_FONTCACHE_DEFINE(pFontCache, pFont) \ |
| 388 CFX_FaceCache(FXFT_Face face); | 374 CFX_AutoFontCache autoFontCache((pFontCache), (pFont)) |
| 389 private: | 375 class CFX_GlyphBitmap { |
| 390 FXFT_Face m_Face; | 376 public: |
| 391 CFX_GlyphBitmap* RenderGlyph(CFX_Font* pFont, FX_DWORD glyph_inde
x, FX_BOOL bFontStyle, | 377 int m_Top; |
| 392 const CFX_AffineMatrix* pMatrix, int des
t_width, int anti_alias); | 378 int m_Left; |
| 393 CFX_GlyphBitmap* RenderGlyph_Nativetext(CFX_Font* pFont, FX_DWORD
glyph_index, | 379 CFX_DIBitmap m_Bitmap; |
| 394 const CFX_AffineMatrix* pMatrix, int dest_width, int anti_alias); | 380 }; |
| 395 CFX_GlyphBitmap* LookUpGlyphBitmap(CFX_Font* pFont, const CFX_AffineM
atrix* pMatrix, CFX_ByteStringC& FaceGlyphsKey, | 381 class CFX_FaceCache { |
| 396 FX_DWORD glyph_index, FX_BOOL bFontStyle, int dest_width, int anti_a
lias); | 382 public: |
| 397 CFX_MapByteStringToPtr m_SizeMap; | 383 ~CFX_FaceCache(); |
| 398 CFX_MapPtrToPtr m_PathMap; | 384 const CFX_GlyphBitmap* LoadGlyphBitmap(CFX_Font* pFont, |
| 399 CFX_DIBitmap* m_pBitmap; | 385 FX_DWORD glyph_index, |
| 400 | 386 FX_BOOL bFontStyle, |
| 401 void InitPlatform(); | 387 const CFX_AffineMatrix* pMatrix, |
| 402 void DestroyPlatform(); | 388 int dest_width, |
| 389 int anti_alias, |
| 390 int& text_flags); |
| 391 const CFX_PathData* LoadGlyphPath(CFX_Font* pFont, |
| 392 FX_DWORD glyph_index, |
| 393 int dest_width); |
| 394 |
| 395 CFX_FaceCache(FXFT_Face face); |
| 396 |
| 397 private: |
| 398 FXFT_Face m_Face; |
| 399 CFX_GlyphBitmap* RenderGlyph(CFX_Font* pFont, |
| 400 FX_DWORD glyph_index, |
| 401 FX_BOOL bFontStyle, |
| 402 const CFX_AffineMatrix* pMatrix, |
| 403 int dest_width, |
| 404 int anti_alias); |
| 405 CFX_GlyphBitmap* RenderGlyph_Nativetext(CFX_Font* pFont, |
| 406 FX_DWORD glyph_index, |
| 407 const CFX_AffineMatrix* pMatrix, |
| 408 int dest_width, |
| 409 int anti_alias); |
| 410 CFX_GlyphBitmap* LookUpGlyphBitmap(CFX_Font* pFont, |
| 411 const CFX_AffineMatrix* pMatrix, |
| 412 CFX_ByteStringC& FaceGlyphsKey, |
| 413 FX_DWORD glyph_index, |
| 414 FX_BOOL bFontStyle, |
| 415 int dest_width, |
| 416 int anti_alias); |
| 417 CFX_MapByteStringToPtr m_SizeMap; |
| 418 CFX_MapPtrToPtr m_PathMap; |
| 419 CFX_DIBitmap* m_pBitmap; |
| 420 |
| 421 void InitPlatform(); |
| 422 void DestroyPlatform(); |
| 403 }; | 423 }; |
| 404 typedef struct { | 424 typedef struct { |
| 405 const CFX_GlyphBitmap*» m_pGlyph; | 425 const CFX_GlyphBitmap* m_pGlyph; |
| 406 int»» » » » m_OriginX, m_OriginY; | 426 int m_OriginX, m_OriginY; |
| 407 FX_FLOAT» » » m_fOriginX, m_fOriginY; | 427 FX_FLOAT m_fOriginX, m_fOriginY; |
| 408 } FXTEXT_GLYPHPOS; | 428 } FXTEXT_GLYPHPOS; |
| 409 FX_RECT FXGE_GetGlyphsBBox(FXTEXT_GLYPHPOS* pGlyphAndPos, int nChars, int anti_a
lias, FX_FLOAT retinaScaleX = 1.0f, FX_FLOAT retinaScaleY = 1.0f); | 429 FX_RECT FXGE_GetGlyphsBBox(FXTEXT_GLYPHPOS* pGlyphAndPos, |
| 410 FX_BOOL»OutputGlyph(void* dib, int x, int y, CFX_Font* pFont, double font_size, | 430 int nChars, |
| 411 CFX_AffineMatrix* pMatrix, unsigned long glyph_index, unsign
ed long argb); | 431 int anti_alias, |
| 412 FX_BOOL»OutputText(void* dib, int x, int y, CFX_Font* pFont, double font_size, | 432 FX_FLOAT retinaScaleX = 1.0f, |
| 413 CFX_AffineMatrix* pText_matrix, unsigned short const* text, u
nsigned long argb); | 433 FX_FLOAT retinaScaleY = 1.0f); |
| 414 class IFX_GSUBTable | 434 FX_BOOL OutputGlyph(void* dib, |
| 415 { | 435 int x, |
| 416 public: | 436 int y, |
| 417 static IFX_GSUBTable* Create(CFX_Font* pFont); | 437 CFX_Font* pFont, |
| 418 virtual ~IFX_GSUBTable() { } | 438 double font_size, |
| 419 virtual FX_BOOL GetVerticalGlyph(FX_DWORD glyphnum, FX_DWORD* vglyphnum) = 0
; | 439 CFX_AffineMatrix* pMatrix, |
| 440 unsigned long glyph_index, |
| 441 unsigned long argb); |
| 442 FX_BOOL OutputText(void* dib, |
| 443 int x, |
| 444 int y, |
| 445 CFX_Font* pFont, |
| 446 double font_size, |
| 447 CFX_AffineMatrix* pText_matrix, |
| 448 unsigned short const* text, |
| 449 unsigned long argb); |
| 450 class IFX_GSUBTable { |
| 451 public: |
| 452 static IFX_GSUBTable* Create(CFX_Font* pFont); |
| 453 virtual ~IFX_GSUBTable() {} |
| 454 virtual FX_BOOL GetVerticalGlyph(FX_DWORD glyphnum, FX_DWORD* vglyphnum) = 0; |
| 420 }; | 455 }; |
| 421 | 456 |
| 422 #endif // CORE_INCLUDE_FXGE_FX_FONT_H_ | 457 #endif // CORE_INCLUDE_FXGE_FX_FONT_H_ |
| OLD | NEW |