LibWeb: Consider last resort font in font list

Getting the first font in a font cascade list with an empty font list
results in an OOTB index error. If the font list is empty, the last
resort font should be returned instead.
This commit is contained in:
Kuba314 2024-09-08 11:46:40 +02:00 committed by Alexander Kalenik
parent b3f77e4769
commit f3a6a589c8
Notes: github-actions[bot] 2024-09-08 11:44:09 +00:00

View file

@ -20,7 +20,7 @@ public:
size_t size() const { return m_fonts.size(); }
bool is_empty() const { return m_fonts.is_empty() && !m_last_resort_font; }
Font const& first() const { return *m_fonts.first().font; }
Font const& first() const { return !m_fonts.is_empty() ? *m_fonts.first().font : *m_last_resort_font; }
template<typename Callback>
void for_each_font_entry(Callback callback) const