From 8cb6a76dac482b01e365507b0f350e0fc1c849a2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 2 Mar 2023 13:34:20 +0100 Subject: [PATCH] latex2svg: more robust handling of libgs not being found. Instead of just looking it up upfront and then hoping for the best, verify also that dvisvgm actually detected and used it. Because it not always does, in particular with versions < 3.0 and ghostscript 10. --- plugins/latex2svg.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/latex2svg.py b/plugins/latex2svg.py index ea6d3ab5..95a56122 100755 --- a/plugins/latex2svg.py +++ b/plugins/latex2svg.py @@ -143,6 +143,13 @@ def latex2svg(code, params=default_params, working_directory=None): return None output = ret.stderr.decode('utf-8') + + # Since we rely on Ghostscript to give us a "depth" (= vertical alignment) + # value, dvisvgm not using it means the output would be broken and it makes + # no sense to continue. + if 'Ghostscript not found' in output: + raise RuntimeError('libgs not detected by dvisvgm, point the LIBGS environment variable to its location') + width, height = get_size(output) depth = get_measure(output, 'depth') return {'svg': svg, 'depth': depth, 'width': width, 'height': height} -- 2.30.2