From 338fed3a1d866452f30b68f9afea7a098835163f Mon Sep 17 00:00:00 2001 From: Shun Wang Date: Fri, 21 Feb 2025 17:25:23 +0800 Subject: [PATCH] also adjust for latex vertical align in tables --- Desktop/html/js/jaspwidgets.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Desktop/html/js/jaspwidgets.js b/Desktop/html/js/jaspwidgets.js index c87a99cf6a..98b6a31672 100644 --- a/Desktop/html/js/jaspwidgets.js +++ b/Desktop/html/js/jaspwidgets.js @@ -36,8 +36,10 @@ class SvgToPng { if (svgs.length > 0) { svgs.forEach(svg => { const canvas = document.createElement('canvas'); - const svgWidth = svg.width ? svg.width.baseVal.value : svg.getAttribute("width") - const svgHeight = svg.height ? svg.height.baseVal.value : svg.getAttribute("Height") + const svgWidth = svg.width ? svg.width.baseVal.value : svg.getAttribute("width"); + const svgHeight = svg.height ? svg.height.baseVal.value : svg.getAttribute("height"); + const svgDisplay = window.getComputedStyle(svg, null).display; + const svgVerticalAlign = window.getComputedStyle(svg, null).verticalAlign; canvas.width = parseFloat(svgWidth) * 1.5; canvas.height = parseFloat(svgHeight) * 1.5; const img = new Image(); @@ -49,6 +51,8 @@ class SvgToPng { newImg.src = pngDataUrl; newImg.width = svgWidth; newImg.height = svgHeight; + newImg.style.display = svgDisplay ? svgDisplay : "inline-block"; + newImg.style.verticalAlign = svgVerticalAlign ? svgVerticalAlign : "middle"; if (svg.parentNode) svg.parentNode.replaceChild(newImg, svg); };