Skip to content

Commit b301f14

Browse files
committed
fix(theming): Correctly generate CSS for font themes
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 : f1448fc Signed-off-by: nfebe <fenn25.fn@gmail.com>
1 parent f05ae48 commit b301f14

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

apps/theming/lib/Controller/ThemingController.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,13 @@ public function getThemeStylesheet(string $themeId, bool $plain = false, bool $w
402402
$css = ":root { $variables } " . $customCss;
403403
} else {
404404
// If not set, we'll rely on the body class
405-
$css = "[data-theme-$themeId] { $variables $customCss }";
405+
// We need to separate @-rules from normal selectors, as they can't be nested
406+
// This is a replacement for the SCSS compiler that did this automatically before f1448fcf0777db7d4254cb0a3ef94d63be9f7a24
407+
preg_match_all('/(@[^{]+\{[^}]*\})/', $customCss, $atRules);
408+
$atRulesCss = implode('', $atRules[0]);
409+
$scopedCss = preg_replace('/(@[^{]+\{[^}]*\})/', '', $customCss);
410+
411+
$css = "$atRulesCss [data-theme-$themeId] { $variables $scopedCss }";
406412
}
407413

408414
try {

0 commit comments

Comments
 (0)