1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:27:44 +00:00

LibWeb: Honor font-weight and font-style when using downloaded fonts

Instead of keying downloaded @font-face fonts on just the family name,
we now key them on a tuple of the family name, weight and slope.
This commit is contained in:
Andreas Kling 2023-05-24 15:35:30 +02:00
parent 74bdbdf43f
commit 38b2cba6a2
2 changed files with 34 additions and 4 deletions

View file

@ -47,6 +47,15 @@ private:
bool m_marked { false };
};
struct FontFaceKey {
FlyString family_name;
int weight { 0 };
int slope { 0 };
[[nodiscard]] u32 hash() const { return pair_int_hash(family_name.hash(), pair_int_hash(weight, slope)); }
[[nodiscard]] bool operator==(FontFaceKey const&) const = default;
};
class StyleComputer {
public:
explicit StyleComputer(DOM::Document&);
@ -132,7 +141,7 @@ private:
OwnPtr<RuleCache> m_user_agent_rule_cache;
class FontLoader;
HashMap<String, NonnullOwnPtr<FontLoader>> m_loaded_fonts;
HashMap<FontFaceKey, NonnullOwnPtr<FontLoader>> m_loaded_fonts;
Length::FontMetrics m_default_font_metrics;
Length::FontMetrics m_root_element_font_metrics;