1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:17:35 +00:00

LibWeb: Add --layout-test-mode flag to HeadlessBrowser

The `layout-test-mode` flag changes the font to be SerenitySans as this
is the font used for layout tests for cross-platform compatibility of
tests.
This commit is contained in:
martinfalisse 2023-05-06 12:46:14 +02:00 committed by Andreas Kling
parent af26b76e0a
commit c719a542c5
6 changed files with 27 additions and 8 deletions

View file

@ -18,7 +18,8 @@ extern DeprecatedString s_serenity_resource_root;
namespace Ladybird {
FontPluginQt::FontPluginQt()
FontPluginQt::FontPluginQt(bool is_layout_test_mode)
: m_is_layout_test_mode(is_layout_test_mode)
{
// Load the default SerenityOS fonts...
Gfx::FontDatabase::set_default_fonts_lookup_path(DeprecatedString::formatted("{}/res/fonts", s_serenity_resource_root));
@ -69,6 +70,11 @@ void FontPluginQt::update_generic_fonts()
m_generic_font_names.resize(static_cast<size_t>(Web::Platform::GenericFont::__Count));
auto update_mapping = [&](Web::Platform::GenericFont generic_font, QFont::StyleHint qfont_style_hint, ReadonlySpan<DeprecatedString> fallbacks) {
if (m_is_layout_test_mode) {
m_generic_font_names[static_cast<size_t>(generic_font)] = "SerenitySans";
return;
}
QFont qt_font;
qt_font.setStyleHint(qfont_style_hint);