mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:17:34 +00:00
LibWeb: Don't round font sizes when looking them up
We previously had a rounding error which sometimes led to asking LibGfx for fonts with slightly wrong sizes.
This commit is contained in:
parent
ee883372f6
commit
d5bba91a16
2 changed files with 4 additions and 4 deletions
|
@ -877,7 +877,7 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele
|
||||||
bool monospace = false;
|
bool monospace = false;
|
||||||
|
|
||||||
auto find_font = [&](String const& family) -> RefPtr<Gfx::Font> {
|
auto find_font = [&](String const& family) -> RefPtr<Gfx::Font> {
|
||||||
int font_size_in_pt = roundf(font_size_in_px * 0.75f);
|
float font_size_in_pt = font_size_in_px * 0.75f;
|
||||||
font_selector = { family, font_size_in_pt, weight, slope };
|
font_selector = { family, font_size_in_pt, weight, slope };
|
||||||
|
|
||||||
if (auto found_font = FontCache::the().get(font_selector))
|
if (auto found_font = FontCache::the().get(font_selector))
|
||||||
|
|
|
@ -14,20 +14,20 @@
|
||||||
|
|
||||||
struct FontSelector {
|
struct FontSelector {
|
||||||
FlyString family;
|
FlyString family;
|
||||||
int size { 0 };
|
float point_size { 0 };
|
||||||
int weight { 0 };
|
int weight { 0 };
|
||||||
int slope { 0 };
|
int slope { 0 };
|
||||||
|
|
||||||
bool operator==(const FontSelector& other) const
|
bool operator==(const FontSelector& other) const
|
||||||
{
|
{
|
||||||
return family == other.family && size == other.size && weight == other.weight && slope == other.slope;
|
return family == other.family && point_size == other.point_size && weight == other.weight && slope == other.slope;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
template<>
|
template<>
|
||||||
struct Traits<FontSelector> : public GenericTraits<FontSelector> {
|
struct Traits<FontSelector> : public GenericTraits<FontSelector> {
|
||||||
static unsigned hash(const FontSelector& key) { return pair_int_hash(pair_int_hash(key.family.hash(), key.weight), key.size); }
|
static unsigned hash(const FontSelector& key) { return pair_int_hash(pair_int_hash(key.family.hash(), key.weight), key.point_size); }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue