Optionsschalter vereinheitlicht, .sh-Skripte von überall aufrufbar
- gleiche Aufgabe = gleicher Schalter in allen Programmen: -c/--config (Alias --cfg), -i, -o/--outdir, --section, --format, -f/--force, -j, -t/--test, -y/--dry, -v - svgconvert: -o statt -s (Alias --svgfolder), --section statt --format für die Sektion (Standard png), --format überschreibt das Bildformat - webscan: --timeout und --browser nur noch lang (kollidierten mit -t/-b) - glyphextract: -i nimmt Glyph oder Font, -e extrahiert (statt -f/-t) - setenv.sh ermittelt das Projektverzeichnis selbst, alle .sh laden es relativ zum Skript; extract-font/fonttest reichen weitere Optionen durch - Hilfetexte korrigiert, doc/README.md: Abschnitt "Gemeinsame Optionen" Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
28f2bcdb32
commit
6bdaa62a7d
+19
-22
@@ -178,26 +178,26 @@ def main():
|
||||
print('"' + out_dir + '" does not exist. Please give the directory for the output!')
|
||||
return 1
|
||||
|
||||
if options.infile:
|
||||
if os.path.isfile(options.infile):
|
||||
# ein Buchstabe (extract-glyph.sh)
|
||||
if not os.path.isfile(options.infile) or not os.path.getsize(options.infile):
|
||||
print('input file does not exist')
|
||||
if not os.path.getsize(options.infile):
|
||||
print('input file is empty')
|
||||
return 1
|
||||
base, config = write_glyph(options.infile, out_dir, options.extract)
|
||||
with open(os.path.join(out_dir, base + '.cfg'), 'w', encoding='utf-8', newline='\n') as fh:
|
||||
fh.write(config)
|
||||
return 0
|
||||
|
||||
name = options.font or options.test
|
||||
source = font_source(name)
|
||||
# alle Buchstaben eines Fonts
|
||||
source = font_source(options.infile)
|
||||
configs = []
|
||||
for svg_path in sorted_glyphs(source):
|
||||
base, config = write_glyph(svg_path, out_dir, extract=bool(options.font))
|
||||
base, config = write_glyph(svg_path, out_dir, options.extract)
|
||||
print(base)
|
||||
configs.append((base, config))
|
||||
|
||||
if options.font:
|
||||
# ein Font (extract-font.sh): alle Sektionen in <font>.cfg
|
||||
if options.extract:
|
||||
# Font (extract-font.sh): alle Sektionen in <font>.cfg
|
||||
cfg_name = os.path.basename(os.path.normpath(source)) + '.cfg'
|
||||
with open(os.path.join(out_dir, cfg_name), 'w', encoding='utf-8', newline='\n') as fh:
|
||||
fh.write(''.join(config for _, config in configs))
|
||||
@@ -211,36 +211,33 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = optparse.OptionParser(usage="""%prog [options]
|
||||
parser = optparse.OptionParser(usage="""%prog -i <glyph.svg | font> [-e] [options]
|
||||
|
||||
Example usage
|
||||
-------------
|
||||
|
||||
one glyph, to test it later with inkscape:
|
||||
one glyph, test picture to check it with inkscape:
|
||||
$ %prog -i ../in/ausgangsschrift/a.svg
|
||||
one glyph, extract the points and text for the font:
|
||||
$ %prog -i ../in/ausgangsschrift/a.svg -e
|
||||
all glyphs of a font (directory in in/) including the font config:
|
||||
$ %prog -f ausgangsschrift
|
||||
all glyphs of a font (directory in in/ or a path) including the font config:
|
||||
$ %prog -i ausgangsschrift -e
|
||||
test pictures of all glyphs of a font:
|
||||
$ %prog -t ausgangsschrift
|
||||
$ %prog -i ausgangsschrift
|
||||
""", version='%prog ' + __version__)
|
||||
|
||||
parser.add_option("-i", "--infile", dest="infile",
|
||||
help="svg file of one glyph")
|
||||
help="svg file of one glyph or directory with the glyphs of a font")
|
||||
parser.add_option("-e", "--extract", dest="extract", action='store_true', default=False,
|
||||
help="with -i: extract the glyph for the font instead of a test picture")
|
||||
parser.add_option("-f", "--font", dest="font",
|
||||
help="directory with the glyphs of a font: create glyphs and font config")
|
||||
parser.add_option("-t", "--test", dest="test",
|
||||
help="directory with the glyphs of a font: create test pictures")
|
||||
help="extract the glyphs for the font (and write <font>.cfg) "
|
||||
"instead of test pictures")
|
||||
parser.add_option("-o", "--outdir", dest="outdir",
|
||||
default=os.environ.get('PICCREATE_OUT', '.'),
|
||||
help="directory for the output. default is $PICCREATE_OUT")
|
||||
help="directory where the files will be written. default is $PICCREATE_OUT")
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
if sum(1 for o in (options.infile, options.font, options.test) if o) != 1:
|
||||
parser.error('please give exactly one of -i, -f or -t')
|
||||
if not options.infile:
|
||||
parser.error('please give a glyph or a font with -i')
|
||||
sys.exit(main())
|
||||
|
||||
# vim: set tw=80 ft=python ts=4 sw=4:
|
||||
|
||||
Reference in New Issue
Block a user