Я читаю свои файлы из файла CSV, который соответствует буквам. Я также попытался добавить текстовый файл, который отображает буквы с их Unicode, но это не помогло. Вот сценарий: < /p>
import os
import shutil
import pandas as pd
import subprocess
# === CONFIGURATION ===
csv_path = r"C:\pathtocsv.csv"
build_dir = "build"
output_dir = r"directory"
def parse_csv(csv_path):
df = pd.read_csv(csv_path, header=0)
font_name = df.iloc[0, 0].strip()
char_map = {}
for col in df.columns[1:]:
char = col.strip()
if len(char) == 1 and char.isalpha() and char.isupper():
svg_path = df[col].iloc[0]
if pd.notna(svg_path) and svg_path.strip():
cleaned_path = svg_path.strip()
if os.path.exists(cleaned_path):
char_map[char] = cleaned_path
else:
print(f"
return font_name, char_map
def copy_svgs_to_build(char_map):
os.makedirs(build_dir, exist_ok=True)
svg_files = []
debug_map = {}
for char, src_path in char_map.items():
hex_code = f"u{ord(char):04X}"
dest_name = f"{hex_code}-{char}.svg"
dest_path = os.path.join(build_dir, dest_name)
shutil.copyfile(src_path, dest_path)
svg_files.append(dest_path)
debug_map[char] = src_path #
print(f"
return svg_files, debug_map
def write_toml(font_name):
toml_path = os.path.join(build_dir, f"{font_name}.toml")
with open(toml_path, "w", encoding="utf-8") as f:
f.write("[build]\n")
f.write(f'family = "{font_name}"\n')
f.write('output_format = "woff2"\n') #
Подробнее здесь: https://stackoverflow.com/questions/796 ... -different