FontCache.cpp 480 B

123456789101112131415161718192021
  1. #include <LibDraw/Font.h>
  2. #include <LibHTML/FontCache.h>
  3. FontCache& FontCache::the()
  4. {
  5. static FontCache cache;
  6. return cache;
  7. }
  8. RefPtr<Font> FontCache::get(const FontSelector& font_selector) const
  9. {
  10. auto cached_font = m_fonts.get(font_selector);
  11. if (cached_font.has_value())
  12. return cached_font.value();
  13. return nullptr;
  14. }
  15. void FontCache::set(const FontSelector& font_selector, NonnullRefPtr<Font> font)
  16. {
  17. m_fonts.set(font_selector, move(font));
  18. }