blob: 2278e534b88aca3902a5af24f0402c2a53f1db5d [file] [log] [blame]
// 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.
#include "core/fxge/cfx_fontcache.h"
#include <memory>
#include <utility>
#include "core/fxge/cfx_font.h"
#include "core/fxge/cfx_glyphcache.h"
#include "core/fxge/fx_font.h"
#include "core/fxge/fx_freetype.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);
return new_cache;
CFX_TypeFace* CFX_FontCache::GetDeviceCache(const CFX_Font* pFont) {
return GetGlyphCache(pFont)->GetDeviceCache(pFont);