Download Google Fonts on style import
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 15 Jul 2020 09:38:07 +0000 (11:38 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 15 Jul 2020 10:17:34 +0000 (12:17 +0200)
see #3394

wcfsetup/install/files/lib/data/style/StyleEditor.class.php

index c3a4c1fb705bb70d8f2f46131c4a3ec7094ae68a..276d5fc7f7cdd89137ad129a94dd5884a3c2c0ce 100644 (file)
@@ -21,6 +21,8 @@ use wcf\system\package\PackageArchive;
 use wcf\system\style\StyleCompiler;
 use wcf\system\style\StyleHandler;
 use wcf\system\Regex;
+use wcf\system\style\exception\FontDownloadFailed;
+use wcf\system\style\FontManager;
 use wcf\system\WCF;
 use wcf\util\DateUtil;
 use wcf\util\FileUtil;
@@ -657,6 +659,16 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject
                        }
                }
                
+               // download google fonts
+               $fontManager = FontManager::getInstance();
+               $family = $style->getVariable('wcfFontFamilyGoogle');
+               try {
+                       $fontManager->downloadFamily($family);
+               }
+               catch (FontDownloadFailed $e) {
+                       // ignore
+               }
+
                $tar->close();
                
                return $style;