| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/fxge/cfx_fontmgr.h" | 7 #include "core/fxge/cfx_fontmgr.h" |
| 8 | 8 |
| 9 #include "core/fxge/cfx_fontmapper.h" | 9 #include "core/fxge/cfx_fontmapper.h" |
| 10 #include "core/fxge/cfx_substfont.h" | 10 #include "core/fxge/cfx_substfont.h" |
| 11 #include "core/fxge/fontdata/chromefontdata/chromefontdata.h" | 11 #include "core/fxge/fontdata/chromefontdata/chromefontdata.h" |
| 12 #include "core/fxge/fx_font.h" | 12 #include "core/fxge/fx_font.h" |
| 13 #include "core/fxge/ge/cttfontdesc.h" | 13 #include "core/fxge/ge/cttfontdesc.h" |
| 14 #include "core/fxge/ifx_systemfontinfo.h" | 14 #include "core/fxge/ifx_systemfontinfo.h" |
| 15 #include "third_party/base/ptr_util.h" |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 struct BuiltinFont { | 19 struct BuiltinFont { |
| 19 const uint8_t* m_pFontData; | 20 const uint8_t* m_pFontData; |
| 20 uint32_t m_dwSize; | 21 uint32_t m_dwSize; |
| 21 }; | 22 }; |
| 22 | 23 |
| 23 const BuiltinFont g_FoxitFonts[14] = { | 24 const BuiltinFont g_FoxitFonts[14] = { |
| 24 {g_FoxitFixedFontData, 17597}, | 25 {g_FoxitFixedFontData, 17597}, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 face_index = 0; | 75 face_index = 0; |
| 75 else | 76 else |
| 76 face_index = index; | 77 face_index = index; |
| 77 return face_index; | 78 return face_index; |
| 78 } | 79 } |
| 79 | 80 |
| 80 } // namespace | 81 } // namespace |
| 81 | 82 |
| 82 CFX_FontMgr::CFX_FontMgr() | 83 CFX_FontMgr::CFX_FontMgr() |
| 83 : m_FTLibrary(nullptr), m_FTLibrarySupportsHinting(false) { | 84 : m_FTLibrary(nullptr), m_FTLibrarySupportsHinting(false) { |
| 84 m_pBuiltinMapper = WrapUnique(new CFX_FontMapper(this)); | 85 m_pBuiltinMapper = pdfium::MakeUnique<CFX_FontMapper>(this); |
| 85 } | 86 } |
| 86 | 87 |
| 87 CFX_FontMgr::~CFX_FontMgr() { | 88 CFX_FontMgr::~CFX_FontMgr() { |
| 88 for (const auto& pair : m_FaceMap) | 89 for (const auto& pair : m_FaceMap) |
| 89 delete pair.second; | 90 delete pair.second; |
| 90 | 91 |
| 91 // |m_pBuiltinMapper| references |m_FTLibrary|, so it has to be destroyed | 92 // |m_pBuiltinMapper| references |m_FTLibrary|, so it has to be destroyed |
| 92 // first. | 93 // first. |
| 93 m_pBuiltinMapper.reset(); | 94 m_pBuiltinMapper.reset(); |
| 94 FXFT_Done_FreeType(m_FTLibrary); | 95 FXFT_Done_FreeType(m_FTLibrary); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 return true; | 251 return true; |
| 251 } | 252 } |
| 252 index -= FX_ArraySize(g_FoxitFonts); | 253 index -= FX_ArraySize(g_FoxitFonts); |
| 253 if (index < FX_ArraySize(g_MMFonts)) { | 254 if (index < FX_ArraySize(g_MMFonts)) { |
| 254 *pFontData = g_MMFonts[index].m_pFontData; | 255 *pFontData = g_MMFonts[index].m_pFontData; |
| 255 *size = g_MMFonts[index].m_dwSize; | 256 *size = g_MMFonts[index].m_dwSize; |
| 256 return true; | 257 return true; |
| 257 } | 258 } |
| 258 return false; | 259 return false; |
| 259 } | 260 } |
| OLD | NEW |