Fixing LaTeX rendering on windows.
This commit is contained in:
parent
70333a4e41
commit
04e070058e
2 changed files with 5 additions and 7 deletions
|
@ -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):
|
||||
|
|
|
@ -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 == ""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue