| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 } | 447 } |
| 448 } | 448 } |
| 449 m_RefCount--; | 449 m_RefCount--; |
| 450 if (m_RefCount) { | 450 if (m_RefCount) { |
| 451 return m_RefCount; | 451 return m_RefCount; |
| 452 } | 452 } |
| 453 delete this; | 453 delete this; |
| 454 return 0; | 454 return 0; |
| 455 } | 455 } |
| 456 | 456 |
| 457 CFX_FontMgr::CFX_FontMgr() : m_FTLibrary(nullptr) { | 457 CFX_FontMgr::CFX_FontMgr() |
| 458 : m_FTLibrary(nullptr), m_FTLibrarySupportsHinting(false) { |
| 458 m_pBuiltinMapper.reset(new CFX_FontMapper(this)); | 459 m_pBuiltinMapper.reset(new CFX_FontMapper(this)); |
| 459 } | 460 } |
| 460 | 461 |
| 461 CFX_FontMgr::~CFX_FontMgr() { | 462 CFX_FontMgr::~CFX_FontMgr() { |
| 462 for (const auto& pair : m_FaceMap) | 463 for (const auto& pair : m_FaceMap) |
| 463 delete pair.second; | 464 delete pair.second; |
| 464 | 465 |
| 465 // |m_pBuiltinMapper| references |m_FTLibrary|, so it has to be destroyed | 466 // |m_pBuiltinMapper| references |m_FTLibrary|, so it has to be destroyed |
| 466 // first. | 467 // first. |
| 467 m_pBuiltinMapper.reset(); | 468 m_pBuiltinMapper.reset(); |
| 468 FXFT_Done_FreeType(m_FTLibrary); | 469 FXFT_Done_FreeType(m_FTLibrary); |
| 469 } | 470 } |
| 470 | 471 |
| 471 void CFX_FontMgr::InitFTLibrary() { | 472 void CFX_FontMgr::InitFTLibrary() { |
| 472 if (m_FTLibrary) | 473 if (m_FTLibrary) |
| 473 return; | 474 return; |
| 474 FXFT_Init_FreeType(&m_FTLibrary); | 475 FXFT_Init_FreeType(&m_FTLibrary); |
| 476 m_FTLibrarySupportsHinting = |
| 477 FXFT_Library_SetLcdFilter(m_FTLibrary, FT_LCD_FILTER_DEFAULT) != |
| 478 FT_Err_Unimplemented_Feature; |
| 475 } | 479 } |
| 476 | 480 |
| 477 void CFX_FontMgr::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) { | 481 void CFX_FontMgr::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) { |
| 478 m_pBuiltinMapper->SetSystemFontInfo(pFontInfo); | 482 m_pBuiltinMapper->SetSystemFontInfo(pFontInfo); |
| 479 } | 483 } |
| 480 | 484 |
| 481 FXFT_Face CFX_FontMgr::FindSubstFont(const CFX_ByteString& face_name, | 485 FXFT_Face CFX_FontMgr::FindSubstFont(const CFX_ByteString& face_name, |
| 482 FX_BOOL bTrueType, | 486 FX_BOOL bTrueType, |
| 483 uint32_t flags, | 487 uint32_t flags, |
| 484 int weight, | 488 int weight, |
| (...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1647 int PDF_GetStandardFontName(CFX_ByteString* name) { | 1651 int PDF_GetStandardFontName(CFX_ByteString* name) { |
| 1648 AltFontName* found = static_cast<AltFontName*>( | 1652 AltFontName* found = static_cast<AltFontName*>( |
| 1649 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), | 1653 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), |
| 1650 sizeof(AltFontName), CompareString)); | 1654 sizeof(AltFontName), CompareString)); |
| 1651 if (!found) | 1655 if (!found) |
| 1652 return -1; | 1656 return -1; |
| 1653 | 1657 |
| 1654 *name = g_Base14FontNames[found->m_Index]; | 1658 *name = g_Base14FontNames[found->m_Index]; |
| 1655 return found->m_Index; | 1659 return found->m_Index; |
| 1656 } | 1660 } |
| OLD | NEW |