From c022147ca7faa8b671ee312ed48805d2c8633c0a Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 22 Apr 2021 11:02:38 +0200 Subject: [PATCH] Moved the font stack into class constants --- .../files/lib/acp/form/StyleAddForm.class.php | 2 +- .../lib/system/style/StyleCompiler.class.php | 22 ++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php index 06ad366eef..9364f14638 100644 --- a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php @@ -75,7 +75,7 @@ class StyleAddForm extends AbstractForm 'Impact, Compacta, Chicago, sans-serif' => 'Impact', '"Lucida Sans", "Lucida Grande", Monaco, Geneva, sans-serif' => 'Lucida', '"Segoe UI", "DejaVu Sans", "Lucida Grande", Helvetica, sans-serif' => 'Segoe UI', - 'system' => 'System', + StyleCompiler::SYSTEM_FONT_NAME => 'System', 'Tahoma, Arial, Helvetica, sans-serif' => 'Tahoma', '"Times New Roman", Times, Georgia, serif' => 'Times New Roman', '"Trebuchet MS", Arial, sans-serif' => 'Trebuchet MS', diff --git a/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php b/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php index 31e5413797..af106f3132 100644 --- a/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php +++ b/wcfsetup/install/files/lib/system/style/StyleCompiler.class.php @@ -52,6 +52,16 @@ final class StyleCompiler extends SingletonFactory */ const REGISTRY_GLOBAL_VALUES = 'styleGlobalValues'; + public const SYSTEM_FONT_NAME = 'system'; + + private const SYSTEM_FONT_FAMILY = 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", + "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", + "Helvetica Neue", Arial, sans-serif'; + + private const SYSTEM_FONT_FAMILY_MONOSPACE = 'ui-monospace, Menlo, Monaco, "Cascadia Mono", + "Segoe UI Mono", "Roboto Mono", "Oxygen Mono", "Ubuntu Monospace", "Source Code Pro", + "Fira Mono", "Droid Sans Mono", "Courier New", monospace'; + /** * @inheritDoc */ @@ -592,14 +602,10 @@ EOT; // Define the font family set for the OS default fonts. This needs to be happen statically to // allow modifications in the future in case of changes. - $variables['wcfFontFamilyMonospace'] = 'ui-monospace, Menlo, Monaco, "Cascadia Mono", - "Segoe UI Mono", "Roboto Mono", "Oxygen Mono", "Ubuntu Monospace", "Source Code Pro", - "Fira Mono", "Droid Sans Mono", "Courier New", monospace'; - - if ($variables['wcfFontFamily'] === 'system') { - $variables['wcfFontFamily'] = 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", - "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", - "Helvetica Neue", Arial, sans-serif'; + $variables['wcfFontFamilyMonospace'] = self::SYSTEM_FONT_FAMILY_MONOSPACE; + + if ($variables['wcfFontFamily'] === self::SYSTEM_FONT_NAME) { + $variables['wcfFontFamily'] = self::SYSTEM_FONT_FAMILY; } // add options as SCSS variables -- 2.20.1