LibWeb: Store FontCascadeList instead of Font in CanvasState

This is required to implement per-glyph font fallbacks in the upcoming
changes.
This commit is contained in:
Aliaksandr Kalenik 2025-04-19 18:34:53 +02:00 committed by Andreas Kling
commit 2c64c6d773
Notes: github-actions[bot] 2025-04-21 07:52:30 +00:00
4 changed files with 22 additions and 20 deletions

View file

@ -14,6 +14,7 @@
#include <LibGfx/CompositingAndBlendingOperator.h>
#include <LibGfx/Filter.h>
#include <LibGfx/Font/Font.h>
#include <LibGfx/FontCascadeList.h>
#include <LibGfx/PaintStyle.h>
#include <LibGfx/Path.h>
#include <LibGfx/WindingRule.h>
@ -99,7 +100,7 @@ public:
float global_alpha = { 1 };
Gfx::CompositingAndBlendingOperator current_compositing_and_blending_operator = Gfx::CompositingAndBlendingOperator::SourceOver;
RefPtr<CSS::CSSStyleValue const> font_style_value { nullptr };
RefPtr<Gfx::Font const> current_font { nullptr };
RefPtr<Gfx::FontCascadeList const> current_font_cascade_list { nullptr };
Bindings::CanvasTextAlign text_align { Bindings::CanvasTextAlign::Start };
Bindings::CanvasTextBaseline text_baseline { Bindings::CanvasTextBaseline::Alphabetic };
};

View file

@ -65,7 +65,7 @@ public:
auto& font_size = *font_style_value.longhand(CSS::PropertyID::FontSize);
auto& font_family = *font_style_value.longhand(CSS::PropertyID::FontFamily);
auto font_list = canvas_element.document().style_computer().compute_font_for_style_values(&canvas_element, {}, font_family, font_size, font_style, font_weight, font_width);
my_drawing_state().current_font = font_list->first();
my_drawing_state().current_font_cascade_list = font_list;
}
Bindings::CanvasTextAlign text_align() const { return my_drawing_state().text_align; }