Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "xfa/fgas/font/fgas_stdfontmgr.h" | 7 #include "xfa/fgas/font/cfgas_fontmgr.h" |
| 8 | 8 |
| 9 #include "core/fxcrt/fx_stream.h" | 9 #include "core/fxcrt/fx_stream.h" |
| 10 #include "core/fxge/cfx_fontmapper.h" | 10 #include "core/fxge/cfx_fontmapper.h" |
| 11 #include "core/fxge/cfx_fontmgr.h" | 11 #include "core/fxge/cfx_fontmgr.h" |
| 12 #include "core/fxge/cfx_gemodule.h" | 12 #include "core/fxge/cfx_gemodule.h" |
| 13 #include "core/fxge/ifx_systemfontinfo.h" | 13 #include "core/fxge/ifx_systemfontinfo.h" |
| 14 #include "third_party/base/ptr_util.h" | |
| 14 #include "xfa/fgas/crt/fgas_codepage.h" | 15 #include "xfa/fgas/crt/fgas_codepage.h" |
| 15 #include "xfa/fgas/font/fgas_fontutils.h" | 16 #include "xfa/fgas/font/fgas_fontutils.h" |
| 16 #include "xfa/fgas/font/fgas_gefont.h" | 17 #include "xfa/fgas/font/fgas_gefont.h" |
| 17 | 18 |
| 18 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 19 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 19 | 20 |
| 20 std::unique_ptr<IFGAS_FontMgr> IFGAS_FontMgr::Create( | 21 namespace { |
| 21 FX_LPEnumAllFonts pEnumerator) { | 22 |
| 22 return std::unique_ptr<IFGAS_FontMgr>(new CFGAS_StdFontMgrImp(pEnumerator)); | 23 int32_t FX_GetSimilarValue(FX_FONTDESCRIPTOR const* pFont, |
|
Tom Sepez
2016/11/11 18:43:16
nit: no need for FX_, also can we call this GetSim
npm
2016/11/11 19:24:46
Done.
| |
| 24 uint32_t dwFontStyles) { | |
| 25 int32_t iValue = 0; | |
| 26 if ((dwFontStyles & FX_FONTSTYLE_Symbolic) == | |
| 27 (pFont->dwFontStyles & FX_FONTSTYLE_Symbolic)) { | |
| 28 iValue += 64; | |
| 29 } | |
| 30 if ((dwFontStyles & FX_FONTSTYLE_FixedPitch) == | |
| 31 (pFont->dwFontStyles & FX_FONTSTYLE_FixedPitch)) { | |
| 32 iValue += 32; | |
| 33 } | |
| 34 if ((dwFontStyles & FX_FONTSTYLE_Serif) == | |
| 35 (pFont->dwFontStyles & FX_FONTSTYLE_Serif)) { | |
| 36 iValue += 16; | |
| 37 } | |
| 38 if ((dwFontStyles & FX_FONTSTYLE_Script) == | |
| 39 (pFont->dwFontStyles & FX_FONTSTYLE_Script)) { | |
| 40 iValue += 8; | |
| 41 } | |
| 42 return iValue; | |
| 23 } | 43 } |
| 24 | 44 |
| 25 CFGAS_StdFontMgrImp::CFGAS_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator) | 45 FX_FONTDESCRIPTOR const* FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams, |
|
Tom Sepez
2016/11/11 18:43:16
nit: can we call this MatchDefaultFont()? A "matc
npm
2016/11/11 19:24:46
Done.
| |
| 46 const CFX_FontDescriptors& fonts) { | |
| 47 FX_FONTDESCRIPTOR const* pBestFont = nullptr; | |
| 48 int32_t iBestSimilar = 0; | |
| 49 bool bMatchStyle = (pParams->dwMatchFlags & FX_FONTMATCHPARA_MatchStyle) > 0; | |
| 50 for (int32_t i = 0; i < fonts.GetSize(); ++i) { | |
| 51 FX_FONTDESCRIPTOR const* pFont = fonts.GetPtrAt(i); | |
| 52 if ((pFont->dwFontStyles & FX_FONTSTYLE_BoldItalic) == | |
| 53 FX_FONTSTYLE_BoldItalic) { | |
| 54 continue; | |
| 55 } | |
| 56 if (pParams->pwsFamily) { | |
| 57 if (FXSYS_wcsicmp(pParams->pwsFamily, pFont->wsFontFace)) | |
| 58 continue; | |
| 59 if (pFont->uCharSet == FX_CHARSET_Symbol) | |
| 60 return pFont; | |
| 61 } | |
| 62 if (pFont->uCharSet == FX_CHARSET_Symbol) | |
| 63 continue; | |
| 64 if (pParams->wCodePage != 0xFFFF) { | |
| 65 if (FX_GetCodePageFromCharset(pFont->uCharSet) != pParams->wCodePage) | |
| 66 continue; | |
| 67 } else { | |
| 68 if (pParams->dwUSB < 128) { | |
| 69 uint32_t dwByte = pParams->dwUSB / 32; | |
| 70 uint32_t dwUSB = 1 << (pParams->dwUSB % 32); | |
| 71 if ((pFont->FontSignature.fsUsb[dwByte] & dwUSB) == 0) | |
| 72 continue; | |
| 73 } | |
| 74 } | |
| 75 if (bMatchStyle) { | |
| 76 if ((pFont->dwFontStyles & 0x0F) == (pParams->dwFontStyles & 0x0F)) | |
| 77 return pFont; | |
| 78 continue; | |
| 79 } | |
| 80 if (pParams->pwsFamily) { | |
| 81 if (FXSYS_wcsicmp(pParams->pwsFamily, pFont->wsFontFace) == 0) | |
| 82 return pFont; | |
| 83 } | |
| 84 int32_t iSimilarValue = FX_GetSimilarValue(pFont, pParams->dwFontStyles); | |
| 85 if (iBestSimilar < iSimilarValue) { | |
| 86 iBestSimilar = iSimilarValue; | |
| 87 pBestFont = pFont; | |
| 88 } | |
| 89 } | |
| 90 return iBestSimilar < 1 ? nullptr : pBestFont; | |
| 91 } | |
| 92 | |
| 93 } // namespace | |
| 94 | |
| 95 std::unique_ptr<CFGAS_FontMgr> CFGAS_FontMgr::Create( | |
| 96 FX_LPEnumAllFonts pEnumerator) { | |
| 97 return pdfium::MakeUnique<CFGAS_FontMgr>(pEnumerator); | |
| 98 } | |
| 99 | |
| 100 CFGAS_FontMgr::CFGAS_FontMgr(FX_LPEnumAllFonts pEnumerator) | |
| 26 : m_pEnumerator(pEnumerator), | 101 : m_pEnumerator(pEnumerator), |
| 27 m_FontFaces(100), | 102 m_FontFaces(100), |
| 28 m_CPFonts(8), | 103 m_CPFonts(8), |
| 29 m_FamilyFonts(16), | 104 m_FamilyFonts(16), |
| 30 m_UnicodeFonts(16), | 105 m_UnicodeFonts(16), |
| 31 m_BufferFonts(4), | 106 m_BufferFonts(4), |
| 32 m_StreamFonts(4), | 107 m_StreamFonts(4), |
| 33 m_DeriveFonts(4) { | 108 m_DeriveFonts(4) { |
| 34 if (m_pEnumerator) { | 109 if (m_pEnumerator) |
| 35 m_pEnumerator(m_FontFaces, nullptr, 0xFEFF); | 110 m_pEnumerator(m_FontFaces, nullptr, 0xFEFF); |
| 36 } | |
| 37 } | 111 } |
| 38 | 112 |
| 39 CFGAS_StdFontMgrImp::~CFGAS_StdFontMgrImp() { | 113 CFGAS_FontMgr::~CFGAS_FontMgr() { |
| 40 m_FontFaces.RemoveAll(false); | 114 m_FontFaces.RemoveAll(false); |
| 41 m_CPFonts.RemoveAll(); | 115 m_CPFonts.RemoveAll(); |
| 42 m_FamilyFonts.RemoveAll(); | 116 m_FamilyFonts.RemoveAll(); |
| 43 m_UnicodeFonts.RemoveAll(); | 117 m_UnicodeFonts.RemoveAll(); |
| 44 m_BufferFonts.RemoveAll(); | 118 m_BufferFonts.RemoveAll(); |
| 45 m_StreamFonts.RemoveAll(); | 119 m_StreamFonts.RemoveAll(); |
| 46 m_DeriveFonts.RemoveAll(); | 120 m_DeriveFonts.RemoveAll(); |
| 47 for (int32_t i = m_Fonts.GetUpperBound(); i >= 0; i--) | 121 for (int32_t i = m_Fonts.GetUpperBound(); i >= 0; i--) |
| 48 m_Fonts[i]->Release(); | 122 m_Fonts[i]->Release(); |
| 49 } | 123 } |
| 50 | 124 |
| 51 CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByCodePage( | 125 CFGAS_GEFont* CFGAS_FontMgr::GetDefFontByCodePage( |
| 52 uint16_t wCodePage, | 126 uint16_t wCodePage, |
| 53 uint32_t dwFontStyles, | 127 uint32_t dwFontStyles, |
| 54 const FX_WCHAR* pszFontFamily) { | 128 const FX_WCHAR* pszFontFamily) { |
| 55 uint32_t dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); | 129 uint32_t dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); |
| 56 CFGAS_GEFont* pFont = nullptr; | 130 CFGAS_GEFont* pFont = nullptr; |
| 57 if (m_CPFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { | 131 if (m_CPFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) |
| 58 return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : nullptr; | 132 return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : nullptr; |
| 59 } | |
| 60 FX_FONTDESCRIPTOR const* pFD = | 133 FX_FONTDESCRIPTOR const* pFD = |
| 61 FindFont(pszFontFamily, dwFontStyles, true, wCodePage); | 134 FindFont(pszFontFamily, dwFontStyles, true, wCodePage); |
| 62 if (!pFD) | 135 if (!pFD) |
| 63 pFD = FindFont(nullptr, dwFontStyles, true, wCodePage); | 136 pFD = FindFont(nullptr, dwFontStyles, true, wCodePage); |
| 64 if (!pFD) | 137 if (!pFD) |
| 65 pFD = FindFont(nullptr, dwFontStyles, false, wCodePage); | 138 pFD = FindFont(nullptr, dwFontStyles, false, wCodePage); |
| 66 if (!pFD) | 139 if (!pFD) |
| 67 return nullptr; | 140 return nullptr; |
| 68 | 141 |
| 69 pFont = | 142 pFont = |
| 70 CFGAS_GEFont::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); | 143 CFGAS_GEFont::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); |
| 71 if (pFont) { | 144 if (pFont) { |
| 72 m_Fonts.Add(pFont); | 145 m_Fonts.Add(pFont); |
| 73 m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 146 m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 74 dwHash = FGAS_GetFontFamilyHash(pFD->wsFontFace, dwFontStyles, wCodePage); | 147 dwHash = FGAS_GetFontFamilyHash(pFD->wsFontFace, dwFontStyles, wCodePage); |
| 75 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 148 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 76 return LoadFont(pFont, dwFontStyles, wCodePage); | 149 return LoadFont(pFont, dwFontStyles, wCodePage); |
| 77 } | 150 } |
| 78 return nullptr; | 151 return nullptr; |
| 79 } | 152 } |
| 80 | 153 |
| 81 CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByCharset( | 154 CFGAS_GEFont* CFGAS_FontMgr::GetDefFontByUnicode( |
| 82 uint8_t nCharset, | |
| 83 uint32_t dwFontStyles, | |
| 84 const FX_WCHAR* pszFontFamily) { | |
| 85 return GetDefFontByCodePage(FX_GetCodePageFromCharset(nCharset), dwFontStyles, | |
| 86 pszFontFamily); | |
| 87 } | |
| 88 | |
| 89 CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByUnicode( | |
| 90 FX_WCHAR wUnicode, | 155 FX_WCHAR wUnicode, |
| 91 uint32_t dwFontStyles, | 156 uint32_t dwFontStyles, |
| 92 const FX_WCHAR* pszFontFamily) { | 157 const FX_WCHAR* pszFontFamily) { |
| 93 const FGAS_FONTUSB* pRet = FGAS_GetUnicodeBitField(wUnicode); | 158 const FGAS_FONTUSB* pRet = FGAS_GetUnicodeBitField(wUnicode); |
| 94 if (pRet->wBitField == 999) | 159 if (pRet->wBitField == 999) |
| 95 return nullptr; | 160 return nullptr; |
| 96 | 161 |
| 97 uint32_t dwHash = | 162 uint32_t dwHash = |
| 98 FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, pRet->wBitField); | 163 FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, pRet->wBitField); |
| 99 CFGAS_GEFont* pFont = nullptr; | 164 CFGAS_GEFont* pFont = nullptr; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 118 m_UnicodeFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 183 m_UnicodeFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 119 dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); | 184 dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); |
| 120 m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 185 m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 121 dwHash = FGAS_GetFontFamilyHash(pFontFace, dwFontStyles, wCodePage); | 186 dwHash = FGAS_GetFontFamilyHash(pFontFace, dwFontStyles, wCodePage); |
| 122 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 187 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 123 return LoadFont(pFont, dwFontStyles, wCodePage); | 188 return LoadFont(pFont, dwFontStyles, wCodePage); |
| 124 } | 189 } |
| 125 return nullptr; | 190 return nullptr; |
| 126 } | 191 } |
| 127 | 192 |
| 128 CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByLanguage( | 193 CFGAS_GEFont* CFGAS_FontMgr::LoadFont(const FX_WCHAR* pszFontFamily, |
| 129 uint16_t wLanguage, | 194 uint32_t dwFontStyles, |
| 130 uint32_t dwFontStyles, | 195 uint16_t wCodePage) { |
| 131 const FX_WCHAR* pszFontFamily) { | |
| 132 return GetDefFontByCodePage(FX_GetDefCodePageByLanguage(wLanguage), | |
| 133 dwFontStyles, pszFontFamily); | |
| 134 } | |
| 135 | |
| 136 CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily, | |
| 137 uint32_t dwFontStyles, | |
| 138 uint16_t wCodePage) { | |
| 139 uint32_t dwHash = | 196 uint32_t dwHash = |
| 140 FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, wCodePage); | 197 FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, wCodePage); |
| 141 CFGAS_GEFont* pFont = nullptr; | 198 CFGAS_GEFont* pFont = nullptr; |
| 142 if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { | 199 if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) |
| 143 return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : nullptr; | 200 return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : nullptr; |
| 144 } | |
| 145 FX_FONTDESCRIPTOR const* pFD = | 201 FX_FONTDESCRIPTOR const* pFD = |
| 146 FindFont(pszFontFamily, dwFontStyles, true, wCodePage); | 202 FindFont(pszFontFamily, dwFontStyles, true, wCodePage); |
| 147 if (!pFD) | 203 if (!pFD) |
| 148 pFD = FindFont(pszFontFamily, dwFontStyles, false, wCodePage); | 204 pFD = FindFont(pszFontFamily, dwFontStyles, false, wCodePage); |
| 149 if (!pFD) | 205 if (!pFD) |
| 150 return nullptr; | 206 return nullptr; |
| 151 | 207 |
| 152 if (wCodePage == 0xFFFF) { | 208 if (wCodePage == 0xFFFF) |
| 153 wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet); | 209 wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet); |
| 154 } | |
| 155 pFont = | 210 pFont = |
| 156 CFGAS_GEFont::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); | 211 CFGAS_GEFont::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); |
| 157 if (pFont) { | 212 if (pFont) { |
| 158 m_Fonts.Add(pFont); | 213 m_Fonts.Add(pFont); |
| 159 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 214 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 160 dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); | 215 dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); |
| 161 m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 216 m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 162 return LoadFont(pFont, dwFontStyles, wCodePage); | 217 return LoadFont(pFont, dwFontStyles, wCodePage); |
| 163 } | 218 } |
| 164 return nullptr; | 219 return nullptr; |
| 165 } | 220 } |
| 166 | 221 |
| 167 CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(const uint8_t* pBuffer, | 222 CFGAS_GEFont* CFGAS_FontMgr::LoadFont(const uint8_t* pBuffer, int32_t iLength) { |
| 168 int32_t iLength) { | |
| 169 ASSERT(pBuffer && iLength > 0); | 223 ASSERT(pBuffer && iLength > 0); |
| 170 CFGAS_GEFont* pFont = nullptr; | 224 CFGAS_GEFont* pFont = nullptr; |
| 171 if (m_BufferFonts.Lookup((void*)pBuffer, (void*&)pFont)) { | 225 if (m_BufferFonts.Lookup((void*)pBuffer, (void*&)pFont)) { |
| 172 if (pFont) { | 226 if (pFont) |
| 173 return pFont->Retain(); | 227 return pFont->Retain(); |
| 174 } | |
| 175 } | 228 } |
| 176 pFont = CFGAS_GEFont::LoadFont(pBuffer, iLength, this); | 229 pFont = CFGAS_GEFont::LoadFont(pBuffer, iLength, this); |
| 177 if (pFont) { | 230 if (pFont) { |
| 178 m_Fonts.Add(pFont); | 231 m_Fonts.Add(pFont); |
| 179 m_BufferFonts.SetAt((void*)pBuffer, pFont); | 232 m_BufferFonts.SetAt((void*)pBuffer, pFont); |
| 180 return pFont->Retain(); | 233 return pFont->Retain(); |
| 181 } | 234 } |
| 182 return nullptr; | 235 return nullptr; |
| 183 } | 236 } |
| 184 | 237 |
| 185 CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream, | 238 CFGAS_GEFont* CFGAS_FontMgr::LoadFont(IFX_Stream* pFontStream, |
| 186 const FX_WCHAR* pszFontAlias, | 239 const FX_WCHAR* pszFontAlias, |
| 187 uint32_t dwFontStyles, | 240 uint32_t dwFontStyles, |
| 188 uint16_t wCodePage, | 241 uint16_t wCodePage, |
| 189 bool bSaveStream) { | 242 bool bSaveStream) { |
| 190 ASSERT(pFontStream && pFontStream->GetLength() > 0); | 243 ASSERT(pFontStream && pFontStream->GetLength() > 0); |
| 191 CFGAS_GEFont* pFont = nullptr; | 244 CFGAS_GEFont* pFont = nullptr; |
| 192 if (m_StreamFonts.Lookup((void*)pFontStream, (void*&)pFont)) { | 245 if (m_StreamFonts.Lookup((void*)pFontStream, (void*&)pFont)) { |
| 193 if (pFont) { | 246 if (pFont) { |
| 194 if (pszFontAlias) { | 247 if (pszFontAlias) { |
| 195 uint32_t dwHash = | 248 uint32_t dwHash = |
| 196 FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); | 249 FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); |
| 197 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 250 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 198 } | 251 } |
| 199 return LoadFont(pFont, dwFontStyles, wCodePage); | 252 return LoadFont(pFont, dwFontStyles, wCodePage); |
| 200 } | 253 } |
| 201 } | 254 } |
| 202 pFont = CFGAS_GEFont::LoadFont(pFontStream, this, bSaveStream); | 255 pFont = CFGAS_GEFont::LoadFont(pFontStream, this, bSaveStream); |
| 203 if (pFont) { | 256 if (pFont) { |
| 204 m_Fonts.Add(pFont); | 257 m_Fonts.Add(pFont); |
| 205 m_StreamFonts.SetAt((void*)pFontStream, (void*)pFont); | 258 m_StreamFonts.SetAt((void*)pFontStream, (void*)pFont); |
| 206 if (pszFontAlias) { | 259 if (pszFontAlias) { |
| 207 uint32_t dwHash = | 260 uint32_t dwHash = |
| 208 FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); | 261 FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); |
| 209 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 262 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 210 } | 263 } |
| 211 return LoadFont(pFont, dwFontStyles, wCodePage); | 264 return LoadFont(pFont, dwFontStyles, wCodePage); |
| 212 } | 265 } |
| 213 return nullptr; | 266 return nullptr; |
| 214 } | 267 } |
| 215 | 268 |
| 216 CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(CFGAS_GEFont* pSrcFont, | 269 CFGAS_GEFont* CFGAS_FontMgr::LoadFont(CFGAS_GEFont* pSrcFont, |
| 217 uint32_t dwFontStyles, | 270 uint32_t dwFontStyles, |
| 218 uint16_t wCodePage) { | 271 uint16_t wCodePage) { |
| 219 ASSERT(pSrcFont); | 272 ASSERT(pSrcFont); |
| 220 if (pSrcFont->GetFontStyles() == dwFontStyles) { | 273 if (pSrcFont->GetFontStyles() == dwFontStyles) |
| 221 return pSrcFont->Retain(); | 274 return pSrcFont->Retain(); |
| 222 } | |
| 223 void* buffer[3] = {pSrcFont, (void*)(uintptr_t)dwFontStyles, | 275 void* buffer[3] = {pSrcFont, (void*)(uintptr_t)dwFontStyles, |
| 224 (void*)(uintptr_t)wCodePage}; | 276 (void*)(uintptr_t)wCodePage}; |
| 225 uint32_t dwHash = FX_HashCode_GetA( | 277 uint32_t dwHash = FX_HashCode_GetA( |
| 226 CFX_ByteStringC((uint8_t*)buffer, sizeof(buffer)), false); | 278 CFX_ByteStringC((uint8_t*)buffer, sizeof(buffer)), false); |
| 227 CFGAS_GEFont* pFont = nullptr; | 279 CFGAS_GEFont* pFont = nullptr; |
| 228 if (m_DeriveFonts.GetCount() > 0) { | 280 if (m_DeriveFonts.GetCount() > 0) { |
| 229 m_DeriveFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont); | 281 m_DeriveFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont); |
| 230 if (pFont) { | 282 if (pFont) |
| 231 return pFont->Retain(); | 283 return pFont->Retain(); |
| 232 } | |
| 233 } | 284 } |
| 234 pFont = pSrcFont->Derive(dwFontStyles, wCodePage); | 285 pFont = pSrcFont->Derive(dwFontStyles, wCodePage); |
| 235 if (pFont) { | 286 if (pFont) { |
| 236 m_DeriveFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 287 m_DeriveFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 237 int32_t index = m_Fonts.Find(pFont); | 288 int32_t index = m_Fonts.Find(pFont); |
| 238 if (index < 0) { | 289 if (index < 0) { |
| 239 m_Fonts.Add(pFont); | 290 m_Fonts.Add(pFont); |
| 240 pFont->Retain(); | 291 pFont->Retain(); |
| 241 } | 292 } |
| 242 return pFont; | 293 return pFont; |
| 243 } | 294 } |
| 244 return nullptr; | 295 return nullptr; |
| 245 } | 296 } |
| 246 | 297 |
| 247 void CFGAS_StdFontMgrImp::ClearFontCache() { | 298 void CFGAS_FontMgr::ClearFontCache() { |
| 248 for (int32_t i = 0; i < m_Fonts.GetSize(); i++) | 299 for (int32_t i = 0; i < m_Fonts.GetSize(); i++) |
| 249 m_Fonts[i]->Reset(); | 300 m_Fonts[i]->Reset(); |
| 250 } | 301 } |
| 251 | 302 |
| 252 void CFGAS_StdFontMgrImp::RemoveFont(CFX_MapPtrToPtr& fontMap, | 303 void CFGAS_FontMgr::RemoveFont(CFX_MapPtrToPtr& fontMap, CFGAS_GEFont* pFont) { |
| 253 CFGAS_GEFont* pFont) { | |
| 254 FX_POSITION pos = fontMap.GetStartPosition(); | 304 FX_POSITION pos = fontMap.GetStartPosition(); |
| 255 void* pKey; | 305 void* pKey; |
| 256 void* pFind; | 306 void* pFind; |
| 257 while (pos) { | 307 while (pos) { |
| 258 pFind = nullptr; | 308 pFind = nullptr; |
| 259 fontMap.GetNextAssoc(pos, pKey, pFind); | 309 fontMap.GetNextAssoc(pos, pKey, pFind); |
| 260 if (pFind != (void*)pFont) { | 310 if (pFind != (void*)pFont) |
| 261 continue; | 311 continue; |
| 262 } | |
| 263 fontMap.RemoveKey(pKey); | 312 fontMap.RemoveKey(pKey); |
| 264 break; | 313 break; |
| 265 } | 314 } |
| 266 } | 315 } |
| 267 | 316 |
| 268 void CFGAS_StdFontMgrImp::RemoveFont(CFGAS_GEFont* pFont) { | 317 void CFGAS_FontMgr::RemoveFont(CFGAS_GEFont* pFont) { |
| 269 RemoveFont(m_CPFonts, pFont); | 318 RemoveFont(m_CPFonts, pFont); |
| 270 RemoveFont(m_FamilyFonts, pFont); | 319 RemoveFont(m_FamilyFonts, pFont); |
| 271 RemoveFont(m_UnicodeFonts, pFont); | 320 RemoveFont(m_UnicodeFonts, pFont); |
| 272 RemoveFont(m_BufferFonts, pFont); | 321 RemoveFont(m_BufferFonts, pFont); |
| 273 RemoveFont(m_StreamFonts, pFont); | 322 RemoveFont(m_StreamFonts, pFont); |
| 274 RemoveFont(m_DeriveFonts, pFont); | 323 RemoveFont(m_DeriveFonts, pFont); |
| 275 int32_t iFind = m_Fonts.Find(pFont); | 324 int32_t iFind = m_Fonts.Find(pFont); |
| 276 if (iFind > -1) { | 325 if (iFind > -1) |
| 277 m_Fonts.RemoveAt(iFind, 1); | 326 m_Fonts.RemoveAt(iFind, 1); |
| 278 } | |
| 279 } | 327 } |
| 280 | 328 |
| 281 FX_FONTDESCRIPTOR const* CFGAS_StdFontMgrImp::FindFont( | 329 FX_FONTDESCRIPTOR const* CFGAS_FontMgr::FindFont(const FX_WCHAR* pszFontFamily, |
| 282 const FX_WCHAR* pszFontFamily, | 330 uint32_t dwFontStyles, |
| 283 uint32_t dwFontStyles, | 331 uint32_t dwMatchFlags, |
| 284 uint32_t dwMatchFlags, | 332 uint16_t wCodePage, |
| 285 uint16_t wCodePage, | 333 uint32_t dwUSB, |
| 286 uint32_t dwUSB, | 334 FX_WCHAR wUnicode) { |
| 287 FX_WCHAR wUnicode) { | |
| 288 FX_FONTMATCHPARAMS params; | 335 FX_FONTMATCHPARAMS params; |
| 289 FXSYS_memset(¶ms, 0, sizeof(params)); | 336 FXSYS_memset(¶ms, 0, sizeof(params)); |
| 290 params.dwUSB = dwUSB; | 337 params.dwUSB = dwUSB; |
| 291 params.wUnicode = wUnicode; | 338 params.wUnicode = wUnicode; |
| 292 params.wCodePage = wCodePage; | 339 params.wCodePage = wCodePage; |
| 293 params.pwsFamily = pszFontFamily; | 340 params.pwsFamily = pszFontFamily; |
| 294 params.dwFontStyles = dwFontStyles; | 341 params.dwFontStyles = dwFontStyles; |
| 295 params.dwMatchFlags = dwMatchFlags; | 342 params.dwMatchFlags = dwMatchFlags; |
| 296 FX_FONTDESCRIPTOR const* pDesc = FX_DefFontMatcher(¶ms, m_FontFaces); | 343 FX_FONTDESCRIPTOR const* pDesc = FX_DefFontMatcher(¶ms, m_FontFaces); |
| 297 if (pDesc) { | 344 if (pDesc) |
| 298 return pDesc; | 345 return pDesc; |
| 299 } | |
| 300 if (pszFontFamily && m_pEnumerator) { | 346 if (pszFontFamily && m_pEnumerator) { |
| 301 CFX_FontDescriptors namedFonts(100); | 347 CFX_FontDescriptors namedFonts(100); |
| 302 m_pEnumerator(namedFonts, pszFontFamily, wUnicode); | 348 m_pEnumerator(namedFonts, pszFontFamily, wUnicode); |
| 303 params.pwsFamily = nullptr; | 349 params.pwsFamily = nullptr; |
| 304 pDesc = FX_DefFontMatcher(¶ms, namedFonts); | 350 pDesc = FX_DefFontMatcher(¶ms, namedFonts); |
| 305 if (!pDesc) { | 351 if (!pDesc) |
| 306 return nullptr; | 352 return nullptr; |
| 307 } | |
| 308 for (int32_t i = m_FontFaces.GetSize() - 1; i >= 0; i--) { | 353 for (int32_t i = m_FontFaces.GetSize() - 1; i >= 0; i--) { |
| 309 FX_FONTDESCRIPTOR const* pMatch = m_FontFaces.GetPtrAt(i); | 354 FX_FONTDESCRIPTOR const* pMatch = m_FontFaces.GetPtrAt(i); |
| 310 if (*pMatch == *pDesc) { | 355 if (*pMatch == *pDesc) |
| 311 return pMatch; | 356 return pMatch; |
| 312 } | |
| 313 } | 357 } |
| 314 int index = m_FontFaces.Add(*pDesc); | 358 int index = m_FontFaces.Add(*pDesc); |
| 315 return m_FontFaces.GetPtrAt(index); | 359 return m_FontFaces.GetPtrAt(index); |
| 316 } | 360 } |
| 317 return nullptr; | 361 return nullptr; |
| 318 } | 362 } |
| 319 | 363 |
| 320 FX_FONTDESCRIPTOR const* FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams, | |
| 321 const CFX_FontDescriptors& fonts) { | |
| 322 FX_FONTDESCRIPTOR const* pBestFont = nullptr; | |
| 323 int32_t iBestSimilar = 0; | |
| 324 bool bMatchStyle = (pParams->dwMatchFlags & FX_FONTMATCHPARA_MacthStyle) > 0; | |
| 325 int32_t iCount = fonts.GetSize(); | |
| 326 for (int32_t i = 0; i < iCount; ++i) { | |
| 327 FX_FONTDESCRIPTOR const* pFont = fonts.GetPtrAt(i); | |
| 328 if ((pFont->dwFontStyles & FX_FONTSTYLE_BoldItalic) == | |
| 329 FX_FONTSTYLE_BoldItalic) { | |
| 330 continue; | |
| 331 } | |
| 332 if (pParams->pwsFamily) { | |
| 333 if (FXSYS_wcsicmp(pParams->pwsFamily, pFont->wsFontFace)) { | |
| 334 continue; | |
| 335 } | |
| 336 if (pFont->uCharSet == FX_CHARSET_Symbol) { | |
| 337 return pFont; | |
| 338 } | |
| 339 } | |
| 340 if (pFont->uCharSet == FX_CHARSET_Symbol) { | |
| 341 continue; | |
| 342 } | |
| 343 if (pParams->wCodePage != 0xFFFF) { | |
| 344 if (FX_GetCodePageFromCharset(pFont->uCharSet) != pParams->wCodePage) { | |
| 345 continue; | |
| 346 } | |
| 347 } else { | |
| 348 if (pParams->dwUSB < 128) { | |
| 349 uint32_t dwByte = pParams->dwUSB / 32; | |
| 350 uint32_t dwUSB = 1 << (pParams->dwUSB % 32); | |
| 351 if ((pFont->FontSignature.fsUsb[dwByte] & dwUSB) == 0) { | |
| 352 continue; | |
| 353 } | |
| 354 } | |
| 355 } | |
| 356 if (bMatchStyle) { | |
| 357 if ((pFont->dwFontStyles & 0x0F) == (pParams->dwFontStyles & 0x0F)) | |
| 358 return pFont; | |
| 359 continue; | |
| 360 } | |
| 361 if (pParams->pwsFamily) { | |
| 362 if (FXSYS_wcsicmp(pParams->pwsFamily, pFont->wsFontFace) == 0) { | |
| 363 return pFont; | |
| 364 } | |
| 365 } | |
| 366 int32_t iSimilarValue = FX_GetSimilarValue(pFont, pParams->dwFontStyles); | |
| 367 if (iBestSimilar < iSimilarValue) { | |
| 368 iBestSimilar = iSimilarValue; | |
| 369 pBestFont = pFont; | |
| 370 } | |
| 371 } | |
| 372 return iBestSimilar < 1 ? nullptr : pBestFont; | |
| 373 } | |
| 374 | |
| 375 int32_t FX_GetSimilarValue(FX_FONTDESCRIPTOR const* pFont, | |
| 376 uint32_t dwFontStyles) { | |
| 377 int32_t iValue = 0; | |
| 378 if ((dwFontStyles & FX_FONTSTYLE_Symbolic) == | |
| 379 (pFont->dwFontStyles & FX_FONTSTYLE_Symbolic)) { | |
| 380 iValue += 64; | |
| 381 } | |
| 382 if ((dwFontStyles & FX_FONTSTYLE_FixedPitch) == | |
| 383 (pFont->dwFontStyles & FX_FONTSTYLE_FixedPitch)) { | |
| 384 iValue += 32; | |
| 385 } | |
| 386 if ((dwFontStyles & FX_FONTSTYLE_Serif) == | |
| 387 (pFont->dwFontStyles & FX_FONTSTYLE_Serif)) { | |
| 388 iValue += 16; | |
| 389 } | |
| 390 if ((dwFontStyles & FX_FONTSTYLE_Script) == | |
| 391 (pFont->dwFontStyles & FX_FONTSTYLE_Script)) { | |
| 392 iValue += 8; | |
| 393 } | |
| 394 return iValue; | |
| 395 } | |
| 396 | |
| 397 FX_LPMatchFont FX_GetDefFontMatchor() { | |
| 398 return FX_DefFontMatcher; | |
| 399 } | |
| 400 | |
| 401 uint32_t FX_GetGdiFontStyles(const LOGFONTW& lf) { | 364 uint32_t FX_GetGdiFontStyles(const LOGFONTW& lf) { |
| 402 uint32_t dwStyles = 0; | 365 uint32_t dwStyles = 0; |
| 403 if ((lf.lfPitchAndFamily & 0x03) == FIXED_PITCH) { | 366 if ((lf.lfPitchAndFamily & 0x03) == FIXED_PITCH) |
| 404 dwStyles |= FX_FONTSTYLE_FixedPitch; | 367 dwStyles |= FX_FONTSTYLE_FixedPitch; |
| 405 } | |
| 406 uint8_t nFamilies = lf.lfPitchAndFamily & 0xF0; | 368 uint8_t nFamilies = lf.lfPitchAndFamily & 0xF0; |
| 407 if (nFamilies == FF_ROMAN) { | 369 if (nFamilies == FF_ROMAN) |
| 408 dwStyles |= FX_FONTSTYLE_Serif; | 370 dwStyles |= FX_FONTSTYLE_Serif; |
| 409 } | 371 if (nFamilies == FF_SCRIPT) |
| 410 if (nFamilies == FF_SCRIPT) { | |
| 411 dwStyles |= FX_FONTSTYLE_Script; | 372 dwStyles |= FX_FONTSTYLE_Script; |
| 412 } | 373 if (lf.lfCharSet == SYMBOL_CHARSET) |
| 413 if (lf.lfCharSet == SYMBOL_CHARSET) { | |
| 414 dwStyles |= FX_FONTSTYLE_Symbolic; | 374 dwStyles |= FX_FONTSTYLE_Symbolic; |
| 415 } | |
| 416 return dwStyles; | 375 return dwStyles; |
| 417 } | 376 } |
| 418 | 377 |
| 419 static int32_t CALLBACK FX_GdiFontEnumProc(ENUMLOGFONTEX* lpelfe, | 378 static int32_t CALLBACK FX_GdiFontEnumProc(ENUMLOGFONTEX* lpelfe, |
| 420 NEWTEXTMETRICEX* lpntme, | 379 NEWTEXTMETRICEX* lpntme, |
| 421 DWORD dwFontType, | 380 DWORD dwFontType, |
| 422 LPARAM lParam) { | 381 LPARAM lParam) { |
| 423 if (dwFontType != TRUETYPE_FONTTYPE) { | 382 if (dwFontType != TRUETYPE_FONTTYPE) |
| 424 return 1; | 383 return 1; |
| 425 } | |
| 426 const LOGFONTW& lf = ((LPENUMLOGFONTEXW)lpelfe)->elfLogFont; | 384 const LOGFONTW& lf = ((LPENUMLOGFONTEXW)lpelfe)->elfLogFont; |
| 427 if (lf.lfFaceName[0] == L'@') { | 385 if (lf.lfFaceName[0] == L'@') |
| 428 return 1; | 386 return 1; |
| 429 } | |
| 430 FX_FONTDESCRIPTOR* pFont = FX_Alloc(FX_FONTDESCRIPTOR, 1); | 387 FX_FONTDESCRIPTOR* pFont = FX_Alloc(FX_FONTDESCRIPTOR, 1); |
| 431 FXSYS_memset(pFont, 0, sizeof(FX_FONTDESCRIPTOR)); | 388 FXSYS_memset(pFont, 0, sizeof(FX_FONTDESCRIPTOR)); |
| 432 pFont->uCharSet = lf.lfCharSet; | 389 pFont->uCharSet = lf.lfCharSet; |
| 433 pFont->dwFontStyles = FX_GetGdiFontStyles(lf); | 390 pFont->dwFontStyles = FX_GetGdiFontStyles(lf); |
| 434 FXSYS_wcsncpy(pFont->wsFontFace, (const FX_WCHAR*)lf.lfFaceName, 31); | 391 FXSYS_wcsncpy(pFont->wsFontFace, (const FX_WCHAR*)lf.lfFaceName, 31); |
| 435 pFont->wsFontFace[31] = 0; | 392 pFont->wsFontFace[31] = 0; |
| 436 FXSYS_memcpy(&pFont->FontSignature, &lpntme->ntmFontSig, | 393 FXSYS_memcpy(&pFont->FontSignature, &lpntme->ntmFontSig, |
| 437 sizeof(lpntme->ntmFontSig)); | 394 sizeof(lpntme->ntmFontSig)); |
| 438 ((CFX_FontDescriptors*)lParam)->Add(*pFont); | 395 ((CFX_FontDescriptors*)lParam)->Add(*pFont); |
| 439 FX_Free(pFont); | 396 FX_Free(pFont); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 453 } | 410 } |
| 454 EnumFontFamiliesExW(hDC, (LPLOGFONTW)&lfFind, | 411 EnumFontFamiliesExW(hDC, (LPLOGFONTW)&lfFind, |
| 455 (FONTENUMPROCW)FX_GdiFontEnumProc, (LPARAM)&fonts, 0); | 412 (FONTENUMPROCW)FX_GdiFontEnumProc, (LPARAM)&fonts, 0); |
| 456 ::ReleaseDC(nullptr, hDC); | 413 ::ReleaseDC(nullptr, hDC); |
| 457 } | 414 } |
| 458 | 415 |
| 459 FX_LPEnumAllFonts FX_GetDefFontEnumerator() { | 416 FX_LPEnumAllFonts FX_GetDefFontEnumerator() { |
| 460 return FX_EnumGdiFonts; | 417 return FX_EnumGdiFonts; |
| 461 } | 418 } |
| 462 | 419 |
| 463 #else | 420 #else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 421 | |
| 422 namespace { | |
| 423 | |
| 464 const FX_CHAR* g_FontFolders[] = { | 424 const FX_CHAR* g_FontFolders[] = { |
| 465 #if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ | 425 #if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ |
| 466 "/usr/share/fonts", "/usr/share/X11/fonts/Type1", | 426 "/usr/share/fonts", "/usr/share/X11/fonts/Type1", |
| 467 "/usr/share/X11/fonts/TTF", "/usr/local/share/fonts", | 427 "/usr/share/X11/fonts/TTF", "/usr/local/share/fonts", |
| 468 #elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 428 #elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 469 "~/Library/Fonts", "/Library/Fonts", "/System/Library/Fonts", | 429 "~/Library/Fonts", "/Library/Fonts", "/System/Library/Fonts", |
| 470 #elif _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ | 430 #elif _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ |
| 471 "/system/fonts", | 431 "/system/fonts", |
| 472 #endif | 432 #endif |
| 473 }; | 433 }; |
| 474 | 434 |
| 435 struct FX_BitCodePage { | |
| 436 uint16_t wBit; | |
| 437 uint16_t wCodePage; | |
| 438 }; | |
| 439 | |
| 440 static const FX_BitCodePage g_Bit2CodePage[] = { | |
|
Tom Sepez
2016/11/11 18:43:16
nit: static inside namespace redundant.
npm
2016/11/11 19:24:46
Done.
| |
| 441 {0, 1252}, {1, 1250}, {2, 1251}, {3, 1253}, {4, 1254}, {5, 1255}, | |
| 442 {6, 1256}, {7, 1257}, {8, 1258}, {9, 0}, {10, 0}, {11, 0}, | |
| 443 {12, 0}, {13, 0}, {14, 0}, {15, 0}, {16, 874}, {17, 932}, | |
| 444 {18, 936}, {19, 949}, {20, 950}, {21, 1361}, {22, 0}, {23, 0}, | |
| 445 {24, 0}, {25, 0}, {26, 0}, {27, 0}, {28, 0}, {29, 0}, | |
| 446 {30, 0}, {31, 0}, {32, 0}, {33, 0}, {34, 0}, {35, 0}, | |
| 447 {36, 0}, {37, 0}, {38, 0}, {39, 0}, {40, 0}, {41, 0}, | |
| 448 {42, 0}, {43, 0}, {44, 0}, {45, 0}, {46, 0}, {47, 0}, | |
| 449 {48, 869}, {49, 866}, {50, 865}, {51, 864}, {52, 863}, {53, 862}, | |
| 450 {54, 861}, {55, 860}, {56, 857}, {57, 855}, {58, 852}, {59, 775}, | |
| 451 {60, 737}, {61, 708}, {62, 850}, {63, 437}, | |
| 452 }; | |
| 453 | |
| 454 uint16_t FX_GetCodePageBit(uint16_t wCodePage) { | |
| 455 for (size_t i = 0; i < FX_ArraySize(g_Bit2CodePage); ++i) { | |
| 456 if (g_Bit2CodePage[i].wCodePage == wCodePage) | |
| 457 return g_Bit2CodePage[i].wBit; | |
| 458 } | |
| 459 return (uint16_t)-1; | |
| 460 } | |
| 461 | |
| 462 uint16_t FX_GetUnicodeBit(FX_WCHAR wcUnicode) { | |
| 463 const FGAS_FONTUSB* x = FGAS_GetUnicodeBitField(wcUnicode); | |
| 464 return x ? x->wBitField : 999; | |
| 465 } | |
| 466 | |
| 467 inline uint8_t GetUInt8(uint8_t* p) { | |
|
Tom Sepez
2016/11/11 18:43:16
nit: const uint8_t* p here and below.
npm
2016/11/11 19:24:46
Done.
| |
| 468 return (uint8_t)(p[0]); | |
| 469 } | |
| 470 inline uint16_t GetUInt16(uint8_t* p) { | |
| 471 return (uint16_t)(p[0] << 8 | p[1]); | |
| 472 } | |
| 473 | |
| 474 struct FX_BIT2CHARSET { | |
| 475 uint16_t wBit; | |
| 476 uint16_t wCharset; | |
| 477 }; | |
| 478 | |
| 479 FX_BIT2CHARSET g_FX_Bit2Charset1[16] = { | |
|
Tom Sepez
2016/11/11 18:43:15
nit: can these be const FX_BIT2CHARSET ... ?
npm
2016/11/11 19:24:46
Done.
| |
| 480 {1 << 0, FX_CHARSET_ANSI}, | |
| 481 {1 << 1, FX_CHARSET_MSWin_EasterEuropean}, | |
| 482 {1 << 2, FX_CHARSET_MSWin_Cyrillic}, | |
| 483 {1 << 3, FX_CHARSET_MSWin_Greek}, | |
| 484 {1 << 4, FX_CHARSET_MSWin_Turkish}, | |
| 485 {1 << 5, FX_CHARSET_MSWin_Hebrew}, | |
| 486 {1 << 6, FX_CHARSET_MSWin_Arabic}, | |
| 487 {1 << 7, FX_CHARSET_MSWin_Baltic}, | |
| 488 {1 << 8, FX_CHARSET_MSWin_Vietnamese}, | |
| 489 {1 << 9, FX_CHARSET_Default}, | |
| 490 {1 << 10, FX_CHARSET_Default}, | |
| 491 {1 << 11, FX_CHARSET_Default}, | |
| 492 {1 << 12, FX_CHARSET_Default}, | |
| 493 {1 << 13, FX_CHARSET_Default}, | |
| 494 {1 << 14, FX_CHARSET_Default}, | |
| 495 {1 << 15, FX_CHARSET_Default}, | |
| 496 }; | |
| 497 | |
| 498 FX_BIT2CHARSET g_FX_Bit2Charset2[16] = { | |
| 499 {1 << 0, FX_CHARSET_Thai}, | |
| 500 {1 << 1, FX_CHARSET_ShiftJIS}, | |
| 501 {1 << 2, FX_CHARSET_ChineseSimplified}, | |
| 502 {1 << 3, FX_CHARSET_Korean}, | |
| 503 {1 << 4, FX_CHARSET_ChineseTriditional}, | |
| 504 {1 << 5, FX_CHARSET_Johab}, | |
| 505 {1 << 6, FX_CHARSET_Default}, | |
| 506 {1 << 7, FX_CHARSET_Default}, | |
| 507 {1 << 8, FX_CHARSET_Default}, | |
| 508 {1 << 9, FX_CHARSET_Default}, | |
| 509 {1 << 10, FX_CHARSET_Default}, | |
| 510 {1 << 11, FX_CHARSET_Default}, | |
| 511 {1 << 12, FX_CHARSET_Default}, | |
| 512 {1 << 13, FX_CHARSET_Default}, | |
| 513 {1 << 14, FX_CHARSET_OEM}, | |
| 514 {1 << 15, FX_CHARSET_Symbol}, | |
| 515 }; | |
| 516 | |
| 517 FX_BIT2CHARSET g_FX_Bit2Charset3[16] = { | |
| 518 {1 << 0, FX_CHARSET_Default}, {1 << 1, FX_CHARSET_Default}, | |
| 519 {1 << 2, FX_CHARSET_Default}, {1 << 3, FX_CHARSET_Default}, | |
| 520 {1 << 4, FX_CHARSET_Default}, {1 << 5, FX_CHARSET_Default}, | |
| 521 {1 << 6, FX_CHARSET_Default}, {1 << 7, FX_CHARSET_Default}, | |
| 522 {1 << 8, FX_CHARSET_Default}, {1 << 9, FX_CHARSET_Default}, | |
| 523 {1 << 10, FX_CHARSET_Default}, {1 << 11, FX_CHARSET_Default}, | |
| 524 {1 << 12, FX_CHARSET_Default}, {1 << 13, FX_CHARSET_Default}, | |
| 525 {1 << 14, FX_CHARSET_Default}, {1 << 15, FX_CHARSET_Default}, | |
| 526 }; | |
| 527 | |
| 528 FX_BIT2CHARSET g_FX_Bit2Charset4[16] = { | |
| 529 {1 << 0, FX_CHARSET_Default}, {1 << 1, FX_CHARSET_Default}, | |
| 530 {1 << 2, FX_CHARSET_Default}, {1 << 3, FX_CHARSET_Default}, | |
| 531 {1 << 4, FX_CHARSET_Default}, {1 << 5, FX_CHARSET_Default}, | |
| 532 {1 << 6, FX_CHARSET_Default}, {1 << 7, FX_CHARSET_Default}, | |
| 533 {1 << 8, FX_CHARSET_Default}, {1 << 9, FX_CHARSET_Default}, | |
| 534 {1 << 10, FX_CHARSET_Default}, {1 << 11, FX_CHARSET_Default}, | |
| 535 {1 << 12, FX_CHARSET_Default}, {1 << 13, FX_CHARSET_Default}, | |
| 536 {1 << 14, FX_CHARSET_Default}, {1 << 15, FX_CHARSET_US}, | |
| 537 }; | |
| 538 | |
| 539 } // namespace | |
| 540 | |
| 475 CFX_FontDescriptor::CFX_FontDescriptor() | 541 CFX_FontDescriptor::CFX_FontDescriptor() |
| 476 : m_nFaceIndex(0), m_dwFontStyles(0), m_dwUsb(), m_dwCsb() {} | 542 : m_nFaceIndex(0), m_dwFontStyles(0), m_dwUsb(), m_dwCsb() {} |
| 477 | 543 |
| 478 CFX_FontDescriptor::~CFX_FontDescriptor() {} | 544 CFX_FontDescriptor::~CFX_FontDescriptor() {} |
| 479 | 545 |
| 480 CFX_FontSourceEnum_File::CFX_FontSourceEnum_File() { | 546 CFX_FontSourceEnum_File::CFX_FontSourceEnum_File() { |
| 481 for (size_t i = 0; i < FX_ArraySize(g_FontFolders); ++i) | 547 for (size_t i = 0; i < FX_ArraySize(g_FontFolders); ++i) |
| 482 m_FolderPaths.Add(g_FontFolders[i]); | 548 m_FolderPaths.Add(g_FontFolders[i]); |
| 483 } | 549 } |
| 484 | 550 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 532 bsName = | 598 bsName = |
| 533 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + | 599 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + |
| 534 bsFolderSpearator + bsName; | 600 bsFolderSpearator + bsName; |
| 535 break; | 601 break; |
| 536 } | 602 } |
| 537 return bsName; | 603 return bsName; |
| 538 } | 604 } |
| 539 | 605 |
| 540 FX_POSITION CFX_FontSourceEnum_File::GetStartPosition() { | 606 FX_POSITION CFX_FontSourceEnum_File::GetStartPosition() { |
| 541 m_wsNext = GetNextFile().UTF8Decode(); | 607 m_wsNext = GetNextFile().UTF8Decode(); |
| 542 if (m_wsNext.GetLength() == 0) { | 608 if (m_wsNext.GetLength() == 0) |
| 543 return (FX_POSITION)0; | 609 return (FX_POSITION)0; |
| 544 } | |
| 545 return (FX_POSITION)-1; | 610 return (FX_POSITION)-1; |
| 546 } | 611 } |
| 547 | 612 |
| 548 IFX_FileAccess* CFX_FontSourceEnum_File::GetNext(FX_POSITION& pos) { | 613 IFX_FileAccess* CFX_FontSourceEnum_File::GetNext(FX_POSITION& pos) { |
| 549 IFX_FileAccess* pAccess = FX_CreateDefaultFileAccess(m_wsNext.AsStringC()); | 614 IFX_FileAccess* pAccess = FX_CreateDefaultFileAccess(m_wsNext.AsStringC()); |
| 550 m_wsNext = GetNextFile().UTF8Decode(); | 615 m_wsNext = GetNextFile().UTF8Decode(); |
| 551 pos = m_wsNext.GetLength() != 0 ? pAccess : nullptr; | 616 pos = m_wsNext.GetLength() != 0 ? pAccess : nullptr; |
| 552 return pAccess; | 617 return pAccess; |
| 553 } | 618 } |
| 554 | 619 |
| 555 std::unique_ptr<IFGAS_FontMgr> IFGAS_FontMgr::Create( | 620 std::unique_ptr<CFGAS_FontMgr> CFGAS_FontMgr::Create( |
| 556 CFX_FontSourceEnum_File* pFontEnum) { | 621 CFX_FontSourceEnum_File* pFontEnum) { |
| 557 if (!pFontEnum) | 622 if (!pFontEnum) |
| 558 return nullptr; | 623 return nullptr; |
| 559 | 624 |
| 560 std::unique_ptr<CFGAS_FontMgrImp> pFontMgr(new CFGAS_FontMgrImp(pFontEnum)); | 625 auto pFontMgr = pdfium::MakeUnique<CFGAS_FontMgr>(pFontEnum); |
| 561 if (!pFontMgr->EnumFonts()) | 626 if (!pFontMgr->EnumFonts()) |
| 562 return nullptr; | 627 return nullptr; |
| 563 return std::move(pFontMgr); | 628 return pFontMgr; |
|
npm
2016/11/11 00:20:39
Removed std::move here because compiler got mad
Tom Sepez
2016/11/11 18:43:15
That's correct to remove it, if its just a variabl
| |
| 564 } | 629 } |
| 565 | 630 |
| 566 CFGAS_FontMgrImp::CFGAS_FontMgrImp(CFX_FontSourceEnum_File* pFontEnum) | 631 CFGAS_FontMgr::CFGAS_FontMgr(CFX_FontSourceEnum_File* pFontEnum) |
| 567 : m_pFontSource(pFontEnum) {} | 632 : m_pFontSource(pFontEnum) {} |
| 568 | 633 |
| 569 CFGAS_FontMgrImp::~CFGAS_FontMgrImp() { | 634 CFGAS_FontMgr::~CFGAS_FontMgr() { |
| 570 for (int32_t i = 0; i < m_InstalledFonts.GetSize(); i++) { | 635 for (int32_t i = 0; i < m_InstalledFonts.GetSize(); i++) |
| 571 delete m_InstalledFonts[i]; | 636 delete m_InstalledFonts[i]; |
| 572 } | |
| 573 FX_POSITION pos = m_Hash2CandidateList.GetStartPosition(); | 637 FX_POSITION pos = m_Hash2CandidateList.GetStartPosition(); |
| 574 while (pos) { | 638 while (pos) { |
| 575 uint32_t dwHash; | 639 uint32_t dwHash; |
| 576 CFX_FontDescriptorInfos* pDescs; | 640 CFX_FontDescriptorInfos* pDescs; |
| 577 m_Hash2CandidateList.GetNextAssoc(pos, dwHash, pDescs); | 641 m_Hash2CandidateList.GetNextAssoc(pos, dwHash, pDescs); |
| 578 delete pDescs; | 642 delete pDescs; |
| 579 } | 643 } |
| 580 pos = m_Hash2Fonts.GetStartPosition(); | 644 pos = m_Hash2Fonts.GetStartPosition(); |
| 581 while (pos) { | 645 while (pos) { |
| 582 uint32_t dwHash; | 646 uint32_t dwHash; |
| 583 CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts; | 647 CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts; |
| 584 m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); | 648 m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); |
| 585 for (int32_t i = 0; i < pFonts->GetSize(); i++) | 649 for (int32_t i = 0; i < pFonts->GetSize(); i++) |
| 586 delete pFonts->GetAt(i); | 650 delete pFonts->GetAt(i); |
| 587 delete pFonts; | 651 delete pFonts; |
| 588 } | 652 } |
| 589 m_Hash2Fonts.RemoveAll(); | 653 m_Hash2Fonts.RemoveAll(); |
| 590 pos = m_IFXFont2FileRead.GetStartPosition(); | 654 pos = m_IFXFont2FileRead.GetStartPosition(); |
| 591 while (pos) { | 655 while (pos) { |
| 592 CFGAS_GEFont* pFont; | 656 CFGAS_GEFont* pFont; |
| 593 IFX_SeekableReadStream* pFileRead; | 657 IFX_SeekableReadStream* pFileRead; |
| 594 m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead); | 658 m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead); |
| 595 pFileRead->Release(); | 659 pFileRead->Release(); |
| 596 } | 660 } |
| 597 } | 661 } |
| 598 | 662 |
| 599 bool CFGAS_FontMgrImp::EnumFontsFromFontMapper() { | 663 bool CFGAS_FontMgr::EnumFontsFromFontMapper() { |
| 600 CFX_FontMapper* pFontMapper = | 664 CFX_FontMapper* pFontMapper = |
| 601 CFX_GEModule::Get()->GetFontMgr()->GetBuiltinMapper(); | 665 CFX_GEModule::Get()->GetFontMgr()->GetBuiltinMapper(); |
| 602 if (!pFontMapper) | 666 if (!pFontMapper) |
| 603 return false; | 667 return false; |
| 604 | 668 |
| 605 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); | 669 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); |
| 606 if (!pSystemFontInfo) | 670 if (!pSystemFontInfo) |
| 607 return false; | 671 return false; |
| 608 | 672 |
| 609 pSystemFontInfo->EnumFontList(pFontMapper); | 673 pSystemFontInfo->EnumFontList(pFontMapper); |
| 610 for (int32_t i = 0; i < pFontMapper->GetFaceSize(); ++i) { | 674 for (int32_t i = 0; i < pFontMapper->GetFaceSize(); ++i) { |
| 611 IFX_SeekableReadStream* pFontStream = | 675 IFX_SeekableReadStream* pFontStream = |
| 612 CreateFontStream(pFontMapper, pSystemFontInfo, i); | 676 CreateFontStream(pFontMapper, pSystemFontInfo, i); |
| 613 if (!pFontStream) | 677 if (!pFontStream) |
| 614 continue; | 678 continue; |
| 615 | 679 |
| 616 CFX_WideString wsFaceName = | 680 CFX_WideString wsFaceName = |
| 617 CFX_WideString::FromLocal(pFontMapper->GetFaceName(i).c_str()); | 681 CFX_WideString::FromLocal(pFontMapper->GetFaceName(i).c_str()); |
| 618 RegisterFaces(pFontStream, &wsFaceName); | 682 RegisterFaces(pFontStream, &wsFaceName); |
| 619 pFontStream->Release(); | 683 pFontStream->Release(); |
| 620 } | 684 } |
| 621 if (m_InstalledFonts.GetSize() == 0) | 685 if (m_InstalledFonts.GetSize() == 0) |
| 622 return false; | 686 return false; |
| 623 | 687 |
| 624 return true; | 688 return true; |
| 625 } | 689 } |
| 626 | 690 |
| 627 bool CFGAS_FontMgrImp::EnumFontsFromFiles() { | 691 bool CFGAS_FontMgr::EnumFontsFromFiles() { |
| 628 CFX_GEModule::Get()->GetFontMgr()->InitFTLibrary(); | 692 CFX_GEModule::Get()->GetFontMgr()->InitFTLibrary(); |
| 629 FX_POSITION pos = m_pFontSource->GetStartPosition(); | 693 FX_POSITION pos = m_pFontSource->GetStartPosition(); |
| 630 IFX_FileAccess* pFontSource = nullptr; | 694 IFX_FileAccess* pFontSource = nullptr; |
| 631 IFX_SeekableReadStream* pFontStream = nullptr; | 695 IFX_SeekableReadStream* pFontStream = nullptr; |
| 632 while (pos) { | 696 while (pos) { |
| 633 pFontSource = m_pFontSource->GetNext(pos); | 697 pFontSource = m_pFontSource->GetNext(pos); |
| 634 pFontStream = pFontSource->CreateFileStream(FX_FILEMODE_ReadOnly); | 698 pFontStream = pFontSource->CreateFileStream(FX_FILEMODE_ReadOnly); |
| 635 if (!pFontStream) { | 699 if (!pFontStream) { |
| 636 pFontSource->Release(); | 700 pFontSource->Release(); |
| 637 continue; | 701 continue; |
| 638 } | 702 } |
| 639 RegisterFaces(pFontStream, nullptr); | 703 RegisterFaces(pFontStream, nullptr); |
| 640 pFontStream->Release(); | 704 pFontStream->Release(); |
| 641 pFontSource->Release(); | 705 pFontSource->Release(); |
| 642 } | 706 } |
| 643 if (m_InstalledFonts.GetSize() == 0) | 707 if (m_InstalledFonts.GetSize() == 0) |
| 644 return false; | 708 return false; |
| 645 return true; | 709 return true; |
| 646 } | 710 } |
| 647 | 711 |
| 648 bool CFGAS_FontMgrImp::EnumFonts() { | 712 bool CFGAS_FontMgr::EnumFonts() { |
| 649 if (EnumFontsFromFontMapper()) | 713 if (EnumFontsFromFontMapper()) |
| 650 return true; | 714 return true; |
| 651 return EnumFontsFromFiles(); | 715 return EnumFontsFromFiles(); |
| 652 } | 716 } |
| 653 | 717 |
| 654 CFGAS_GEFont* CFGAS_FontMgrImp::GetDefFontByCodePage( | 718 CFGAS_GEFont* CFGAS_FontMgr::GetFontByCodePage(uint16_t wCodePage, |
| 655 uint16_t wCodePage, | 719 uint32_t dwFontStyles, |
| 656 uint32_t dwFontStyles, | 720 const FX_WCHAR* pszFontFamily) { |
| 657 const FX_WCHAR* pszFontFamily) { | |
| 658 return nullptr; | |
| 659 } | |
| 660 | |
| 661 CFGAS_GEFont* CFGAS_FontMgrImp::GetDefFontByCharset( | |
| 662 uint8_t nCharset, | |
| 663 uint32_t dwFontStyles, | |
| 664 const FX_WCHAR* pszFontFamily) { | |
| 665 return nullptr; | |
| 666 } | |
| 667 | |
| 668 CFGAS_GEFont* CFGAS_FontMgrImp::GetDefFontByUnicode( | |
| 669 FX_WCHAR wUnicode, | |
| 670 uint32_t dwFontStyles, | |
| 671 const FX_WCHAR* pszFontFamily) { | |
| 672 return nullptr; | |
| 673 } | |
| 674 | |
| 675 CFGAS_GEFont* CFGAS_FontMgrImp::GetDefFontByLanguage( | |
| 676 uint16_t wLanguage, | |
| 677 uint32_t dwFontStyles, | |
| 678 const FX_WCHAR* pszFontFamily) { | |
| 679 return nullptr; | |
| 680 } | |
| 681 | |
| 682 CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByCodePage( | |
| 683 uint16_t wCodePage, | |
| 684 uint32_t dwFontStyles, | |
| 685 const FX_WCHAR* pszFontFamily) { | |
| 686 CFX_ByteString bsHash; | 721 CFX_ByteString bsHash; |
| 687 bsHash.Format("%d, %d", wCodePage, dwFontStyles); | 722 bsHash.Format("%d, %d", wCodePage, dwFontStyles); |
| 688 bsHash += CFX_WideString(pszFontFamily).UTF8Encode(); | 723 bsHash += CFX_WideString(pszFontFamily).UTF8Encode(); |
| 689 uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringC(), false); | 724 uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringC(), false); |
| 690 CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts = nullptr; | 725 CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts = nullptr; |
| 691 if (m_Hash2Fonts.Lookup(dwHash, pFonts)) { | 726 if (m_Hash2Fonts.Lookup(dwHash, pFonts)) { |
| 692 if (!pFonts) | 727 if (!pFonts) |
| 693 return nullptr; | 728 return nullptr; |
| 694 | 729 |
| 695 if (pFonts->GetSize() != 0) | 730 if (pFonts->GetSize() != 0) |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 713 CFX_FontDescriptor* pDesc = sortedFonts->GetAt(0).pFont; | 748 CFX_FontDescriptor* pDesc = sortedFonts->GetAt(0).pFont; |
| 714 CFGAS_GEFont* pFont = | 749 CFGAS_GEFont* pFont = |
| 715 LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr); | 750 LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr); |
| 716 if (pFont) | 751 if (pFont) |
| 717 pFont->SetLogicalFontStyle(dwFontStyles); | 752 pFont->SetLogicalFontStyle(dwFontStyles); |
| 718 | 753 |
| 719 pFonts->Add(pFont); | 754 pFonts->Add(pFont); |
| 720 return pFont; | 755 return pFont; |
| 721 } | 756 } |
| 722 | 757 |
| 723 CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByCharset( | 758 CFGAS_GEFont* CFGAS_FontMgr::GetFontByUnicode(FX_WCHAR wUnicode, |
| 724 uint8_t nCharset, | 759 uint32_t dwFontStyles, |
| 725 uint32_t dwFontStyles, | 760 const FX_WCHAR* pszFontFamily) { |
| 726 const FX_WCHAR* pszFontFamily) { | |
| 727 return GetFontByCodePage(FX_GetCodePageFromCharset(nCharset), dwFontStyles, | |
| 728 pszFontFamily); | |
| 729 } | |
| 730 | |
| 731 CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByUnicode( | |
| 732 FX_WCHAR wUnicode, | |
| 733 uint32_t dwFontStyles, | |
| 734 const FX_WCHAR* pszFontFamily) { | |
| 735 CFGAS_GEFont* pFont = nullptr; | 761 CFGAS_GEFont* pFont = nullptr; |
| 736 if (m_FailedUnicodes2Nullptr.Lookup(wUnicode, pFont)) | 762 if (m_FailedUnicodes2Nullptr.Lookup(wUnicode, pFont)) |
| 737 return nullptr; | 763 return nullptr; |
| 738 const FGAS_FONTUSB* x = FGAS_GetUnicodeBitField(wUnicode); | 764 const FGAS_FONTUSB* x = FGAS_GetUnicodeBitField(wUnicode); |
| 739 uint16_t wCodePage = x ? x->wCodePage : 0xFFFF; | 765 uint16_t wCodePage = x ? x->wCodePage : 0xFFFF; |
| 740 uint16_t wBitField = x ? x->wBitField : 0x03E7; | 766 uint16_t wBitField = x ? x->wBitField : 0x03E7; |
| 741 CFX_ByteString bsHash; | 767 CFX_ByteString bsHash; |
| 742 if (wCodePage == 0xFFFF) | 768 if (wCodePage == 0xFFFF) |
| 743 bsHash.Format("%d, %d, %d", wCodePage, wBitField, dwFontStyles); | 769 bsHash.Format("%d, %d, %d", wCodePage, wBitField, dwFontStyles); |
| 744 else | 770 else |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 773 continue; | 799 continue; |
| 774 pFont->SetLogicalFontStyle(dwFontStyles); | 800 pFont->SetLogicalFontStyle(dwFontStyles); |
| 775 pFonts->Add(pFont); | 801 pFonts->Add(pFont); |
| 776 return pFont; | 802 return pFont; |
| 777 } | 803 } |
| 778 if (!pszFontFamily) | 804 if (!pszFontFamily) |
| 779 m_FailedUnicodes2Nullptr.SetAt(wUnicode, nullptr); | 805 m_FailedUnicodes2Nullptr.SetAt(wUnicode, nullptr); |
| 780 return nullptr; | 806 return nullptr; |
| 781 } | 807 } |
| 782 | 808 |
| 783 bool CFGAS_FontMgrImp::VerifyUnicode(CFX_FontDescriptor* pDesc, | 809 bool CFGAS_FontMgr::VerifyUnicode(CFX_FontDescriptor* pDesc, |
| 784 FX_WCHAR wcUnicode) { | 810 FX_WCHAR wcUnicode) { |
| 785 IFX_SeekableReadStream* pFileRead = | 811 IFX_SeekableReadStream* pFileRead = |
| 786 CreateFontStream(pDesc->m_wsFaceName.UTF8Encode()); | 812 CreateFontStream(pDesc->m_wsFaceName.UTF8Encode()); |
| 787 if (!pFileRead) | 813 if (!pFileRead) |
| 788 return false; | 814 return false; |
| 789 FXFT_Face pFace = LoadFace(pFileRead, pDesc->m_nFaceIndex); | 815 FXFT_Face pFace = LoadFace(pFileRead, pDesc->m_nFaceIndex); |
| 790 FT_Error retCharmap = FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE); | 816 FT_Error retCharmap = FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE); |
| 791 FT_Error retIndex = FXFT_Get_Char_Index(pFace, wcUnicode); | 817 FT_Error retIndex = FXFT_Get_Char_Index(pFace, wcUnicode); |
| 792 pFileRead->Release(); | 818 pFileRead->Release(); |
| 793 if (!pFace) | 819 if (!pFace) |
| 794 return false; | 820 return false; |
| 795 if (FXFT_Get_Face_External_Stream(pFace)) | 821 if (FXFT_Get_Face_External_Stream(pFace)) |
| 796 FXFT_Clear_Face_External_Stream(pFace); | 822 FXFT_Clear_Face_External_Stream(pFace); |
| 797 FXFT_Done_Face(pFace); | 823 FXFT_Done_Face(pFace); |
| 798 return !retCharmap && retIndex; | 824 return !retCharmap && retIndex; |
| 799 } | 825 } |
| 800 | 826 |
| 801 bool CFGAS_FontMgrImp::VerifyUnicode(CFGAS_GEFont* pFont, FX_WCHAR wcUnicode) { | 827 bool CFGAS_FontMgr::VerifyUnicode(CFGAS_GEFont* pFont, FX_WCHAR wcUnicode) { |
| 802 if (!pFont) | 828 if (!pFont) |
| 803 return false; | 829 return false; |
| 804 | 830 |
| 805 FXFT_Face pFace = pFont->GetDevFont()->GetFace(); | 831 FXFT_Face pFace = pFont->GetDevFont()->GetFace(); |
| 806 FXFT_CharMap charmap = FXFT_Get_Face_Charmap(pFace); | 832 FXFT_CharMap charmap = FXFT_Get_Face_Charmap(pFace); |
| 807 if (FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE) != 0) | 833 if (FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE) != 0) |
| 808 return false; | 834 return false; |
| 809 | 835 |
| 810 if (FXFT_Get_Char_Index(pFace, wcUnicode) == 0) { | 836 if (FXFT_Get_Char_Index(pFace, wcUnicode) == 0) { |
| 811 FXFT_Set_Charmap(pFace, charmap); | 837 FXFT_Set_Charmap(pFace, charmap); |
| 812 return false; | 838 return false; |
| 813 } | 839 } |
| 814 return true; | 840 return true; |
| 815 } | 841 } |
| 816 | 842 |
| 817 CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByLanguage( | 843 CFGAS_GEFont* CFGAS_FontMgr::LoadFont(const CFX_WideString& wsFaceName, |
| 818 uint16_t wLanguage, | 844 int32_t iFaceIndex, |
| 819 uint32_t dwFontStyles, | 845 int32_t* pFaceCount) { |
| 820 const FX_WCHAR* pszFontFamily) { | |
| 821 return GetFontByCodePage(FX_GetDefCodePageByLanguage(wLanguage), dwFontStyles, | |
| 822 pszFontFamily); | |
| 823 } | |
| 824 | |
| 825 CFGAS_GEFont* CFGAS_FontMgrImp::LoadFont(const CFX_WideString& wsFaceName, | |
| 826 int32_t iFaceIndex, | |
| 827 int32_t* pFaceCount) { | |
| 828 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); | 846 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); |
| 829 CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); | 847 CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); |
| 830 if (!pFontMapper) | 848 if (!pFontMapper) |
| 831 return nullptr; | 849 return nullptr; |
| 832 | 850 |
| 833 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); | 851 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); |
| 834 if (!pSystemFontInfo) | 852 if (!pSystemFontInfo) |
| 835 return nullptr; | 853 return nullptr; |
| 836 | 854 |
| 837 IFX_SeekableReadStream* pFontStream = | 855 IFX_SeekableReadStream* pFontStream = |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 872 int res = pFile->ReadBlock(buffer, offset, count); | 890 int res = pFile->ReadBlock(buffer, offset, count); |
| 873 if (res) | 891 if (res) |
| 874 return count; | 892 return count; |
| 875 return 0; | 893 return 0; |
| 876 } | 894 } |
| 877 | 895 |
| 878 void _ftStreamClose(FXFT_Stream stream) {} | 896 void _ftStreamClose(FXFT_Stream stream) {} |
| 879 | 897 |
| 880 }; // extern "C" | 898 }; // extern "C" |
| 881 | 899 |
| 882 FXFT_Face CFGAS_FontMgrImp::LoadFace(IFX_SeekableReadStream* pFontStream, | 900 FXFT_Face CFGAS_FontMgr::LoadFace(IFX_SeekableReadStream* pFontStream, |
| 883 int32_t iFaceIndex) { | 901 int32_t iFaceIndex) { |
| 884 if (!pFontStream) | 902 if (!pFontStream) |
| 885 return nullptr; | 903 return nullptr; |
| 886 | 904 |
| 887 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); | 905 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); |
| 888 pFontMgr->InitFTLibrary(); | 906 pFontMgr->InitFTLibrary(); |
| 889 FXFT_Library library = pFontMgr->GetFTLibrary(); | 907 FXFT_Library library = pFontMgr->GetFTLibrary(); |
| 890 if (!library) | 908 if (!library) |
| 891 return nullptr; | 909 return nullptr; |
| 892 | 910 |
| 893 FXFT_Stream ftStream = FX_Alloc(FXFT_StreamRec, 1); | 911 FXFT_Stream ftStream = FX_Alloc(FXFT_StreamRec, 1); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 907 FXFT_Face pFace = nullptr; | 925 FXFT_Face pFace = nullptr; |
| 908 if (FXFT_Open_Face(library, &ftArgs, iFaceIndex, &pFace)) { | 926 if (FXFT_Open_Face(library, &ftArgs, iFaceIndex, &pFace)) { |
| 909 FX_Free(ftStream); | 927 FX_Free(ftStream); |
| 910 return nullptr; | 928 return nullptr; |
| 911 } | 929 } |
| 912 | 930 |
| 913 FXFT_Set_Pixel_Sizes(pFace, 0, 64); | 931 FXFT_Set_Pixel_Sizes(pFace, 0, 64); |
| 914 return pFace; | 932 return pFace; |
| 915 } | 933 } |
| 916 | 934 |
| 917 IFX_SeekableReadStream* CFGAS_FontMgrImp::CreateFontStream( | 935 IFX_SeekableReadStream* CFGAS_FontMgr::CreateFontStream( |
| 918 CFX_FontMapper* pFontMapper, | 936 CFX_FontMapper* pFontMapper, |
| 919 IFX_SystemFontInfo* pSystemFontInfo, | 937 IFX_SystemFontInfo* pSystemFontInfo, |
| 920 uint32_t index) { | 938 uint32_t index) { |
| 921 int iExact = 0; | 939 int iExact = 0; |
| 922 void* hFont = | 940 void* hFont = |
| 923 pSystemFontInfo->MapFont(0, 0, FXFONT_DEFAULT_CHARSET, 0, | 941 pSystemFontInfo->MapFont(0, 0, FXFONT_DEFAULT_CHARSET, 0, |
| 924 pFontMapper->GetFaceName(index).c_str(), iExact); | 942 pFontMapper->GetFaceName(index).c_str(), iExact); |
| 925 if (!hFont) | 943 if (!hFont) |
| 926 return nullptr; | 944 return nullptr; |
| 927 | 945 |
| 928 uint32_t dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, nullptr, 0); | 946 uint32_t dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, nullptr, 0); |
| 929 if (dwFileSize == 0) | 947 if (dwFileSize == 0) |
| 930 return nullptr; | 948 return nullptr; |
| 931 | 949 |
| 932 uint8_t* pBuffer = FX_Alloc(uint8_t, dwFileSize + 1); | 950 uint8_t* pBuffer = FX_Alloc(uint8_t, dwFileSize + 1); |
| 933 dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, pBuffer, dwFileSize); | 951 dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, pBuffer, dwFileSize); |
| 934 | 952 |
| 935 return FX_CreateMemoryStream(pBuffer, dwFileSize, true); | 953 return FX_CreateMemoryStream(pBuffer, dwFileSize, true); |
| 936 } | 954 } |
| 937 | 955 |
| 938 IFX_SeekableReadStream* CFGAS_FontMgrImp::CreateFontStream( | 956 IFX_SeekableReadStream* CFGAS_FontMgr::CreateFontStream( |
| 939 const CFX_ByteString& bsFaceName) { | 957 const CFX_ByteString& bsFaceName) { |
| 940 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); | 958 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); |
| 941 CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); | 959 CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); |
| 942 | 960 |
| 943 if (!pFontMapper) | 961 if (!pFontMapper) |
| 944 return nullptr; | 962 return nullptr; |
| 945 | 963 |
| 946 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); | 964 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); |
| 947 if (!pSystemFontInfo) | 965 if (!pSystemFontInfo) |
| 948 return nullptr; | 966 return nullptr; |
| 949 | 967 |
| 950 pSystemFontInfo->EnumFontList(pFontMapper); | 968 pSystemFontInfo->EnumFontList(pFontMapper); |
| 951 for (int32_t i = 0; i < pFontMapper->GetFaceSize(); ++i) { | 969 for (int32_t i = 0; i < pFontMapper->GetFaceSize(); ++i) { |
| 952 if (pFontMapper->GetFaceName(i) == bsFaceName) | 970 if (pFontMapper->GetFaceName(i) == bsFaceName) |
| 953 return CreateFontStream(pFontMapper, pSystemFontInfo, i); | 971 return CreateFontStream(pFontMapper, pSystemFontInfo, i); |
| 954 } | 972 } |
| 955 return nullptr; | 973 return nullptr; |
| 956 } | 974 } |
| 957 | 975 |
| 958 int32_t CFGAS_FontMgrImp::MatchFonts(CFX_FontDescriptorInfos& MatchedFonts, | 976 int32_t CFGAS_FontMgr::MatchFonts(CFX_FontDescriptorInfos& MatchedFonts, |
| 959 uint16_t wCodePage, | 977 uint16_t wCodePage, |
| 960 uint32_t dwFontStyles, | 978 uint32_t dwFontStyles, |
| 961 const CFX_WideString& FontName, | 979 const CFX_WideString& FontName, |
| 962 FX_WCHAR wcUnicode) { | 980 FX_WCHAR wcUnicode) { |
| 963 MatchedFonts.RemoveAll(); | 981 MatchedFonts.RemoveAll(); |
| 964 CFX_WideString wsNormalizedFontName = FontName; | 982 CFX_WideString wsNormalizedFontName = FontName; |
| 965 | 983 |
| 966 CFX_FontDescriptor* pFont = nullptr; | 984 CFX_FontDescriptor* pFont = nullptr; |
| 967 int32_t nCount = m_InstalledFonts.GetSize(); | 985 int32_t nCount = m_InstalledFonts.GetSize(); |
| 968 for (int32_t i = 0; i < nCount; i++) { | 986 for (int32_t i = 0; i < nCount; i++) { |
| 969 pFont = m_InstalledFonts[i]; | 987 pFont = m_InstalledFonts[i]; |
| 970 int32_t nPenalty = CalcPenalty(pFont, wCodePage, dwFontStyles, | 988 int32_t nPenalty = CalcPenalty(pFont, wCodePage, dwFontStyles, |
| 971 wsNormalizedFontName, wcUnicode); | 989 wsNormalizedFontName, wcUnicode); |
| 972 if (nPenalty >= 0xffff) | 990 if (nPenalty >= 0xffff) |
| 973 continue; | 991 continue; |
| 974 | 992 |
| 975 FX_FontDescriptorInfo FontInfo; | 993 FX_FontDescriptorInfo FontInfo; |
| 976 FontInfo.pFont = pFont; | 994 FontInfo.pFont = pFont; |
| 977 FontInfo.nPenalty = nPenalty; | 995 FontInfo.nPenalty = nPenalty; |
| 978 MatchedFonts.Add(FontInfo); | 996 MatchedFonts.Add(FontInfo); |
| 979 if (MatchedFonts.GetSize() == 0xffff) | 997 if (MatchedFonts.GetSize() == 0xffff) |
| 980 break; | 998 break; |
| 981 } | 999 } |
| 982 if (MatchedFonts.GetSize() == 0) | 1000 if (MatchedFonts.GetSize() == 0) |
| 983 return 0; | 1001 return 0; |
| 984 | 1002 |
| 985 CFX_SSortTemplate<FX_FontDescriptorInfo> ssort; | 1003 CFX_SSortTemplate<FX_FontDescriptorInfo> ssort; |
| 986 ssort.ShellSort(MatchedFonts.GetData(), MatchedFonts.GetSize()); | 1004 ssort.ShellSort(MatchedFonts.GetData(), MatchedFonts.GetSize()); |
| 987 return MatchedFonts.GetSize(); | 1005 return MatchedFonts.GetSize(); |
| 988 } | 1006 } |
| 989 | 1007 |
| 990 struct FX_BitCodePage { | 1008 int32_t CFGAS_FontMgr::CalcPenalty(CFX_FontDescriptor* pInstalled, |
| 991 uint16_t wBit; | 1009 uint16_t wCodePage, |
| 992 uint16_t wCodePage; | 1010 uint32_t dwFontStyles, |
| 993 }; | 1011 const CFX_WideString& FontName, |
| 994 static const FX_BitCodePage g_Bit2CodePage[] = { | 1012 FX_WCHAR wcUnicode) { |
| 995 {0, 1252}, {1, 1250}, {2, 1251}, {3, 1253}, {4, 1254}, {5, 1255}, | |
| 996 {6, 1256}, {7, 1257}, {8, 1258}, {9, 0}, {10, 0}, {11, 0}, | |
| 997 {12, 0}, {13, 0}, {14, 0}, {15, 0}, {16, 874}, {17, 932}, | |
| 998 {18, 936}, {19, 949}, {20, 950}, {21, 1361}, {22, 0}, {23, 0}, | |
| 999 {24, 0}, {25, 0}, {26, 0}, {27, 0}, {28, 0}, {29, 0}, | |
| 1000 {30, 0}, {31, 0}, {32, 0}, {33, 0}, {34, 0}, {35, 0}, | |
| 1001 {36, 0}, {37, 0}, {38, 0}, {39, 0}, {40, 0}, {41, 0}, | |
| 1002 {42, 0}, {43, 0}, {44, 0}, {45, 0}, {46, 0}, {47, 0}, | |
| 1003 {48, 869}, {49, 866}, {50, 865}, {51, 864}, {52, 863}, {53, 862}, | |
| 1004 {54, 861}, {55, 860}, {56, 857}, {57, 855}, {58, 852}, {59, 775}, | |
| 1005 {60, 737}, {61, 708}, {62, 850}, {63, 437}, | |
| 1006 }; | |
| 1007 | |
| 1008 uint16_t FX_GetCodePageBit(uint16_t wCodePage) { | |
| 1009 for (size_t i = 0; i < FX_ArraySize(g_Bit2CodePage); ++i) { | |
| 1010 if (g_Bit2CodePage[i].wCodePage == wCodePage) | |
| 1011 return g_Bit2CodePage[i].wBit; | |
| 1012 } | |
| 1013 return (uint16_t)-1; | |
| 1014 } | |
| 1015 | |
| 1016 uint16_t FX_GetUnicodeBit(FX_WCHAR wcUnicode) { | |
| 1017 const FGAS_FONTUSB* x = FGAS_GetUnicodeBitField(wcUnicode); | |
| 1018 return x ? x->wBitField : 999; | |
| 1019 } | |
| 1020 | |
| 1021 int32_t CFGAS_FontMgrImp::CalcPenalty(CFX_FontDescriptor* pInstalled, | |
| 1022 uint16_t wCodePage, | |
| 1023 uint32_t dwFontStyles, | |
| 1024 const CFX_WideString& FontName, | |
| 1025 FX_WCHAR wcUnicode) { | |
| 1026 int32_t nPenalty = 30000; | 1013 int32_t nPenalty = 30000; |
| 1027 if (0 != FontName.GetLength()) { | 1014 if (0 != FontName.GetLength()) { |
| 1028 if (FontName != pInstalled->m_wsFaceName) { | 1015 if (FontName != pInstalled->m_wsFaceName) { |
| 1029 int32_t i; | 1016 int32_t i; |
| 1030 for (i = 0; i < pInstalled->m_wsFamilyNames.GetSize(); i++) { | 1017 for (i = 0; i < pInstalled->m_wsFamilyNames.GetSize(); i++) { |
| 1031 if (pInstalled->m_wsFamilyNames[i] == FontName) { | 1018 if (pInstalled->m_wsFamilyNames[i] == FontName) |
| 1032 break; | 1019 break; |
| 1033 } | |
| 1034 } | 1020 } |
| 1035 if (i == pInstalled->m_wsFamilyNames.GetSize()) { | 1021 if (i == pInstalled->m_wsFamilyNames.GetSize()) |
| 1036 nPenalty += 0xFFFF; | 1022 nPenalty += 0xFFFF; |
| 1037 } else { | 1023 else |
| 1038 nPenalty -= 28000; | 1024 nPenalty -= 28000; |
| 1039 } | |
| 1040 } else { | 1025 } else { |
| 1041 nPenalty -= 30000; | 1026 nPenalty -= 30000; |
| 1042 } | 1027 } |
| 1043 if (30000 == nPenalty && | 1028 if (30000 == nPenalty && |
| 1044 0 == IsPartName(pInstalled->m_wsFaceName, FontName)) { | 1029 0 == IsPartName(pInstalled->m_wsFaceName, FontName)) { |
| 1045 int32_t i; | 1030 int32_t i; |
| 1046 for (i = 0; i < pInstalled->m_wsFamilyNames.GetSize(); i++) { | 1031 for (i = 0; i < pInstalled->m_wsFamilyNames.GetSize(); i++) { |
| 1047 if (0 != IsPartName(pInstalled->m_wsFamilyNames[i], FontName)) { | 1032 if (0 != IsPartName(pInstalled->m_wsFamilyNames[i], FontName)) |
| 1048 break; | 1033 break; |
| 1049 } | |
| 1050 } | 1034 } |
| 1051 if (i == pInstalled->m_wsFamilyNames.GetSize()) { | 1035 if (i == pInstalled->m_wsFamilyNames.GetSize()) |
| 1052 nPenalty += 0xFFFF; | 1036 nPenalty += 0xFFFF; |
| 1053 } else { | 1037 else |
| 1054 nPenalty -= 26000; | 1038 nPenalty -= 26000; |
| 1055 } | |
| 1056 } else { | 1039 } else { |
| 1057 nPenalty -= 27000; | 1040 nPenalty -= 27000; |
| 1058 } | 1041 } |
| 1059 } | 1042 } |
| 1060 uint32_t dwStyleMask = pInstalled->m_dwFontStyles ^ dwFontStyles; | 1043 uint32_t dwStyleMask = pInstalled->m_dwFontStyles ^ dwFontStyles; |
| 1061 if (dwStyleMask & FX_FONTSTYLE_Bold) { | 1044 if (dwStyleMask & FX_FONTSTYLE_Bold) |
| 1062 nPenalty += 4500; | 1045 nPenalty += 4500; |
| 1063 } | 1046 if (dwStyleMask & FX_FONTSTYLE_FixedPitch) |
| 1064 if (dwStyleMask & FX_FONTSTYLE_FixedPitch) { | |
| 1065 nPenalty += 10000; | 1047 nPenalty += 10000; |
| 1066 } | 1048 if (dwStyleMask & FX_FONTSTYLE_Italic) |
| 1067 if (dwStyleMask & FX_FONTSTYLE_Italic) { | |
| 1068 nPenalty += 10000; | 1049 nPenalty += 10000; |
| 1069 } | 1050 if (dwStyleMask & FX_FONTSTYLE_Serif) |
| 1070 if (dwStyleMask & FX_FONTSTYLE_Serif) { | |
| 1071 nPenalty += 500; | 1051 nPenalty += 500; |
| 1072 } | 1052 if (dwStyleMask & FX_FONTSTYLE_Symbolic) |
| 1073 if (dwStyleMask & FX_FONTSTYLE_Symbolic) { | |
| 1074 nPenalty += 0xFFFF; | 1053 nPenalty += 0xFFFF; |
| 1075 } | 1054 if (nPenalty >= 0xFFFF) |
| 1076 if (nPenalty >= 0xFFFF) { | |
| 1077 return 0xFFFF; | 1055 return 0xFFFF; |
| 1078 } | |
| 1079 uint16_t wBit = | 1056 uint16_t wBit = |
| 1080 ((0 == wCodePage || 0xFFFF == wCodePage) ? (uint16_t)-1 | 1057 ((0 == wCodePage || 0xFFFF == wCodePage) ? (uint16_t)-1 |
| 1081 : FX_GetCodePageBit(wCodePage)); | 1058 : FX_GetCodePageBit(wCodePage)); |
| 1082 if (wBit != (uint16_t)-1) { | 1059 if (wBit != (uint16_t)-1) { |
| 1083 ASSERT(wBit < 64); | 1060 ASSERT(wBit < 64); |
| 1084 if (0 == (pInstalled->m_dwCsb[wBit / 32] & (1 << (wBit % 32)))) { | 1061 if (0 == (pInstalled->m_dwCsb[wBit / 32] & (1 << (wBit % 32)))) |
| 1085 nPenalty += 0xFFFF; | 1062 nPenalty += 0xFFFF; |
| 1086 } else { | 1063 else |
| 1087 nPenalty -= 60000; | 1064 nPenalty -= 60000; |
| 1088 } | |
| 1089 } | 1065 } |
| 1090 wBit = | 1066 wBit = |
| 1091 ((0 == wcUnicode || 0xFFFE == wcUnicode) ? (uint16_t)999 | 1067 ((0 == wcUnicode || 0xFFFE == wcUnicode) ? (uint16_t)999 |
| 1092 : FX_GetUnicodeBit(wcUnicode)); | 1068 : FX_GetUnicodeBit(wcUnicode)); |
| 1093 if (wBit != (uint16_t)999) { | 1069 if (wBit != (uint16_t)999) { |
| 1094 ASSERT(wBit < 128); | 1070 ASSERT(wBit < 128); |
| 1095 if (0 == (pInstalled->m_dwUsb[wBit / 32] & (1 << (wBit % 32)))) { | 1071 if (0 == (pInstalled->m_dwUsb[wBit / 32] & (1 << (wBit % 32)))) |
| 1096 nPenalty += 0xFFFF; | 1072 nPenalty += 0xFFFF; |
| 1097 } else { | 1073 else |
| 1098 nPenalty -= 60000; | 1074 nPenalty -= 60000; |
| 1099 } | |
| 1100 } | 1075 } |
| 1101 return nPenalty; | 1076 return nPenalty; |
| 1102 } | 1077 } |
| 1103 | 1078 |
| 1104 void CFGAS_FontMgrImp::ClearFontCache() { | 1079 void CFGAS_FontMgr::ClearFontCache() { |
| 1105 FX_POSITION pos = m_Hash2CandidateList.GetStartPosition(); | 1080 FX_POSITION pos = m_Hash2CandidateList.GetStartPosition(); |
| 1106 while (pos) { | 1081 while (pos) { |
| 1107 uint32_t dwHash; | 1082 uint32_t dwHash; |
| 1108 CFX_FontDescriptorInfos* pDescs; | 1083 CFX_FontDescriptorInfos* pDescs; |
| 1109 m_Hash2CandidateList.GetNextAssoc(pos, dwHash, pDescs); | 1084 m_Hash2CandidateList.GetNextAssoc(pos, dwHash, pDescs); |
| 1110 delete pDescs; | 1085 delete pDescs; |
| 1111 } | 1086 } |
| 1112 pos = m_IFXFont2FileRead.GetStartPosition(); | 1087 pos = m_IFXFont2FileRead.GetStartPosition(); |
| 1113 while (pos) { | 1088 while (pos) { |
| 1114 CFGAS_GEFont* pFont; | 1089 CFGAS_GEFont* pFont; |
| 1115 IFX_SeekableReadStream* pFileRead; | 1090 IFX_SeekableReadStream* pFileRead; |
| 1116 m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead); | 1091 m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead); |
| 1117 pFileRead->Release(); | 1092 pFileRead->Release(); |
| 1118 } | 1093 } |
| 1119 } | 1094 } |
| 1120 | 1095 |
| 1121 void CFGAS_FontMgrImp::RemoveFont(CFGAS_GEFont* pEFont) { | 1096 void CFGAS_FontMgr::RemoveFont(CFGAS_GEFont* pEFont) { |
| 1122 if (!pEFont) { | 1097 if (!pEFont) |
| 1123 return; | 1098 return; |
| 1124 } | 1099 |
| 1125 IFX_SeekableReadStream* pFileRead; | 1100 IFX_SeekableReadStream* pFileRead; |
| 1126 if (m_IFXFont2FileRead.Lookup(pEFont, pFileRead)) { | 1101 if (m_IFXFont2FileRead.Lookup(pEFont, pFileRead)) { |
| 1127 pFileRead->Release(); | 1102 pFileRead->Release(); |
| 1128 m_IFXFont2FileRead.RemoveKey(pEFont); | 1103 m_IFXFont2FileRead.RemoveKey(pEFont); |
| 1129 } | 1104 } |
| 1130 FX_POSITION pos; | 1105 FX_POSITION pos; |
| 1131 pos = m_Hash2Fonts.GetStartPosition(); | 1106 pos = m_Hash2Fonts.GetStartPosition(); |
| 1132 while (pos) { | 1107 while (pos) { |
| 1133 uint32_t dwHash; | 1108 uint32_t dwHash; |
| 1134 CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts; | 1109 CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts; |
| 1135 m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); | 1110 m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); |
| 1136 if (pFonts) { | 1111 if (pFonts) { |
| 1137 for (int32_t i = 0; i < pFonts->GetSize(); i++) { | 1112 for (int32_t i = 0; i < pFonts->GetSize(); i++) { |
| 1138 if (pFonts->GetAt(i) == pEFont) { | 1113 if (pFonts->GetAt(i) == pEFont) |
| 1139 pFonts->SetAt(i, nullptr); | 1114 pFonts->SetAt(i, nullptr); |
| 1140 } | |
| 1141 } | 1115 } |
| 1142 } else { | 1116 } else { |
| 1143 m_Hash2Fonts.RemoveKey(dwHash); | 1117 m_Hash2Fonts.RemoveKey(dwHash); |
| 1144 } | 1118 } |
| 1145 } | 1119 } |
| 1146 } | 1120 } |
| 1147 | 1121 |
| 1148 void CFGAS_FontMgrImp::RegisterFace(FXFT_Face pFace, | 1122 void CFGAS_FontMgr::RegisterFace(FXFT_Face pFace, |
| 1149 const CFX_WideString* pFaceName) { | 1123 const CFX_WideString* pFaceName) { |
| 1150 if ((pFace->face_flags & FT_FACE_FLAG_SCALABLE) == 0) | 1124 if ((pFace->face_flags & FT_FACE_FLAG_SCALABLE) == 0) |
| 1151 return; | 1125 return; |
| 1152 | 1126 |
| 1153 std::unique_ptr<CFX_FontDescriptor> pFont(new CFX_FontDescriptor); | 1127 std::unique_ptr<CFX_FontDescriptor> pFont(new CFX_FontDescriptor); |
| 1154 pFont->m_dwFontStyles |= FXFT_Is_Face_Bold(pFace) ? FX_FONTSTYLE_Bold : 0; | 1128 pFont->m_dwFontStyles |= FXFT_Is_Face_Bold(pFace) ? FX_FONTSTYLE_Bold : 0; |
| 1155 pFont->m_dwFontStyles |= FXFT_Is_Face_Italic(pFace) ? FX_FONTSTYLE_Italic : 0; | 1129 pFont->m_dwFontStyles |= FXFT_Is_Face_Italic(pFace) ? FX_FONTSTYLE_Italic : 0; |
| 1156 pFont->m_dwFontStyles |= GetFlags(pFace); | 1130 pFont->m_dwFontStyles |= GetFlags(pFace); |
| 1157 | 1131 |
| 1158 std::vector<uint16_t> charsets = GetCharsets(pFace); | 1132 std::vector<uint16_t> charsets = GetCharsets(pFace); |
| 1159 GetUSBCSB(pFace, pFont->m_dwUsb, pFont->m_dwCsb); | 1133 GetUSBCSB(pFace, pFont->m_dwUsb, pFont->m_dwCsb); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1173 | 1147 |
| 1174 pFont->m_wsFamilyNames.Add(CFX_ByteString(pFace->family_name).UTF8Decode()); | 1148 pFont->m_wsFamilyNames.Add(CFX_ByteString(pFace->family_name).UTF8Decode()); |
| 1175 pFont->m_wsFaceName = | 1149 pFont->m_wsFaceName = |
| 1176 pFaceName ? *pFaceName | 1150 pFaceName ? *pFaceName |
| 1177 : CFX_WideString::FromLocal(FXFT_Get_Postscript_Name(pFace)); | 1151 : CFX_WideString::FromLocal(FXFT_Get_Postscript_Name(pFace)); |
| 1178 pFont->m_nFaceIndex = pFace->face_index; | 1152 pFont->m_nFaceIndex = pFace->face_index; |
| 1179 | 1153 |
| 1180 m_InstalledFonts.Add(pFont.release()); | 1154 m_InstalledFonts.Add(pFont.release()); |
| 1181 } | 1155 } |
| 1182 | 1156 |
| 1183 void CFGAS_FontMgrImp::RegisterFaces(IFX_SeekableReadStream* pFontStream, | 1157 void CFGAS_FontMgr::RegisterFaces(IFX_SeekableReadStream* pFontStream, |
| 1184 const CFX_WideString* pFaceName) { | 1158 const CFX_WideString* pFaceName) { |
| 1185 int32_t index = 0; | 1159 int32_t index = 0; |
| 1186 int32_t num_faces = 0; | 1160 int32_t num_faces = 0; |
| 1187 do { | 1161 do { |
| 1188 FXFT_Face pFace = LoadFace(pFontStream, index++); | 1162 FXFT_Face pFace = LoadFace(pFontStream, index++); |
| 1189 if (!pFace) | 1163 if (!pFace) |
| 1190 continue; | 1164 continue; |
| 1191 // All faces keep number of faces. It can be retrieved from any one face. | 1165 // All faces keep number of faces. It can be retrieved from any one face. |
| 1192 if (num_faces == 0) | 1166 if (num_faces == 0) |
| 1193 num_faces = pFace->num_faces; | 1167 num_faces = pFace->num_faces; |
| 1194 RegisterFace(pFace, pFaceName); | 1168 RegisterFace(pFace, pFaceName); |
| 1195 if (FXFT_Get_Face_External_Stream(pFace)) | 1169 if (FXFT_Get_Face_External_Stream(pFace)) |
| 1196 FXFT_Clear_Face_External_Stream(pFace); | 1170 FXFT_Clear_Face_External_Stream(pFace); |
| 1197 FXFT_Done_Face(pFace); | 1171 FXFT_Done_Face(pFace); |
| 1198 } while (index < num_faces); | 1172 } while (index < num_faces); |
| 1199 } | 1173 } |
| 1200 | 1174 |
| 1201 uint32_t CFGAS_FontMgrImp::GetFlags(FXFT_Face pFace) { | 1175 uint32_t CFGAS_FontMgr::GetFlags(FXFT_Face pFace) { |
| 1202 uint32_t flag = 0; | 1176 uint32_t flag = 0; |
| 1203 if (FT_IS_FIXED_WIDTH(pFace)) { | 1177 if (FT_IS_FIXED_WIDTH(pFace)) |
| 1204 flag |= FX_FONTSTYLE_FixedPitch; | 1178 flag |= FX_FONTSTYLE_FixedPitch; |
| 1205 } | |
| 1206 TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2); | 1179 TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2); |
| 1207 if (!pOS2) { | 1180 if (!pOS2) |
| 1208 return flag; | 1181 return flag; |
| 1209 } | 1182 if (pOS2->ulCodePageRange1 & (1 << 31)) |
| 1210 if (pOS2->ulCodePageRange1 & (1 << 31)) { | |
| 1211 flag |= FX_FONTSTYLE_Symbolic; | 1183 flag |= FX_FONTSTYLE_Symbolic; |
| 1212 } | |
| 1213 if (pOS2->panose[0] == 2) { | 1184 if (pOS2->panose[0] == 2) { |
| 1214 uint8_t uSerif = pOS2->panose[1]; | 1185 uint8_t uSerif = pOS2->panose[1]; |
| 1215 if ((uSerif > 1 && uSerif < 10) || uSerif > 13) { | 1186 if ((uSerif > 1 && uSerif < 10) || uSerif > 13) |
| 1216 flag |= FX_FONTSTYLE_Serif; | 1187 flag |= FX_FONTSTYLE_Serif; |
| 1217 } | |
| 1218 } | 1188 } |
| 1219 return flag; | 1189 return flag; |
| 1220 } | 1190 } |
| 1221 | 1191 |
| 1222 #define GetUInt8(p) ((uint8_t)((p)[0])) | 1192 void CFGAS_FontMgr::GetNames(const uint8_t* name_table, |
| 1223 #define GetUInt16(p) ((uint16_t)((p)[0] << 8 | (p)[1])) | 1193 CFX_WideStringArray& Names) { |
|
npm
2016/11/11 00:20:39
Moved these two to inline namespace methods. GetUI
| |
| 1224 #define GetUInt32(p) \ | |
| 1225 ((uint32_t)((p)[0] << 24 | (p)[1] << 16 | (p)[2] << 8 | (p)[3])) | |
| 1226 | |
| 1227 void CFGAS_FontMgrImp::GetNames(const uint8_t* name_table, | |
| 1228 CFX_WideStringArray& Names) { | |
| 1229 if (!name_table) { | 1194 if (!name_table) { |
| 1230 return; | 1195 return; |
| 1231 } | 1196 } |
| 1232 uint8_t* lpTable = (uint8_t*)name_table; | 1197 uint8_t* lpTable = (uint8_t*)name_table; |
| 1233 CFX_WideString wsFamily; | 1198 CFX_WideString wsFamily; |
| 1234 uint8_t* sp = lpTable + 2; | 1199 uint8_t* sp = lpTable + 2; |
| 1235 uint8_t* lpNameRecord = lpTable + 6; | 1200 uint8_t* lpNameRecord = lpTable + 6; |
| 1236 uint16_t nNameCount = GetUInt16(sp); | 1201 uint16_t nNameCount = GetUInt16(sp); |
| 1237 uint8_t* lpStr = lpTable + GetUInt16(sp + 2); | 1202 uint8_t* lpStr = lpTable + GetUInt16(sp + 2); |
| 1238 for (uint16_t j = 0; j < nNameCount; j++) { | 1203 for (uint16_t j = 0; j < nNameCount; j++) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1252 Names.Add(wsFamily); | 1217 Names.Add(wsFamily); |
| 1253 } else { | 1218 } else { |
| 1254 for (uint16_t k = 0; k < nNameLength; k++) { | 1219 for (uint16_t k = 0; k < nNameLength; k++) { |
| 1255 FX_WCHAR wcTemp = GetUInt8(lpStr + nNameOffset + k); | 1220 FX_WCHAR wcTemp = GetUInt8(lpStr + nNameOffset + k); |
| 1256 wsFamily += wcTemp; | 1221 wsFamily += wcTemp; |
| 1257 } | 1222 } |
| 1258 Names.Add(wsFamily); | 1223 Names.Add(wsFamily); |
| 1259 } | 1224 } |
| 1260 } | 1225 } |
| 1261 } | 1226 } |
| 1262 #undef GetUInt8 | |
| 1263 #undef GetUInt16 | |
| 1264 #undef GetUInt32 | |
| 1265 struct FX_BIT2CHARSET { | |
| 1266 uint16_t wBit; | |
| 1267 uint16_t wCharset; | |
| 1268 }; | |
| 1269 | 1227 |
| 1270 FX_BIT2CHARSET g_FX_Bit2Charset1[16] = { | 1228 // TODO(npm): Get rid of this #define |
| 1271 {1 << 0, FX_CHARSET_ANSI}, | |
| 1272 {1 << 1, FX_CHARSET_MSWin_EasterEuropean}, | |
| 1273 {1 << 2, FX_CHARSET_MSWin_Cyrillic}, | |
| 1274 {1 << 3, FX_CHARSET_MSWin_Greek}, | |
| 1275 {1 << 4, FX_CHARSET_MSWin_Turkish}, | |
| 1276 {1 << 5, FX_CHARSET_MSWin_Hebrew}, | |
| 1277 {1 << 6, FX_CHARSET_MSWin_Arabic}, | |
| 1278 {1 << 7, FX_CHARSET_MSWin_Baltic}, | |
| 1279 {1 << 8, FX_CHARSET_MSWin_Vietnamese}, | |
| 1280 {1 << 9, FX_CHARSET_Default}, | |
| 1281 {1 << 10, FX_CHARSET_Default}, | |
| 1282 {1 << 11, FX_CHARSET_Default}, | |
| 1283 {1 << 12, FX_CHARSET_Default}, | |
| 1284 {1 << 13, FX_CHARSET_Default}, | |
| 1285 {1 << 14, FX_CHARSET_Default}, | |
| 1286 {1 << 15, FX_CHARSET_Default}, | |
| 1287 }; | |
| 1288 | |
| 1289 FX_BIT2CHARSET g_FX_Bit2Charset2[16] = { | |
| 1290 {1 << 0, FX_CHARSET_Thai}, | |
| 1291 {1 << 1, FX_CHARSET_ShiftJIS}, | |
| 1292 {1 << 2, FX_CHARSET_ChineseSimplified}, | |
| 1293 {1 << 3, FX_CHARSET_Korean}, | |
| 1294 {1 << 4, FX_CHARSET_ChineseTriditional}, | |
| 1295 {1 << 5, FX_CHARSET_Johab}, | |
| 1296 {1 << 6, FX_CHARSET_Default}, | |
| 1297 {1 << 7, FX_CHARSET_Default}, | |
| 1298 {1 << 8, FX_CHARSET_Default}, | |
| 1299 {1 << 9, FX_CHARSET_Default}, | |
| 1300 {1 << 10, FX_CHARSET_Default}, | |
| 1301 {1 << 11, FX_CHARSET_Default}, | |
| 1302 {1 << 12, FX_CHARSET_Default}, | |
| 1303 {1 << 13, FX_CHARSET_Default}, | |
| 1304 {1 << 14, FX_CHARSET_OEM}, | |
| 1305 {1 << 15, FX_CHARSET_Symbol}, | |
| 1306 }; | |
| 1307 | |
| 1308 FX_BIT2CHARSET g_FX_Bit2Charset3[16] = { | |
| 1309 {1 << 0, FX_CHARSET_Default}, {1 << 1, FX_CHARSET_Default}, | |
| 1310 {1 << 2, FX_CHARSET_Default}, {1 << 3, FX_CHARSET_Default}, | |
| 1311 {1 << 4, FX_CHARSET_Default}, {1 << 5, FX_CHARSET_Default}, | |
| 1312 {1 << 6, FX_CHARSET_Default}, {1 << 7, FX_CHARSET_Default}, | |
| 1313 {1 << 8, FX_CHARSET_Default}, {1 << 9, FX_CHARSET_Default}, | |
| 1314 {1 << 10, FX_CHARSET_Default}, {1 << 11, FX_CHARSET_Default}, | |
| 1315 {1 << 12, FX_CHARSET_Default}, {1 << 13, FX_CHARSET_Default}, | |
| 1316 {1 << 14, FX_CHARSET_Default}, {1 << 15, FX_CHARSET_Default}, | |
| 1317 }; | |
| 1318 | |
| 1319 FX_BIT2CHARSET g_FX_Bit2Charset4[16] = { | |
| 1320 {1 << 0, FX_CHARSET_Default}, {1 << 1, FX_CHARSET_Default}, | |
| 1321 {1 << 2, FX_CHARSET_Default}, {1 << 3, FX_CHARSET_Default}, | |
| 1322 {1 << 4, FX_CHARSET_Default}, {1 << 5, FX_CHARSET_Default}, | |
| 1323 {1 << 6, FX_CHARSET_Default}, {1 << 7, FX_CHARSET_Default}, | |
| 1324 {1 << 8, FX_CHARSET_Default}, {1 << 9, FX_CHARSET_Default}, | |
| 1325 {1 << 10, FX_CHARSET_Default}, {1 << 11, FX_CHARSET_Default}, | |
| 1326 {1 << 12, FX_CHARSET_Default}, {1 << 13, FX_CHARSET_Default}, | |
| 1327 {1 << 14, FX_CHARSET_Default}, {1 << 15, FX_CHARSET_US}, | |
| 1328 }; | |
| 1329 | |
| 1330 #define CODEPAGERANGE_IMPLEMENT(n) \ | 1229 #define CODEPAGERANGE_IMPLEMENT(n) \ |
| 1331 for (int32_t i = 0; i < 16; i++) { \ | 1230 for (int32_t i = 0; i < 16; i++) { \ |
| 1332 if ((a##n & g_FX_Bit2Charset##n[i].wBit) != 0) \ | 1231 if ((a##n & g_FX_Bit2Charset##n[i].wBit) != 0) \ |
| 1333 charsets.push_back(g_FX_Bit2Charset##n[i].wCharset); \ | 1232 charsets.push_back(g_FX_Bit2Charset##n[i].wCharset); \ |
| 1334 } | 1233 } |
| 1335 | 1234 |
| 1336 std::vector<uint16_t> CFGAS_FontMgrImp::GetCharsets(FXFT_Face pFace) const { | 1235 std::vector<uint16_t> CFGAS_FontMgr::GetCharsets(FXFT_Face pFace) const { |
| 1337 std::vector<uint16_t> charsets; | 1236 std::vector<uint16_t> charsets; |
| 1338 TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2); | 1237 TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2); |
| 1339 if (pOS2) { | 1238 if (pOS2) { |
| 1340 uint16_t a1 = pOS2->ulCodePageRange1 & 0xffff; | 1239 uint16_t a1 = pOS2->ulCodePageRange1 & 0xffff; |
| 1341 CODEPAGERANGE_IMPLEMENT(1); | 1240 CODEPAGERANGE_IMPLEMENT(1); |
| 1342 uint16_t a2 = (pOS2->ulCodePageRange1 >> 16) & 0xffff; | 1241 uint16_t a2 = (pOS2->ulCodePageRange1 >> 16) & 0xffff; |
| 1343 CODEPAGERANGE_IMPLEMENT(2); | 1242 CODEPAGERANGE_IMPLEMENT(2); |
| 1344 uint16_t a3 = pOS2->ulCodePageRange2 & 0xffff; | 1243 uint16_t a3 = pOS2->ulCodePageRange2 & 0xffff; |
| 1345 CODEPAGERANGE_IMPLEMENT(3); | 1244 CODEPAGERANGE_IMPLEMENT(3); |
| 1346 uint16_t a4 = (pOS2->ulCodePageRange2 >> 16) & 0xffff; | 1245 uint16_t a4 = (pOS2->ulCodePageRange2 >> 16) & 0xffff; |
| 1347 CODEPAGERANGE_IMPLEMENT(4); | 1246 CODEPAGERANGE_IMPLEMENT(4); |
| 1348 } else { | 1247 } else { |
| 1349 charsets.push_back(FX_CHARSET_Default); | 1248 charsets.push_back(FX_CHARSET_Default); |
| 1350 } | 1249 } |
| 1351 return charsets; | 1250 return charsets; |
| 1352 } | 1251 } |
| 1353 | 1252 |
| 1354 #undef CODEPAGERANGE_IMPLEMENT | 1253 #undef CODEPAGERANGE_IMPLEMENT |
| 1355 void CFGAS_FontMgrImp::GetUSBCSB(FXFT_Face pFace, | 1254 |
| 1356 uint32_t* USB, | 1255 void CFGAS_FontMgr::GetUSBCSB(FXFT_Face pFace, uint32_t* USB, uint32_t* CSB) { |
| 1357 uint32_t* CSB) { | |
| 1358 TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2); | 1256 TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2); |
| 1359 if (pOS2) { | 1257 if (pOS2) { |
| 1360 USB[0] = pOS2->ulUnicodeRange1; | 1258 USB[0] = pOS2->ulUnicodeRange1; |
| 1361 USB[1] = pOS2->ulUnicodeRange2; | 1259 USB[1] = pOS2->ulUnicodeRange2; |
| 1362 USB[2] = pOS2->ulUnicodeRange3; | 1260 USB[2] = pOS2->ulUnicodeRange3; |
| 1363 USB[3] = pOS2->ulUnicodeRange4; | 1261 USB[3] = pOS2->ulUnicodeRange4; |
| 1364 CSB[0] = pOS2->ulCodePageRange1; | 1262 CSB[0] = pOS2->ulCodePageRange1; |
| 1365 CSB[1] = pOS2->ulCodePageRange2; | 1263 CSB[1] = pOS2->ulCodePageRange2; |
| 1366 } else { | 1264 } else { |
| 1367 USB[0] = 0; | 1265 USB[0] = 0; |
| 1368 USB[1] = 0; | 1266 USB[1] = 0; |
| 1369 USB[2] = 0; | 1267 USB[2] = 0; |
| 1370 USB[3] = 0; | 1268 USB[3] = 0; |
| 1371 CSB[0] = 0; | 1269 CSB[0] = 0; |
| 1372 CSB[1] = 0; | 1270 CSB[1] = 0; |
| 1373 } | 1271 } |
| 1374 } | 1272 } |
| 1375 | 1273 |
| 1376 int32_t CFGAS_FontMgrImp::IsPartName(const CFX_WideString& Name1, | 1274 int32_t CFGAS_FontMgr::IsPartName(const CFX_WideString& Name1, |
| 1377 const CFX_WideString& Name2) { | 1275 const CFX_WideString& Name2) { |
| 1378 if (Name1.Find(Name2.c_str()) != -1) { | 1276 if (Name1.Find(Name2.c_str()) != -1) |
| 1379 return 1; | 1277 return 1; |
| 1380 } | |
| 1381 return 0; | 1278 return 0; |
| 1382 } | 1279 } |
| 1383 | 1280 |
| 1384 #endif | 1281 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| OLD | NEW |