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)
|
# self.convert_dvi_to_png(latex_path, export_path+"@4", font_size*4, color)
|
||||||
img = QImage(export_path)
|
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
|
# 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)
|
@Slot(str, float, QColor, result=str)
|
||||||
def findPrerendered(self, latex_markup: str, font_size: float, color: QColor) -> str:
|
def findPrerendered(self, latex_markup: str, font_size: float, color: QColor) -> str:
|
||||||
|
@ -206,7 +206,7 @@ class Latex(QObject):
|
||||||
data = ""
|
data = ""
|
||||||
if path.exists(export_path + ".png"):
|
if path.exists(export_path + ".png"):
|
||||||
img = QImage(export_path)
|
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
|
return data
|
||||||
|
|
||||||
def create_export_path(self, latex_markup: str, font_size: float, color: QColor):
|
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()
|
result = result.toVariant()
|
||||||
assert type(result) == str
|
assert type(result) == str
|
||||||
[path, width, height] = result.split(",")
|
[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+", width)
|
||||||
assert match(r"\d+", height)
|
assert match(r"\d+", height)
|
||||||
return True
|
return True
|
||||||
|
@ -92,10 +93,7 @@ class TestLatex:
|
||||||
latex_obj.renderSync(*args)
|
latex_obj.renderSync(*args)
|
||||||
prerendered = latex_obj.findPrerendered(*args)
|
prerendered = latex_obj.findPrerendered(*args)
|
||||||
assert type(prerendered) == str
|
assert type(prerendered) == str
|
||||||
[path, width, height] = prerendered.split(",")
|
check_render_results(prerendered)
|
||||||
assert exists(path)
|
|
||||||
assert match(r"\d+", width)
|
|
||||||
assert match(r"\d+", height)
|
|
||||||
prerendered2 = latex_obj.findPrerendered(args[0], args[1]+2, args[2])
|
prerendered2 = latex_obj.findPrerendered(args[0], args[1]+2, args[2])
|
||||||
assert prerendered2 == ""
|
assert prerendered2 == ""
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue