| 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 #include "xfa/fgas/font/fgas_stdfontmgr.h" | 7 #include "xfa/fgas/font/fgas_stdfontmgr.h" |
| 8 | 8 |
| 9 #include "core/fxcrt/include/fx_stream.h" | 9 #include "core/fxcrt/include/fx_stream.h" |
| 10 #include "core/fxge/include/fx_ge.h" |
| 10 #include "xfa/fgas/crt/fgas_codepage.h" | 11 #include "xfa/fgas/crt/fgas_codepage.h" |
| 11 #include "xfa/fgas/font/fgas_fontutils.h" | 12 #include "xfa/fgas/font/fgas_fontutils.h" |
| 12 | 13 |
| 13 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 14 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 14 IFX_FontMgr* IFX_FontMgr::Create(FX_LPEnumAllFonts pEnumerator) { | 15 IFX_FontMgr* IFX_FontMgr::Create(FX_LPEnumAllFonts pEnumerator) { |
| 15 return new CFX_StdFontMgrImp(pEnumerator); | 16 return new CFX_StdFontMgrImp(pEnumerator); |
| 16 } | 17 } |
| 17 CFX_StdFontMgrImp::CFX_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator) | 18 CFX_StdFontMgrImp::CFX_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator) |
| 18 : m_pEnumerator(pEnumerator), | 19 : m_pEnumerator(pEnumerator), |
| 19 m_FontFaces(), | 20 m_FontFaces(), |
| 20 m_CPFonts(8), | 21 m_CPFonts(8), |
| 21 m_FamilyFonts(16), | 22 m_FamilyFonts(16), |
| 22 m_UnicodeFonts(16), | 23 m_UnicodeFonts(16), |
| 23 m_BufferFonts(4), | 24 m_BufferFonts(4), |
| 24 m_FileFonts(4), | 25 m_FileFonts(4), |
| 25 m_StreamFonts(4), | 26 m_StreamFonts(4), |
| 26 m_DeriveFonts(4) { | 27 m_DeriveFonts(4) { |
| 27 if (m_pEnumerator != NULL) { | 28 if (m_pEnumerator) { |
| 28 m_pEnumerator(m_FontFaces, NULL, 0xFEFF); | 29 m_pEnumerator(m_FontFaces, NULL, 0xFEFF); |
| 29 } | 30 } |
| 30 } | 31 } |
| 31 | 32 |
| 32 CFX_StdFontMgrImp::~CFX_StdFontMgrImp() { | 33 CFX_StdFontMgrImp::~CFX_StdFontMgrImp() { |
| 33 m_FontFaces.RemoveAll(); | 34 m_FontFaces.RemoveAll(); |
| 34 m_CPFonts.RemoveAll(); | 35 m_CPFonts.RemoveAll(); |
| 35 m_FamilyFonts.RemoveAll(); | 36 m_FamilyFonts.RemoveAll(); |
| 36 m_UnicodeFonts.RemoveAll(); | 37 m_UnicodeFonts.RemoveAll(); |
| 37 m_BufferFonts.RemoveAll(); | 38 m_BufferFonts.RemoveAll(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 51 if (m_CPFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { | 52 if (m_CPFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { |
| 52 return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : NULL; | 53 return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : NULL; |
| 53 } | 54 } |
| 54 FX_FONTDESCRIPTOR const* pFD; | 55 FX_FONTDESCRIPTOR const* pFD; |
| 55 if ((pFD = FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage)) == NULL) { | 56 if ((pFD = FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage)) == NULL) { |
| 56 if ((pFD = FindFont(NULL, dwFontStyles, TRUE, wCodePage)) == NULL) { | 57 if ((pFD = FindFont(NULL, dwFontStyles, TRUE, wCodePage)) == NULL) { |
| 57 if ((pFD = FindFont(NULL, dwFontStyles, FALSE, wCodePage)) == NULL) | 58 if ((pFD = FindFont(NULL, dwFontStyles, FALSE, wCodePage)) == NULL) |
| 58 return NULL; | 59 return NULL; |
| 59 } | 60 } |
| 60 } | 61 } |
| 61 ASSERT(pFD != NULL); | 62 ASSERT(pFD); |
| 62 pFont = IFX_Font::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); | 63 pFont = IFX_Font::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); |
| 63 if (pFont) { | 64 if (pFont) { |
| 64 m_Fonts.Add(pFont); | 65 m_Fonts.Add(pFont); |
| 65 m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 66 m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 66 dwHash = FGAS_GetFontFamilyHash(pFD->wsFontFace, dwFontStyles, wCodePage); | 67 dwHash = FGAS_GetFontFamilyHash(pFD->wsFontFace, dwFontStyles, wCodePage); |
| 67 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 68 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 68 return LoadFont(pFont, dwFontStyles, wCodePage); | 69 return LoadFont(pFont, dwFontStyles, wCodePage); |
| 69 } | 70 } |
| 70 return NULL; | 71 return NULL; |
| 71 } | 72 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { | 133 if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { |
| 133 return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : NULL; | 134 return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : NULL; |
| 134 } | 135 } |
| 135 FX_FONTDESCRIPTOR const* pFD = NULL; | 136 FX_FONTDESCRIPTOR const* pFD = NULL; |
| 136 if ((pFD = FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage)) == NULL) { | 137 if ((pFD = FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage)) == NULL) { |
| 137 if ((pFD = FindFont(pszFontFamily, dwFontStyles, FALSE, wCodePage)) == | 138 if ((pFD = FindFont(pszFontFamily, dwFontStyles, FALSE, wCodePage)) == |
| 138 NULL) { | 139 NULL) { |
| 139 return NULL; | 140 return NULL; |
| 140 } | 141 } |
| 141 } | 142 } |
| 142 ASSERT(pFD != NULL); | 143 ASSERT(pFD); |
| 143 if (wCodePage == 0xFFFF) { | 144 if (wCodePage == 0xFFFF) { |
| 144 wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet); | 145 wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet); |
| 145 } | 146 } |
| 146 pFont = IFX_Font::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); | 147 pFont = IFX_Font::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); |
| 147 if (pFont) { | 148 if (pFont) { |
| 148 m_Fonts.Add(pFont); | 149 m_Fonts.Add(pFont); |
| 149 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 150 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 150 dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); | 151 dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); |
| 151 m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 152 m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 152 return LoadFont(pFont, dwFontStyles, wCodePage); | 153 return LoadFont(pFont, dwFontStyles, wCodePage); |
| 153 } | 154 } |
| 154 return NULL; | 155 return NULL; |
| 155 } | 156 } |
| 156 IFX_Font* CFX_StdFontMgrImp::LoadFont(const uint8_t* pBuffer, int32_t iLength) { | 157 IFX_Font* CFX_StdFontMgrImp::LoadFont(const uint8_t* pBuffer, int32_t iLength) { |
| 157 ASSERT(pBuffer != NULL && iLength > 0); | 158 ASSERT(pBuffer && iLength > 0); |
| 158 IFX_Font* pFont = NULL; | 159 IFX_Font* pFont = NULL; |
| 159 if (m_BufferFonts.Lookup((void*)pBuffer, (void*&)pFont)) { | 160 if (m_BufferFonts.Lookup((void*)pBuffer, (void*&)pFont)) { |
| 160 if (pFont != NULL) { | 161 if (pFont) { |
| 161 return pFont->Retain(); | 162 return pFont->Retain(); |
| 162 } | 163 } |
| 163 } | 164 } |
| 164 pFont = IFX_Font::LoadFont(pBuffer, iLength, this); | 165 pFont = IFX_Font::LoadFont(pBuffer, iLength, this); |
| 165 if (pFont) { | 166 if (pFont) { |
| 166 m_Fonts.Add(pFont); | 167 m_Fonts.Add(pFont); |
| 167 m_BufferFonts.SetAt((void*)pBuffer, pFont); | 168 m_BufferFonts.SetAt((void*)pBuffer, pFont); |
| 168 return pFont->Retain(); | 169 return pFont->Retain(); |
| 169 } | 170 } |
| 170 return NULL; | 171 return NULL; |
| 171 } | 172 } |
| 172 IFX_Font* CFX_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFileName) { | 173 IFX_Font* CFX_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFileName) { |
| 173 ASSERT(pszFileName != NULL); | 174 ASSERT(pszFileName); |
| 174 uint32_t dwHash = FX_HashCode_GetW(pszFileName, false); | 175 uint32_t dwHash = FX_HashCode_GetW(pszFileName, false); |
| 175 IFX_Font* pFont = NULL; | 176 IFX_Font* pFont = NULL; |
| 176 if (m_FileFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { | 177 if (m_FileFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { |
| 177 if (pFont != NULL) { | 178 if (pFont) { |
| 178 return pFont->Retain(); | 179 return pFont->Retain(); |
| 179 } | 180 } |
| 180 } | 181 } |
| 181 pFont = IFX_Font::LoadFont(pszFileName, NULL); | 182 pFont = IFX_Font::LoadFont(pszFileName, NULL); |
| 182 if (pFont) { | 183 if (pFont) { |
| 183 m_Fonts.Add(pFont); | 184 m_Fonts.Add(pFont); |
| 184 m_FileFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 185 m_FileFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 185 return pFont->Retain(); | 186 return pFont->Retain(); |
| 186 } | 187 } |
| 187 return NULL; | 188 return NULL; |
| 188 } | 189 } |
| 189 IFX_Font* CFX_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream, | 190 IFX_Font* CFX_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream, |
| 190 const FX_WCHAR* pszFontAlias, | 191 const FX_WCHAR* pszFontAlias, |
| 191 uint32_t dwFontStyles, | 192 uint32_t dwFontStyles, |
| 192 uint16_t wCodePage, | 193 uint16_t wCodePage, |
| 193 FX_BOOL bSaveStream) { | 194 FX_BOOL bSaveStream) { |
| 194 ASSERT(pFontStream != NULL && pFontStream->GetLength() > 0); | 195 ASSERT(pFontStream && pFontStream->GetLength() > 0); |
| 195 IFX_Font* pFont = NULL; | 196 IFX_Font* pFont = NULL; |
| 196 if (m_StreamFonts.Lookup((void*)pFontStream, (void*&)pFont)) { | 197 if (m_StreamFonts.Lookup((void*)pFontStream, (void*&)pFont)) { |
| 197 if (pFont != NULL) { | 198 if (pFont) { |
| 198 if (pszFontAlias != NULL) { | 199 if (pszFontAlias) { |
| 199 uint32_t dwHash = | 200 uint32_t dwHash = |
| 200 FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); | 201 FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); |
| 201 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 202 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 202 } | 203 } |
| 203 return LoadFont(pFont, dwFontStyles, wCodePage); | 204 return LoadFont(pFont, dwFontStyles, wCodePage); |
| 204 } | 205 } |
| 205 } | 206 } |
| 206 pFont = IFX_Font::LoadFont(pFontStream, this, bSaveStream); | 207 pFont = IFX_Font::LoadFont(pFontStream, this, bSaveStream); |
| 207 if (pFont) { | 208 if (pFont) { |
| 208 m_Fonts.Add(pFont); | 209 m_Fonts.Add(pFont); |
| 209 m_StreamFonts.SetAt((void*)pFontStream, (void*)pFont); | 210 m_StreamFonts.SetAt((void*)pFontStream, (void*)pFont); |
| 210 if (pszFontAlias != NULL) { | 211 if (pszFontAlias) { |
| 211 uint32_t dwHash = | 212 uint32_t dwHash = |
| 212 FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); | 213 FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); |
| 213 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 214 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 214 } | 215 } |
| 215 return LoadFont(pFont, dwFontStyles, wCodePage); | 216 return LoadFont(pFont, dwFontStyles, wCodePage); |
| 216 } | 217 } |
| 217 return NULL; | 218 return NULL; |
| 218 } | 219 } |
| 219 IFX_Font* CFX_StdFontMgrImp::LoadFont(IFX_Font* pSrcFont, | 220 IFX_Font* CFX_StdFontMgrImp::LoadFont(IFX_Font* pSrcFont, |
| 220 uint32_t dwFontStyles, | 221 uint32_t dwFontStyles, |
| 221 uint16_t wCodePage) { | 222 uint16_t wCodePage) { |
| 222 ASSERT(pSrcFont != NULL); | 223 ASSERT(pSrcFont); |
| 223 if (pSrcFont->GetFontStyles() == dwFontStyles) { | 224 if (pSrcFont->GetFontStyles() == dwFontStyles) { |
| 224 return pSrcFont->Retain(); | 225 return pSrcFont->Retain(); |
| 225 } | 226 } |
| 226 void* buffer[3] = {pSrcFont, (void*)(uintptr_t)dwFontStyles, | 227 void* buffer[3] = {pSrcFont, (void*)(uintptr_t)dwFontStyles, |
| 227 (void*)(uintptr_t)wCodePage}; | 228 (void*)(uintptr_t)wCodePage}; |
| 228 uint32_t dwHash = FX_HashCode_GetA( | 229 uint32_t dwHash = FX_HashCode_GetA( |
| 229 CFX_ByteStringC((uint8_t*)buffer, sizeof(buffer)), false); | 230 CFX_ByteStringC((uint8_t*)buffer, sizeof(buffer)), false); |
| 230 IFX_Font* pFont = NULL; | 231 IFX_Font* pFont = NULL; |
| 231 if (m_DeriveFonts.GetCount() > 0) { | 232 if (m_DeriveFonts.GetCount() > 0) { |
| 232 m_DeriveFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont); | 233 m_DeriveFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont); |
| 233 if (pFont != NULL) { | 234 if (pFont) { |
| 234 return pFont->Retain(); | 235 return pFont->Retain(); |
| 235 } | 236 } |
| 236 } | 237 } |
| 237 pFont = pSrcFont->Derive(dwFontStyles, wCodePage); | 238 pFont = pSrcFont->Derive(dwFontStyles, wCodePage); |
| 238 if (pFont) { | 239 if (pFont) { |
| 239 m_DeriveFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 240 m_DeriveFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
| 240 int32_t index = m_Fonts.Find(pFont); | 241 int32_t index = m_Fonts.Find(pFont); |
| 241 if (index < 0) { | 242 if (index < 0) { |
| 242 m_Fonts.Add(pFont); | 243 m_Fonts.Add(pFont); |
| 243 pFont->Retain(); | 244 pFont->Retain(); |
| 244 } | 245 } |
| 245 return pFont; | 246 return pFont; |
| 246 } | 247 } |
| 247 return NULL; | 248 return NULL; |
| 248 } | 249 } |
| 249 | 250 |
| 250 void CFX_StdFontMgrImp::ClearFontCache() { | 251 void CFX_StdFontMgrImp::ClearFontCache() { |
| 251 for (int32_t i = 0; i < m_Fonts.GetSize(); i++) | 252 for (int32_t i = 0; i < m_Fonts.GetSize(); i++) |
| 252 m_Fonts[i]->Reset(); | 253 m_Fonts[i]->Reset(); |
| 253 } | 254 } |
| 254 | 255 |
| 255 void CFX_StdFontMgrImp::RemoveFont(CFX_MapPtrToPtr& fontMap, IFX_Font* pFont) { | 256 void CFX_StdFontMgrImp::RemoveFont(CFX_MapPtrToPtr& fontMap, IFX_Font* pFont) { |
| 256 FX_POSITION pos = fontMap.GetStartPosition(); | 257 FX_POSITION pos = fontMap.GetStartPosition(); |
| 257 void* pKey; | 258 void* pKey; |
| 258 void* pFind; | 259 void* pFind; |
| 259 while (pos != NULL) { | 260 while (pos) { |
| 260 pFind = NULL; | 261 pFind = NULL; |
| 261 fontMap.GetNextAssoc(pos, pKey, pFind); | 262 fontMap.GetNextAssoc(pos, pKey, pFind); |
| 262 if (pFind != (void*)pFont) { | 263 if (pFind != (void*)pFont) { |
| 263 continue; | 264 continue; |
| 264 } | 265 } |
| 265 fontMap.RemoveKey(pKey); | 266 fontMap.RemoveKey(pKey); |
| 266 break; | 267 break; |
| 267 } | 268 } |
| 268 } | 269 } |
| 269 void CFX_StdFontMgrImp::RemoveFont(IFX_Font* pFont) { | 270 void CFX_StdFontMgrImp::RemoveFont(IFX_Font* pFont) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 } else { | 349 } else { |
| 349 if (pParams->dwUSB < 128) { | 350 if (pParams->dwUSB < 128) { |
| 350 uint32_t dwByte = pParams->dwUSB / 32; | 351 uint32_t dwByte = pParams->dwUSB / 32; |
| 351 uint32_t dwUSB = 1 << (pParams->dwUSB % 32); | 352 uint32_t dwUSB = 1 << (pParams->dwUSB % 32); |
| 352 if ((pFont->FontSignature.fsUsb[dwByte] & dwUSB) == 0) { | 353 if ((pFont->FontSignature.fsUsb[dwByte] & dwUSB) == 0) { |
| 353 continue; | 354 continue; |
| 354 } | 355 } |
| 355 } | 356 } |
| 356 } | 357 } |
| 357 if (bMatchStyle) { | 358 if (bMatchStyle) { |
| 358 if ((pFont->dwFontStyles & 0x0F) == (pParams->dwFontStyles & 0x0F)) { | 359 if ((pFont->dwFontStyles & 0x0F) == (pParams->dwFontStyles & 0x0F)) |
| 359 return pFont; | 360 return pFont; |
| 360 } else { | 361 continue; |
| 361 continue; | |
| 362 } | |
| 363 } | 362 } |
| 364 if (pParams->pwsFamily != NULL) { | 363 if (pParams->pwsFamily) { |
| 365 if (FXSYS_wcsicmp(pParams->pwsFamily, pFont->wsFontFace) == 0) { | 364 if (FXSYS_wcsicmp(pParams->pwsFamily, pFont->wsFontFace) == 0) { |
| 366 return pFont; | 365 return pFont; |
| 367 } | 366 } |
| 368 } | 367 } |
| 369 int32_t iSimilarValue = FX_GetSimilarValue(pFont, pParams->dwFontStyles); | 368 int32_t iSimilarValue = FX_GetSimilarValue(pFont, pParams->dwFontStyles); |
| 370 if (iBestSimilar < iSimilarValue) { | 369 if (iBestSimilar < iSimilarValue) { |
| 371 iBestSimilar = iSimilarValue; | 370 iBestSimilar = iSimilarValue; |
| 372 pBestFont = pFont; | 371 pBestFont = pFont; |
| 373 } | 372 } |
| 374 } | 373 } |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 IFX_FileAccess* pAccess = FX_CreateDefaultFileAccess(m_wsNext.AsStringC()); | 544 IFX_FileAccess* pAccess = FX_CreateDefaultFileAccess(m_wsNext.AsStringC()); |
| 546 m_wsNext = GetNextFile().UTF8Decode(); | 545 m_wsNext = GetNextFile().UTF8Decode(); |
| 547 pos = 0 != m_wsNext.GetLength() ? pAccess : NULL; | 546 pos = 0 != m_wsNext.GetLength() ? pAccess : NULL; |
| 548 return (IFX_FileAccess*)pAccess; | 547 return (IFX_FileAccess*)pAccess; |
| 549 } | 548 } |
| 550 | 549 |
| 551 IFX_FontMgr* IFX_FontMgr::Create(CFX_FontSourceEnum_File* pFontEnum) { | 550 IFX_FontMgr* IFX_FontMgr::Create(CFX_FontSourceEnum_File* pFontEnum) { |
| 552 if (!pFontEnum) | 551 if (!pFontEnum) |
| 553 return nullptr; | 552 return nullptr; |
| 554 | 553 |
| 555 CFX_FontMgrImp* pFontMgr = new CFX_FontMgrImp(pFontEnum); | 554 std::unique_ptr<CFX_FontMgrImp> pFontMgr(new CFX_FontMgrImp(pFontEnum)); |
| 556 if (pFontMgr->EnumFonts()) | 555 if (!pFontMgr->EnumFonts()) |
| 557 return pFontMgr; | 556 return nullptr; |
| 557 return pFontMgr.release(); |
| 558 } |
| 558 | 559 |
| 559 delete pFontMgr; | |
| 560 return nullptr; | |
| 561 } | |
| 562 CFX_FontMgrImp::CFX_FontMgrImp(CFX_FontSourceEnum_File* pFontEnum) | 560 CFX_FontMgrImp::CFX_FontMgrImp(CFX_FontSourceEnum_File* pFontEnum) |
| 563 : m_pFontSource(pFontEnum) {} | 561 : m_pFontSource(pFontEnum) {} |
| 564 | 562 |
| 563 CFX_FontMgrImp::~CFX_FontMgrImp() {} |
| 564 |
| 565 FX_BOOL CFX_FontMgrImp::EnumFontsFromFontMapper() { | 565 FX_BOOL CFX_FontMgrImp::EnumFontsFromFontMapper() { |
| 566 CFX_FontMapper* pFontMapper = | 566 CFX_FontMapper* pFontMapper = |
| 567 CFX_GEModule::Get()->GetFontMgr()->GetBuiltinMapper(); | 567 CFX_GEModule::Get()->GetFontMgr()->GetBuiltinMapper(); |
| 568 if (!pFontMapper) | 568 if (!pFontMapper) |
| 569 return FALSE; | 569 return FALSE; |
| 570 | 570 |
| 571 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); | 571 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); |
| 572 if (!pSystemFontInfo) | 572 if (!pSystemFontInfo) |
| 573 return FALSE; | 573 return FALSE; |
| 574 | 574 |
| (...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1486 } | 1486 } |
| 1487 } | 1487 } |
| 1488 int32_t CFX_FontMgrImp::IsPartName(const CFX_WideString& Name1, | 1488 int32_t CFX_FontMgrImp::IsPartName(const CFX_WideString& Name1, |
| 1489 const CFX_WideString& Name2) { | 1489 const CFX_WideString& Name2) { |
| 1490 if (Name1.Find(Name2.c_str()) != -1) { | 1490 if (Name1.Find(Name2.c_str()) != -1) { |
| 1491 return 1; | 1491 return 1; |
| 1492 } | 1492 } |
| 1493 return 0; | 1493 return 0; |
| 1494 } | 1494 } |
| 1495 #endif | 1495 #endif |
| OLD | NEW |