Serenity Operating System
at master 27 lines 622 B view raw
1/* 2 * Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#include <LibGfx/Font/Font.h> 8#include <LibWeb/FontCache.h> 9 10FontCache& FontCache::the() 11{ 12 static FontCache cache; 13 return cache; 14} 15 16RefPtr<Gfx::Font const> FontCache::get(FontSelector const& font_selector) const 17{ 18 auto cached_font = m_fonts.get(font_selector); 19 if (cached_font.has_value()) 20 return cached_font.value(); 21 return nullptr; 22} 23 24void FontCache::set(FontSelector const& font_selector, NonnullRefPtr<Gfx::Font const> font) 25{ 26 m_fonts.set(font_selector, move(font)); 27}