• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/fx_font.h"
12 
13 CFX_FontCache::CFX_FontCache() = default;
14 
15 CFX_FontCache::~CFX_FontCache() = default;
16 
GetGlyphCache(const CFX_Font * pFont)17 RetainPtr<CFX_GlyphCache> CFX_FontCache::GetGlyphCache(const CFX_Font* pFont) {
18   RetainPtr<CFX_Face> face = pFont->GetFace();
19   const bool bExternal = !face;
20   auto& map = bExternal ? m_ExtGlyphCacheMap : m_GlyphCacheMap;
21   auto it = map.find(face.Get());
22   if (it != map.end() && it->second)
23     return pdfium::WrapRetain(it->second.Get());
24 
25   auto new_cache = pdfium::MakeRetain<CFX_GlyphCache>(face);
26   map[face.Get()].Reset(new_cache.Get());
27   return new_cache;
28 }
29 
30 #if defined(PDF_USE_SKIA)
GetDeviceCache(const CFX_Font * pFont)31 CFX_TypeFace* CFX_FontCache::GetDeviceCache(const CFX_Font* pFont) {
32   return GetGlyphCache(pFont)->GetDeviceCache(pFont);
33 }
34 #endif
35