aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornfebe <fenn25.fn@gmail.com>2025-07-07 20:37:18 +0100
committernfebe <fenn25.fn@gmail.com>2025-07-11 12:27:41 +0100
commit625c1264fedd9e52023cd85d51a1bf8daa63c63c (patch)
tree4dea0b948457a8879c8dd6370021a4b951de9584
parentb61757a9e7e2e21d02191e91b777202714c5c98c (diff)
downloadnextcloud-server-fix/dyslexia-font-not-loading.tar.gz
nextcloud-server-fix/dyslexia-font-not-loading.zip
fix(theming): Correctly generate CSS for font themesfix/dyslexia-font-not-loading
Fixes a regression from dropping the SCSS compiler that broke font themes like OpenDyslexic. The old code relied on the SCSS compiler to automatically correct the order of the CSS rules, ensuring the @font-face declaration was always valid. The server now correctly generates the `@font-face` rule at the top level of the stylesheet, fixing the previously invalid nested CSS. Introduced in : f1448fcf0777db7d4254cb0a3ef94d63be9f7a24 Signed-off-by: nfebe <fenn25.fn@gmail.com>
-rw-r--r--apps/theming/lib/Controller/ThemingController.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/apps/theming/lib/Controller/ThemingController.php b/apps/theming/lib/Controller/ThemingController.php
index 4763e384156..e5cee254fe8 100644
--- a/apps/theming/lib/Controller/ThemingController.php
+++ b/apps/theming/lib/Controller/ThemingController.php
@@ -402,7 +402,17 @@ class ThemingController extends Controller {
$css = ":root { $variables } " . $customCss;
} else {
// If not set, we'll rely on the body class
- $css = "[data-theme-$themeId] { $variables $customCss }";
+ // We need to separate @-rules from normal selectors, as they can't be nested
+ // This is a replacement for the SCSS compiler that did this automatically before f1448fcf0777db7d4254cb0a3ef94d63be9f7a24
+ // We need a better way to handle this, but for now we just remove comments and split the at-rules
+ // from the rest of the CSS.
+ $customCssWithoutComments = preg_replace('!/\*.*?\*/!s', '', $customCss);
+ $customCssWithoutComments = preg_replace('!//.*!', '', $customCssWithoutComments);
+ preg_match_all('/(@[^{]+{(?:[^{}]*|(?R))*})/', $customCssWithoutComments, $atRules);
+ $atRulesCss = implode('', $atRules[0]);
+ $scopedCss = preg_replace('/(@[^{]+{(?:[^{}]*|(?R))*})/', '', $customCssWithoutComments);
+
+ $css = "$atRulesCss [data-theme-$themeId] { $variables $scopedCss }";
}
try {