Chromium Code Reviews| 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() : m_FTLibrary(nullptr) { |
|
Lei Zhang
2016/05/17 18:30:54
Can you initialize |m_FTLibrarySupportsHinting| to
Tom (Use chromium acct)
2016/05/17 19:06:37
Done.
| |
| 458 m_pBuiltinMapper.reset(new CFX_FontMapper(this)); | 458 m_pBuiltinMapper.reset(new CFX_FontMapper(this)); |
| 459 } | 459 } |
| 460 | 460 |
| 461 CFX_FontMgr::~CFX_FontMgr() { | 461 CFX_FontMgr::~CFX_FontMgr() { |
| 462 for (const auto& pair : m_FaceMap) | 462 for (const auto& pair : m_FaceMap) |
| 463 delete pair.second; | 463 delete pair.second; |
| 464 | 464 |
| 465 // |m_pBuiltinMapper| references |m_FTLibrary|, so it has to be destroyed | 465 // |m_pBuiltinMapper| references |m_FTLibrary|, so it has to be destroyed |
| 466 // first. | 466 // first. |
| 467 m_pBuiltinMapper.reset(); | 467 m_pBuiltinMapper.reset(); |
| 468 FXFT_Done_FreeType(m_FTLibrary); | 468 FXFT_Done_FreeType(m_FTLibrary); |
| 469 } | 469 } |
| 470 | 470 |
| 471 void CFX_FontMgr::InitFTLibrary() { | 471 void CFX_FontMgr::InitFTLibrary() { |
| 472 if (m_FTLibrary) | 472 if (m_FTLibrary) |
| 473 return; | 473 return; |
| 474 FXFT_Init_FreeType(&m_FTLibrary); | 474 FXFT_Init_FreeType(&m_FTLibrary); |
| 475 m_FTLibrarySupportsHinting = | |
| 476 FXFT_Library_SetLcdFilter(m_FTLibrary, FT_LCD_FILTER_DEFAULT) != | |
| 477 FT_Err_Unimplemented_Feature; | |
| 475 } | 478 } |
| 476 | 479 |
| 477 void CFX_FontMgr::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) { | 480 void CFX_FontMgr::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) { |
| 478 m_pBuiltinMapper->SetSystemFontInfo(pFontInfo); | 481 m_pBuiltinMapper->SetSystemFontInfo(pFontInfo); |
| 479 } | 482 } |
| 480 | 483 |
| 481 FXFT_Face CFX_FontMgr::FindSubstFont(const CFX_ByteString& face_name, | 484 FXFT_Face CFX_FontMgr::FindSubstFont(const CFX_ByteString& face_name, |
| 482 FX_BOOL bTrueType, | 485 FX_BOOL bTrueType, |
| 483 uint32_t flags, | 486 uint32_t flags, |
| 484 int weight, | 487 int weight, |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 641 } | 644 } |
| 642 index -= FX_ArraySize(g_FoxitFonts); | 645 index -= FX_ArraySize(g_FoxitFonts); |
| 643 if (index < FX_ArraySize(g_MMFonts)) { | 646 if (index < FX_ArraySize(g_MMFonts)) { |
| 644 *pFontData = g_MMFonts[index].m_pFontData; | 647 *pFontData = g_MMFonts[index].m_pFontData; |
| 645 *size = g_MMFonts[index].m_dwSize; | 648 *size = g_MMFonts[index].m_dwSize; |
| 646 return true; | 649 return true; |
| 647 } | 650 } |
| 648 return false; | 651 return false; |
| 649 } | 652 } |
| 650 | 653 |
| 654 bool CFX_FontMgr::FTLibrarySupportsHinting() const { | |
| 655 if (!m_FTLibrary) | |
|
Lei Zhang
2016/05/17 18:30:54
And don't worry about this.
Tom (Use chromium acct)
2016/05/17 19:06:37
Done.
| |
| 656 return false; | |
| 657 return m_FTLibrarySupportsHinting; | |
| 658 } | |
| 659 | |
| 651 CFX_FontMapper::CFX_FontMapper(CFX_FontMgr* mgr) | 660 CFX_FontMapper::CFX_FontMapper(CFX_FontMgr* mgr) |
| 652 : m_bListLoaded(FALSE), | 661 : m_bListLoaded(FALSE), |
| 653 m_pFontInfo(nullptr), | 662 m_pFontInfo(nullptr), |
| 654 m_pFontMgr(mgr) { | 663 m_pFontMgr(mgr) { |
| 655 m_MMFaces[0] = nullptr; | 664 m_MMFaces[0] = nullptr; |
| 656 m_MMFaces[1] = nullptr; | 665 m_MMFaces[1] = nullptr; |
| 657 FXSYS_memset(m_FoxitFaces, 0, sizeof(m_FoxitFaces)); | 666 FXSYS_memset(m_FoxitFaces, 0, sizeof(m_FoxitFaces)); |
| 658 } | 667 } |
| 659 CFX_FontMapper::~CFX_FontMapper() { | 668 CFX_FontMapper::~CFX_FontMapper() { |
| 660 for (size_t i = 0; i < FX_ArraySize(m_FoxitFaces); ++i) { | 669 for (size_t i = 0; i < FX_ArraySize(m_FoxitFaces); ++i) { |
| (...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1647 int PDF_GetStandardFontName(CFX_ByteString* name) { | 1656 int PDF_GetStandardFontName(CFX_ByteString* name) { |
| 1648 AltFontName* found = static_cast<AltFontName*>( | 1657 AltFontName* found = static_cast<AltFontName*>( |
| 1649 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), | 1658 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), |
| 1650 sizeof(AltFontName), CompareString)); | 1659 sizeof(AltFontName), CompareString)); |
| 1651 if (!found) | 1660 if (!found) |
| 1652 return -1; | 1661 return -1; |
| 1653 | 1662 |
| 1654 *name = g_Base14FontNames[found->m_Index]; | 1663 *name = g_Base14FontNames[found->m_Index]; |
| 1655 return found->m_Index; | 1664 return found->m_Index; |
| 1656 } | 1665 } |
| OLD | NEW |