Windows-Unterstützung: .bat-Skripte, Font-Werkzeuge in Python
- libs/glyphextract.py ersetzt die grep/sed/bc-Logik von extract-glyph.sh, extract-font.sh und fonttest.sh (die .sh rufen es nur noch auf); schreibt FONTNAME= und <font>.cfg nach $PICCREATE_OUT - bin/*.bat: setenv, piccreate, svgconvert, webscan, extract-glyph, extract-font, fonttest, setup-venv; .gitattributes für CRLF - piccreate.py: Hintergrund als file:// URL (Windows-Pfade) - svgconvert.py: magick statt convert, Configs/CSV als UTF-8 - webscan.py: Installationshinweise für Windows - doc/README.md: Abschnitt Windows, Font-Werkzeuge aktualisiert Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
4897883938
commit
29c066b45a
+18
-8
@@ -11,6 +11,7 @@ import cProfile
|
||||
import optparse
|
||||
import configparser
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import csv
|
||||
from string import Template
|
||||
@@ -18,10 +19,14 @@ from concurrent import futures
|
||||
from progressbar import EasyProgressBar
|
||||
|
||||
|
||||
# ImageMagick 7 heisst "magick"; unter Windows ist "convert" ein Systemprogramm
|
||||
IMAGEMAGICK = shutil.which('magick') or shutil.which('convert')
|
||||
|
||||
|
||||
def get_translation(cfg_path, sec_name):
|
||||
""" lädt die Zuordnung zwischen einem .csv Eingabefile und den Attributen"""
|
||||
config = configparser.RawConfigParser()
|
||||
config.read(cfg_path)
|
||||
config.read(cfg_path, encoding='utf-8')
|
||||
trans = dict(config.items(sec_name))
|
||||
return dict([[v,k] for k,v in trans.items()])
|
||||
|
||||
@@ -42,12 +47,14 @@ def convertSVG(in_path,filename,pic_config):
|
||||
if options.verbose:
|
||||
print (filename, 'already exist!')
|
||||
else:
|
||||
background = " -background " + pic_config['background'] + " "
|
||||
resize = " -resize " + pic_config['width'] + "x" + pic_config['height'] + " "
|
||||
density = " -density " + pic_config['density']
|
||||
cmd = "convert"
|
||||
cmdline = [IMAGEMAGICK,
|
||||
'-density', pic_config['density'],
|
||||
'-background', pic_config['background'],
|
||||
inpath,
|
||||
'-resize', pic_config['width'] + "x" + pic_config['height'],
|
||||
jpgpath]
|
||||
if not options.dry:
|
||||
subprocess.check_call(cmd + density + background + inpath + resize + jpgpath, shell = True)
|
||||
subprocess.check_call(cmdline)
|
||||
if options.verbose:
|
||||
print ('start converting', filename)
|
||||
Epb.slide_progbar()
|
||||
@@ -111,6 +118,9 @@ font-weight:normal;font-stretch:normal;font-family:Ubuntu;\
|
||||
|
||||
def main():
|
||||
"""get all information from the switches an start the parallel conversion"""
|
||||
if not IMAGEMAGICK and not options.dry:
|
||||
print('ImageMagick not found. Please install it (https://imagemagick.org).')
|
||||
return None
|
||||
#set the workpath and the default config
|
||||
work_path = os.path.expandvars('$PICCREATE_OUT')
|
||||
if options.svgfolder:
|
||||
@@ -149,7 +159,7 @@ def main():
|
||||
print('\"'+ config_path +'\" does not exist. Please give the name of a config file!')
|
||||
return None
|
||||
config = configparser.RawConfigParser()
|
||||
config.read(config_path)
|
||||
config.read(config_path, encoding='utf-8')
|
||||
# fill the config
|
||||
pic_config = dict(config.items(options.format))
|
||||
if options.background:
|
||||
@@ -173,7 +183,7 @@ def main():
|
||||
print ("you must give a config file for checking the svg files")
|
||||
return None
|
||||
svglist = []
|
||||
with open(csv_path, newline='') as csvfile:
|
||||
with open(csv_path, newline='', encoding='utf-8') as csvfile:
|
||||
reader = csv.DictReader(csvfile,delimiter = ';')
|
||||
for row in reader:
|
||||
if row[pic_config['customerid']] not in filelist:
|
||||
|
||||
Reference in New Issue
Block a user