diff --git a/runtime-pyside6/LogarithmPlotter/util/latex.py b/runtime-pyside6/LogarithmPlotter/util/latex.py index b446295..5b127dc 100644 --- a/runtime-pyside6/LogarithmPlotter/util/latex.py +++ b/runtime-pyside6/LogarithmPlotter/util/latex.py @@ -195,7 +195,7 @@ class Latex(QObject): # self.convert_dvi_to_png(latex_path, export_path+"@4", font_size*4, color) img = QImage(export_path) # Small hack, not very optimized since we load the image twice, but you can't pass a QImage to QML and expect it to be loaded - return f'{export_path}.png,{img.width()},{img.height()}' + return f'file:///{export_path}.png,{img.width()},{img.height()}' @Slot(str, float, QColor, result=str) def findPrerendered(self, latex_markup: str, font_size: float, color: QColor) -> str: @@ -206,7 +206,7 @@ class Latex(QObject): data = "" if path.exists(export_path + ".png"): img = QImage(export_path) - data = f'{export_path}.png,{img.width()},{img.height()}' + data = f'file:///{export_path}.png,{img.width()},{img.height()}' return data def create_export_path(self, latex_markup: str, font_size: float, color: QColor): diff --git a/runtime-pyside6/tests/test_latex.py b/runtime-pyside6/tests/test_latex.py index 4ffbc6c..e410995 100644 --- a/runtime-pyside6/tests/test_latex.py +++ b/runtime-pyside6/tests/test_latex.py @@ -47,7 +47,8 @@ def check_render_results(result): result = result.toVariant() assert type(result) == str [path, width, height] = result.split(",") - assert exists(path) + assert path.startswith("file:///") + assert exists(path[len("file:///"):]) assert match(r"\d+", width) assert match(r"\d+", height) return True @@ -92,10 +93,7 @@ class TestLatex: latex_obj.renderSync(*args) prerendered = latex_obj.findPrerendered(*args) assert type(prerendered) == str - [path, width, height] = prerendered.split(",") - assert exists(path) - assert match(r"\d+", width) - assert match(r"\d+", height) + check_render_results(prerendered) prerendered2 = latex_obj.findPrerendered(args[0], args[1]+2, args[2]) assert prerendered2 == ""