blob: 38a1795fbecce81a39f1e6e9bdd71f8903e29635 [file] [log] [blame] [edit]
// Copyright 2016 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "core/fxge/cfx_fontcache.h"
#include "core/fxge/cfx_font.h"
#include "core/fxge/cfx_glyphcache.h"
#include "core/fxge/freetype/fx_freetype.h"
#include "core/fxge/fx_font.h"
CFX_FontCache::CFX_FontCache() = default;
CFX_FontCache::~CFX_FontCache() = default;
RetainPtr<CFX_GlyphCache> CFX_FontCache::GetGlyphCache(const CFX_Font* pFont) {
RetainPtr<CFX_Face> face = pFont->GetFace();
const bool bExternal = !face;
auto& map = bExternal ? m_ExtGlyphCacheMap : m_GlyphCacheMap;
auto it = map.find(face.Get());
if (it != map.end() && it->second)
return pdfium::WrapRetain(it->second.Get());
auto new_cache = pdfium::MakeRetain<CFX_GlyphCache>(face);
map[face.Get()].Reset(new_cache.Get());
return new_cache;
}
#if defined(_SKIA_SUPPORT_)
CFX_TypeFace* CFX_FontCache::GetDeviceCache(const CFX_Font* pFont) {
return GetGlyphCache(pFont)->GetDeviceCache(pFont);
}
#endif