diff --git a/Libraries/LibWeb/CSS/StyleComputer.cpp b/Libraries/LibWeb/CSS/StyleComputer.cpp index 96c18a12d66..330369c9c8e 100644 --- a/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -2051,6 +2051,10 @@ RefPtr StyleComputer::compute_font_for_style_values( font_list->add(*emoji_font); } + if (auto math_font = Platform::FontPlugin::the().default_math_font(font_size_in_pt); math_font) { + font_list->add(*math_font); + } + auto found_font = StyleProperties::font_fallback(monospace, bold); font_list->set_last_resort_font(found_font->with_size(font_size_in_pt)); diff --git a/Libraries/LibWeb/Platform/FontPlugin.h b/Libraries/LibWeb/Platform/FontPlugin.h index f21a977b824..4073ac50bae 100644 --- a/Libraries/LibWeb/Platform/FontPlugin.h +++ b/Libraries/LibWeb/Platform/FontPlugin.h @@ -34,6 +34,7 @@ public: virtual Gfx::Font& default_font() = 0; virtual Gfx::Font& default_fixed_width_font() = 0; virtual RefPtr default_emoji_font(float point_size) = 0; + virtual RefPtr default_math_font(float point_size) = 0; virtual FlyString generic_font_name(GenericFont) = 0; }; diff --git a/Libraries/LibWebView/Plugins/FontPlugin.cpp b/Libraries/LibWebView/Plugins/FontPlugin.cpp index 8bd758c399e..e9108840dc7 100644 --- a/Libraries/LibWebView/Plugins/FontPlugin.cpp +++ b/Libraries/LibWebView/Plugins/FontPlugin.cpp @@ -79,6 +79,11 @@ RefPtr FontPlugin::default_emoji_font(float point_size) return Gfx::FontDatabase::the().get(default_emoji_font_name, point_size, 400, Gfx::FontWidth::Normal, 0); } +RefPtr FontPlugin::default_math_font(float point_size) +{ + return Gfx::FontDatabase::the().get("Noto Sans Math"_fly_string, point_size, 400, Gfx::FontWidth::Normal, 0); +} + #ifdef USE_FONTCONFIG static Optional query_fontconfig_for_generic_family(Web::Platform::GenericFont generic_font) { diff --git a/Libraries/LibWebView/Plugins/FontPlugin.h b/Libraries/LibWebView/Plugins/FontPlugin.h index 658c00206fe..33cf7015f69 100644 --- a/Libraries/LibWebView/Plugins/FontPlugin.h +++ b/Libraries/LibWebView/Plugins/FontPlugin.h @@ -21,6 +21,7 @@ public: virtual Gfx::Font& default_font() override; virtual Gfx::Font& default_fixed_width_font() override; virtual RefPtr default_emoji_font(float point_size) override; + virtual RefPtr default_math_font(float point_size) override; virtual FlyString generic_font_name(Web::Platform::GenericFont) override; void update_generic_fonts(); diff --git a/Tests/LibWeb/Layout/expected/css-text-transform-math-auto.txt b/Tests/LibWeb/Layout/expected/css-text-transform-math-auto.txt index c06033cc4f7..59542e7b85f 100644 --- a/Tests/LibWeb/Layout/expected/css-text-transform-math-auto.txt +++ b/Tests/LibWeb/Layout/expected/css-text-transform-math-auto.txt @@ -2,8 +2,18 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline BlockContainer at (0,0) content-size 800x600 [BFC] children: not-inline BlockContainer at (8,16) content-size 784x17 children: not-inline BlockContainer

at (8,16) content-size 784x17 children: inline - frag 0 from TextNode start: 0, length: 67, rect: [8,16 118.40625x17] baseline: 13.296875 - "𝑊𝑒𝑙𝑙, ℎ𝑒𝑙𝑙𝑜 𝑓𝑟𝑖𝑒𝑛𝑑𝑠!" + frag 0 from TextNode start: 0, length: 16, rect: [8,16 29.171875x17] baseline: 13.296875 + "𝑊𝑒𝑙𝑙" + frag 1 from TextNode start: 16, length: 2, rect: [37,16 13.046875x17] baseline: 13.296875 + ", " + frag 2 from TextNode start: 18, length: 19, rect: [50,16 33x17] baseline: 13.296875 + "ℎ𝑒𝑙𝑙𝑜" + frag 3 from TextNode start: 37, length: 1, rect: [83,16 8x17] baseline: 13.296875 + " " + frag 4 from TextNode start: 38, length: 28, rect: [91,16 44.171875x17] baseline: 13.296875 + "𝑓𝑟𝑖𝑒𝑛𝑑𝑠" + frag 5 from TextNode start: 66, length: 1, rect: [135,16 3.859375x17] baseline: 13.296875 + "!" TextNode <#text> BlockContainer <(anonymous)> at (8,49) content-size 784x0 children: inline TextNode <#text>