mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:37:35 +00:00
LibWeb: Improvements to font lookup
Parse out the font-family, font-size and font-weight values from CSS and use them to perform a kinda-best-effort lookup against the system font library. We also now handle standard font names like "sans-serif", "monospace" and others.
This commit is contained in:
parent
861d22838d
commit
08517daa5a
5 changed files with 216 additions and 129 deletions
|
@ -33,18 +33,19 @@
|
|||
|
||||
struct FontSelector {
|
||||
FlyString family;
|
||||
FlyString weight;
|
||||
int size { 0 };
|
||||
int weight { 0 };
|
||||
|
||||
bool operator==(const FontSelector& other) const
|
||||
{
|
||||
return family == other.family && weight == other.weight;
|
||||
return family == other.family && size == other.size && weight == other.weight;
|
||||
}
|
||||
};
|
||||
|
||||
namespace AK {
|
||||
template<>
|
||||
struct Traits<FontSelector> : public GenericTraits<FontSelector> {
|
||||
static unsigned hash(const FontSelector& key) { return pair_int_hash(key.family.hash(), key.weight.hash()); }
|
||||
static unsigned hash(const FontSelector& key) { return pair_int_hash(pair_int_hash(key.family.hash(), key.weight), key.size); }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue