Restructure icon theme builder

This commit is contained in:
Veronica Berglyd Olsen
2025-01-16 19:26:04 +01:00
parent eb419fc4e0
commit b9602da177
6 changed files with 91 additions and 90 deletions
+5 -88
View File
@@ -35,7 +35,8 @@ import zipfile
from pathlib import Path
from utils.icon_themes import processFontAwesome, processMaterialIcons, processRemix
import utils.binary_dist
import utils.icon_themes
CURR_DIR = Path(__file__).parent
SETUP_DIR = CURR_DIR / "setup"
@@ -325,90 +326,6 @@ def buildSampleZip(args: argparse.Namespace | None = None) -> None:
return
##
# Import Translations (import-i18n)
##
def buildIconTheme(args: argparse.Namespace) -> None:
"""Build icon themes."""
print("")
print("Build Icon Themes")
print("=================")
print("")
workDir = Path(args.sources).absolute()
if not workDir.is_dir():
print(f"Source directory not found: {workDir}")
sys.exit(1)
iconsDir = CURR_DIR / "novelwriter" / "assets" / "icons"
style = args.style
if style in ("all", "material"):
processMaterialIcons(workDir, iconsDir, {
"material_rounded_thin": {
"name": "Material Symbols - Rounded Thin",
"style": "rounded",
"filled": False,
"weight": 200,
},
"material_rounded_normal": {
"name": "Material Symbols - Rounded Medium",
"style": "rounded",
"filled": False,
"weight": 400,
},
"material_rounded_bold": {
"name": "Material Symbols - Rounded Bold",
"style": "rounded",
"filled": False,
"weight": 600,
},
"material_filled_thin": {
"name": "Material Symbols - Filled Thin",
"style": "rounded",
"filled": True,
"weight": 200,
},
"material_filled_normal": {
"name": "Material Symbols - Filled Medium",
"style": "rounded",
"filled": True,
"weight": 400,
},
"material_filled_bold": {
"name": "Material Symbols - Filled Bold",
"style": "rounded",
"filled": True,
"weight": 600,
},
})
if style in ("all", "fa"):
processFontAwesome(workDir, iconsDir, {
"font_awesome": {
"name": "Font Awesome 6",
},
})
if style in ("all", "remix"):
processRemix(workDir, iconsDir, {
"remix_outline": {
"name": "Remix Icon - Outline",
"filled": False,
},
"remix_filled": {
"name": "Remix Icon - Filled",
"filled": True,
},
})
print("Done")
print("")
return
##
# Import Translations (import-i18n)
##
@@ -1487,9 +1404,9 @@ if __name__ == "__main__":
cmdIcons = parsers.add_parser(
"icons", help="Build icon theme files from source."
)
cmdIcons.add_argument("sources", help="Working directory for sources.")
cmdIcons.add_argument("style", help="What icon style to build.")
cmdIcons.set_defaults(func=buildIconTheme)
cmdIcons.add_argument("--sources", help="Working directory for sources.")
cmdIcons.add_argument("--style", help="What icon style to build.")
cmdIcons.set_defaults(func=utils.icon_themes.main)
# Import Translations
cmdImportTS = parsers.add_parser(