mirror of https://github.com/elisescu/tty-server
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
873 B
Python
48 lines
873 B
Python
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}");
|
|
}}
|
|
""")
|
|
|