From e47d0de28b7becc2f16d6ba4814fd1307282710f Mon Sep 17 00:00:00 2001 From: Matthew Strasiotto Date: Thu, 24 Sep 2020 19:15:58 +1000 Subject: [PATCH] Add python script for building css --- .../tty-receiver/assets/fonts/fmt_fonts.py | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 frontend/tty-receiver/assets/fonts/fmt_fonts.py diff --git a/frontend/tty-receiver/assets/fonts/fmt_fonts.py b/frontend/tty-receiver/assets/fonts/fmt_fonts.py new file mode 100644 index 0000000..a209833 --- /dev/null +++ b/frontend/tty-receiver/assets/fonts/fmt_fonts.py @@ -0,0 +1,47 @@ +import re + +from pathlib import Path + +family = "Sauce_Code_Pro" + +pat = r"^" + family + r"_(?P[a-zA-Z]*)_?(?P[a-zA-Z]*))\.ttf" + +weights = { + "medium" : 400, + "" : 400, + "extralight" : 250, + "light" : 300, + "semibold" : 600, + "bold" : 700, + "black": 800 +} + +styles = { + "italic" : "italic", + "" : "normal" +} + +p = Path('.') + +for font in p.iterdir(): + m = re.match(pat, font.name) + + match_dict = m.groupdict(default = "") + + weight = match_dict["weight"].lower() + italic = match_dict["italic"].lower() + + css_weight = weights[""] + css_style = styles[""] + if weight in weights: css_weight = weights[weight] + if italic in styles: css_style = styles[italic] + + print(f""" +@font-face {{ + font-family: {family}; + font-style: {css_style}; + font-weight: {css_weight}; + src: url("assets/fonts/{font.name}"); +}} +""") +