Add getFont() SCSS helper function
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 28 Jul 2020 12:12:55 +0000 (14:12 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 28 Jul 2020 12:12:55 +0000 (14:12 +0200)
wcfsetup/install/files/lib/system/style/StyleCompiler.class.php

index 354ae05928c30396b373eec547f06c13880779f7..5f52db634bf5020ff850813960db6bcc804c053f 100644 (file)
@@ -274,6 +274,25 @@ class StyleCompiler extends SingletonFactory {
                        $content .= $this->prepareFile($mixin);
                }
                
+               // getFont helper
+               $content .= <<<'EOT'
+@function getFont($filename, $family: "/", $version: "") {
+       @if (1 == 1) {
+               @if ($family != "") {
+                       $family: "families/" + $family + "/";
+               }
+               @if ($version != "") {
+                       $version: "?v=" + $version;
+               }
+               
+               @return "../font/" + $family + $filename + $version;
+       }
+       @else {
+               @return "../font/getFont.php?family=" + $family + "&filename=" + $filename + "&v=" + $version;
+       }
+}
+EOT;
+               
                // add google fonts
                if (!empty($variables['wcfFontFamilyGoogle']) && PACKAGE_ID) {
                        $cssFile = FontManager::getInstance()->getCssFilename(substr($variables['wcfFontFamilyGoogle'], 1, -1));