From 6b124a255a3679798fed81da76efd14fc00cf831 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 12 Jul 2020 19:33:20 +0100 Subject: [PATCH] Preload font --- webinterface.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/webinterface.py b/webinterface.py index 85faa020..4565be48 100644 --- a/webinterface.py +++ b/webinterface.py @@ -2242,10 +2242,24 @@ def htmlNewPost(mediaInstance: bool, translate: {}, return newPostForm +def getFontFromCss(css: str) -> (str, str): + """Returns the font name and format + """ + if 'src: url(' not in css: + return None, None + fontName = css.split("src: url('")[1].split("')")[0] + fontFormat = css.split(" format('")[1].split("')")[0] + return fontName, fontFormat + + def htmlHeader(cssFilename: str, css: str, lang='en') -> str: htmlStr = '\n' htmlStr += '\n' htmlStr += ' \n' + fontName, fontFormat = getFontFromCss(css) + if fontName: + htmlStr += ' ' htmlStr += ' \n' htmlStr += ' \n' return htmlStr