mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:27:45 +00:00
LibGfx+LibWeb: Produce font cascade list in CSS font matching algorithm
According to the CSS font matching algorithm specification, it is supposed to be executed for each glyph instead of each text run, as is currently done. This change partially implements this by having the font matching algorithm produce a list of fonts against which each glyph will be tested to find its suitable font. Now, it becomes possible to have per-glyph fallback fonts: if the needed glyph is not present in a font, we can check the subsequent fonts in the list.
This commit is contained in:
parent
f50bf00814
commit
2cb0039a13
23 changed files with 250 additions and 109 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <AK/HashMap.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <LibGfx/Font/Font.h>
|
||||
#include <LibGfx/FontCascadeList.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibWeb/CSS/ComputedValues.h>
|
||||
#include <LibWeb/CSS/LengthBox.h>
|
||||
|
@ -22,8 +23,6 @@ public:
|
|||
|
||||
static NonnullRefPtr<StyleProperties> create() { return adopt_ref(*new StyleProperties); }
|
||||
|
||||
NonnullRefPtr<StyleProperties> clone() const;
|
||||
|
||||
template<typename Callback>
|
||||
inline void for_each_property(Callback callback) const
|
||||
{
|
||||
|
@ -128,15 +127,17 @@ public:
|
|||
float stroke_opacity() const;
|
||||
Optional<CSS::FillRule> fill_rule() const;
|
||||
|
||||
Gfx::Font const& computed_font() const
|
||||
Gfx::Font const& first_available_computed_font() const { return m_font_list->first(); }
|
||||
|
||||
Gfx::FontCascadeList const& computed_font_list() const
|
||||
{
|
||||
VERIFY(m_font);
|
||||
return *m_font;
|
||||
VERIFY(m_font_list);
|
||||
return *m_font_list;
|
||||
}
|
||||
|
||||
void set_computed_font(NonnullRefPtr<Gfx::Font const> font)
|
||||
void set_computed_font_list(NonnullRefPtr<Gfx::FontCascadeList> font_list) const
|
||||
{
|
||||
m_font = move(font);
|
||||
m_font_list = move(font_list);
|
||||
}
|
||||
|
||||
CSSPixels line_height(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const;
|
||||
|
@ -162,7 +163,7 @@ private:
|
|||
Vector<CSS::ShadowData> shadow(CSS::PropertyID, Layout::Node const&) const;
|
||||
|
||||
int m_math_depth { InitialValues::math_depth() };
|
||||
mutable RefPtr<Gfx::Font const> m_font;
|
||||
mutable RefPtr<Gfx::FontCascadeList> m_font_list;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue