diff --git a/Userland/Libraries/LibGfx/Font/TypefaceSkia.cpp b/Userland/Libraries/LibGfx/Font/TypefaceSkia.cpp index b568194820e..293eb7e9456 100644 --- a/Userland/Libraries/LibGfx/Font/TypefaceSkia.cpp +++ b/Userland/Libraries/LibGfx/Font/TypefaceSkia.cpp @@ -116,9 +116,12 @@ void TypefaceSkia::populate_glyph_page(GlyphPage& glyph_page, size_t page_index) String TypefaceSkia::family() const { - SkString family_name; - impl().skia_typeface->getFamilyName(&family_name); - return String::from_utf8_without_validation(ReadonlyBytes { family_name.c_str(), family_name.size() }); + if (!m_family.has_value()) { + SkString family_name; + impl().skia_typeface->getFamilyName(&family_name); + m_family = String::from_utf8_without_validation(ReadonlyBytes { family_name.c_str(), family_name.size() }); + } + return m_family.value(); } u16 TypefaceSkia::weight() const diff --git a/Userland/Libraries/LibGfx/Font/TypefaceSkia.h b/Userland/Libraries/LibGfx/Font/TypefaceSkia.h index e4b7312db4f..567857c2109 100644 --- a/Userland/Libraries/LibGfx/Font/TypefaceSkia.h +++ b/Userland/Libraries/LibGfx/Font/TypefaceSkia.h @@ -39,6 +39,8 @@ private: ReadonlyBytes m_buffer; unsigned m_ttc_index { 0 }; + mutable Optional m_family; + // This cache stores information per code point. // It's segmented into pages with data about 256 code points each. struct GlyphPage {