diff --git a/app.py b/app.py index 06dfeff2171218e71552dab45b6e6eabe53213a3..e079df3c3478337c06b7712db2216d73f35b26ed 100644 --- a/app.py +++ b/app.py @@ -290,6 +290,16 @@ def catalogue(): # # 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'<svg xmlns="http://www.w3.org/2000/svg" viewbox="{viewbox}" width="{newWidth}mm" height="{newHeight}mm" class="svgbob">' @app.route('/hpgl/<id>') def hpgl (id): @@ -309,6 +319,8 @@ def hpgl (id): svg = re.sub(r'\<rect class="backdrop" x="\d+" y="\d+" width="\d+" height="\d+">\<\/rect\>', '', svg, flags=re.M) + svg = re.sub(r'<svg xmlns="http://www.w3.org/2000/svg" width="(\d+)" height="(\d+)" class="svgbob">', resizeSVG,svg) + #print(svg) # store as a temporary file