1 // Copyright 2016 The PDFium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #include "core/fxge/cfx_fontcache.h" 8 9 #include "core/fxge/cfx_font.h" 10 #include "core/fxge/cfx_glyphcache.h" 11 #include "core/fxge/freetype/fx_freetype.h" 12 #include "core/fxge/fx_font.h" 13 14 CFX_FontCache::CFX_FontCache() = default; 15 16 CFX_FontCache::~CFX_FontCache() = default; 17 GetGlyphCache(const CFX_Font * pFont)18RetainPtr<CFX_GlyphCache> CFX_FontCache::GetGlyphCache(const CFX_Font* pFont) { 19 RetainPtr<CFX_Face> face = pFont->GetFace(); 20 const bool bExternal = !face; 21 auto& map = bExternal ? m_ExtGlyphCacheMap : m_GlyphCacheMap; 22 auto it = map.find(face.Get()); 23 if (it != map.end() && it->second) 24 return pdfium::WrapRetain(it->second.Get()); 25 26 auto new_cache = pdfium::MakeRetain<CFX_GlyphCache>(face); 27 map[face.Get()].Reset(new_cache.Get()); 28 return new_cache; 29 } 30 31 #if defined(_SKIA_SUPPORT_) GetDeviceCache(const CFX_Font * pFont)32CFX_TypeFace* CFX_FontCache::GetDeviceCache(const CFX_Font* pFont) { 33 return GetGlyphCache(pFont)->GetDeviceCache(pFont); 34 } 35 #endif 36