From 43d78e17e5ad649a9f3f6904d07fa6b1e423fe17 Mon Sep 17 00:00:00 2001 From: Ad5001 Date: Mon, 22 May 2023 04:21:53 +0200 Subject: [PATCH] Improving LaTeX rendering DPI. --- LogarithmPlotter/util/latex.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/LogarithmPlotter/util/latex.py b/LogarithmPlotter/util/latex.py index d9b4643..35d8d46 100644 --- a/LogarithmPlotter/util/latex.py +++ b/LogarithmPlotter/util/latex.py @@ -86,7 +86,7 @@ class Latex(QObject): Prepares and renders a latex string into a png file. """ markup_hash = hash(latex_markup) - export_path = path.join(self.tempdir.name, f'{markup_hash}_{font_size}_{color.rgb()}') + export_path = path.join(self.tempdir.name, f'{markup_hash}_{int(font_size)}_{color.rgb()}') if self.latexSupported and not path.exists(export_path + ".png"): print("Rendering", latex_markup, export_path) # Generating file @@ -97,7 +97,11 @@ class Latex(QObject): self.create_latex_doc(latex_path, latex_markup) self.convert_latex_to_dvi(latex_path) self.cleanup(latex_path) + # Creating four pictures of different sizes to better handle dpi. self.convert_dvi_to_png(latex_path, export_path, font_size, color) + self.convert_dvi_to_png(latex_path, export_path+"@2", font_size*2, color) + self.convert_dvi_to_png(latex_path, export_path+"@3", font_size*3, color) + self.convert_dvi_to_png(latex_path, export_path+"@4", font_size*4, color) except Exception as e: # One of the processes failed. A message will be sent every time. raise e img = QImage(export_path);