From 28332c94bf850c408a437c39bdacb8655bee956e Mon Sep 17 00:00:00 2001 From: zeeker999 <13848632+zeeker999@users.noreply.github.com> Date: Wed, 7 Jun 2023 05:26:32 +0800 Subject: [PATCH] feat: Allow customizing the default math font (#38514) --- docs/api/structures/web-preferences.md | 1 + shell/browser/web_contents_preferences.cc | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/docs/api/structures/web-preferences.md b/docs/api/structures/web-preferences.md index 4325bcb29c95..047a13cefc2a 100644 --- a/docs/api/structures/web-preferences.md +++ b/docs/api/structures/web-preferences.md @@ -67,6 +67,7 @@ * `monospace` string (optional) - Defaults to `Courier New`. * `cursive` string (optional) - Defaults to `Script`. * `fantasy` string (optional) - Defaults to `Impact`. + * `math` string (optional) - Defaults to `Latin Modern Math`. * `defaultFontSize` Integer (optional) - Defaults to `16`. * `defaultMonospaceFontSize` Integer (optional) - Defaults to `13`. * `minimumFontSize` Integer (optional) - Defaults to `0`. diff --git a/shell/browser/web_contents_preferences.cc b/shell/browser/web_contents_preferences.cc index 1527c45be457..035ecad6439d 100644 --- a/shell/browser/web_contents_preferences.cc +++ b/shell/browser/web_contents_preferences.cc @@ -450,6 +450,10 @@ void WebContentsPreferences::OverrideWebkitPrefs( iter != default_font_family_.end()) prefs->fantasy_font_family_map[blink::web_pref::kCommonScript] = iter->second; + if (auto iter = default_font_family_.find("math"); + iter != default_font_family_.end()) + prefs->math_font_family_map[blink::web_pref::kCommonScript] = + iter->second; } if (default_font_size_)