2020-01-18 11:38:21 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 11:38:21 +03:00
|
|
|
*/
|
|
|
|
|
2022-04-09 10:28:38 +03:00
|
|
|
#include <LibGfx/Font/Font.h>
|
2020-03-07 12:32:51 +03:00
|
|
|
#include <LibWeb/FontCache.h>
|
2019-10-19 00:02:10 +03:00
|
|
|
|
|
|
|
FontCache& FontCache::the()
|
|
|
|
{
|
|
|
|
static FontCache cache;
|
|
|
|
return cache;
|
|
|
|
}
|
|
|
|
|
2022-04-01 20:58:27 +03:00
|
|
|
RefPtr<Gfx::Font> FontCache::get(FontSelector const& font_selector) const
|
2019-10-19 00:02:10 +03:00
|
|
|
{
|
|
|
|
auto cached_font = m_fonts.get(font_selector);
|
|
|
|
if (cached_font.has_value())
|
|
|
|
return cached_font.value();
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2022-04-01 20:58:27 +03:00
|
|
|
void FontCache::set(FontSelector const& font_selector, NonnullRefPtr<Gfx::Font> font)
|
2019-10-19 00:02:10 +03:00
|
|
|
{
|
|
|
|
m_fonts.set(font_selector, move(font));
|
|
|
|
}
|