Update icons files

This commit is contained in:
Veronica Berglyd Olsen
2025-01-08 00:20:31 +01:00
parent b97844512a
commit 5cc29a7605
9 changed files with 677 additions and 390 deletions
+34 -18
View File
@@ -57,6 +57,7 @@ ICON_MAP = {
"fmt_underline": "format_underlined",
"fmt_toolbar": "text_format",
"search": "search",
"search_cancel": "close",
"search_case": "match_case",
"search_loop": "laps",
@@ -65,7 +66,6 @@ ICON_MAP = {
"search_regex": "regular_expression",
"search_replace": "find_replace",
"search_word": "match_word",
"search": "search",
"bullet-off": "radio_button_unchecked",
"bullet-on": "radio_button_checked",
@@ -136,7 +136,7 @@ def _fixXml(svg: str) -> str:
return etree.tostring(xSvg).decode()
def processMaterialIcons(workDir: Path, output: Path, style: str, fill: bool, weight: int) -> None:
def processMaterialIcons(workDir: Path, iconsDir: Path, jobs: dict) -> None:
"""Process material icons of a given spec and write output file."""
srcRepo = workDir / "material-design-icons"
if not srcRepo.is_dir():
@@ -144,20 +144,36 @@ def processMaterialIcons(workDir: Path, output: Path, style: str, fill: bool, we
else:
subprocess.call(["git", "pull"], cwd=srcRepo)
kind = f"wght{weight}" if weight != 400 else ""
kind += "fill1" if fill else ""
for file, job in jobs.items():
name: str = job["name"]
style: str = job["style"]
filled: bool = job["filled"]
weight: int = job["weight"]
with open(output, mode="w", encoding="utf-8") as icons:
iconSrc = srcRepo / "symbols" / "web"
for key, name in ICON_MAP.items():
if kind:
fileNmae = f"{name}_{kind}_24px.svg"
else:
fileNmae = f"{name}_24px.svg"
iconFile = iconSrc / name / f"materialsymbols{style}" / fileNmae
if iconFile.is_file():
svg = iconFile.read_text(encoding="utf-8")
icons.write(f"{key:<15s} = {_fixXml(svg)}\n")
print(f"Wrote: {iconFile.stem}")
else:
print(f"Not Found: {iconFile}")
kind = f"wght{weight}" if weight != 400 else ""
kind += "fill1" if filled else ""
print("")
print(f"Processing: {name}")
print("")
with open(iconsDir / f"{file}.icons", mode="w", encoding="utf-8") as icons:
icons.write("# This file is automatically generated. Do not edit.\n\n")
icons.write("# Meta\n")
icons.write(f"meta:name = {name}\n")
icons.write("meta:author = Google\n")
icons.write("meta:licence = Apache License Version 2.0\n")
icons.write("\n")
icons.write("# Icons\n")
iconSrc = srcRepo / "symbols" / "web"
for key, icon in ICON_MAP.items():
if kind:
fileNmae = f"{icon}_{kind}_24px.svg"
else:
fileNmae = f"{icon}_24px.svg"
iconFile = iconSrc / icon / f"materialsymbols{style}" / fileNmae
if iconFile.is_file():
svg = iconFile.read_text(encoding="utf-8")
icons.write(f"icon:{key:<15s} = {_fixXml(svg)}\n")
print(f"Wrote: {iconFile.stem}")
else:
print(f"Not Found: {iconFile}")