diff --git a/app.py b/app.py index c5d1896..dce53a1 100644 --- a/app.py +++ b/app.py @@ -319,6 +319,16 @@ def writing(id): # # FIGLET 2 SVGBOB INTERACTIVE CATALOGUE +def resizeSVG (m): + width = int(m.group(1)) + height = int(m.group(2)) + + viewbox = f'0 0 {width} {height}' + + newHeight = 420 + newWidth = (width/height) * newHeight + + return f'' @app.route('/hpgl/') def hpgl (id): @@ -336,11 +346,17 @@ def hpgl (id): # to SVG svg = ascii2svg(ascii, params['weight']) + svg = re.sub(r'\\<\/rect\>', '', svg, flags=re.M) + + svg = re.sub(r'', resizeSVG,svg) + + #print(svg) + # store as a temporary file - (svg_file, svg_path) = tempfile.mkstemp() - print(svg_path) - with open(svg_path, 'w') as svg_file: - svg_file.write(svg) + (svg_file, svg_path) = tempfile.mkstemp('.svg') + + with open(svg_file, 'w') as svg_handle: + svg_handle.write(svg) # transform to hpgl hpgl = svgToHPGL(svg_path) diff --git a/svg_to_hpgl.py b/svg_to_hpgl.py index 9b1930d..aab92e7 100644 --- a/svg_to_hpgl.py +++ b/svg_to_hpgl.py @@ -1,14 +1,23 @@ -# from hpgl_multipen_output import HpglMultipenOutput -from hpgl_output_adapted import HpglOutputAdapted +from hpgl_multipen_output import HpglMultipenOutput +import subprocess +# from hpgl_output_adapted import HpglOutputAdapted def svgToHPGL (path, speed=1, penCount=8, force=2): - e = HpglOutputAdapted() - e.run([ - '--orientation', '0', + + subprocess.call(['inkscape', + '-f', path, + '--verb', 'EditSelectAll', + '--verb', 'ObjectToPath', + '--verb', 'FileSave', + '--verb', 'FileQuit' ]) + + e = HpglMultipenOutput() + e.affect([ + '--orientation', '270', '--force', '0', '--overcut', '0', '--precut', 'false', - '--flat', '4', + '--flat', '8', '--toolOffset', '0', '--autoAlign', 'false', '--speed', str(speed), diff --git a/templates/font.html b/templates/font.html index 6a943d8..749e75a 100644 --- a/templates/font.html +++ b/templates/font.html @@ -26,6 +26,71 @@ output text + +