mirror of https://github.com/elisescu/tty-server
Add python script for building css
parent
b38526cca7
commit
e47d0de28b
@ -0,0 +1,47 @@
|
||||
import re
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
family = "Sauce_Code_Pro"
|
||||
|
||||
pat = r"^" + family + r"_(?P<weight>[a-zA-Z]*)_?(?P<italic>[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}");
|
||||
}}
|
||||
""")
|
||||
|
Loading…
Reference in New Issue