Skip to content

Commit 43c8d82

Browse files
committed
Fix fontsize calculation in text_to_tspans. Fixes #62.
1 parent 685b439 commit 43c8d82

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pd/nw/pdgui.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3801,8 +3801,10 @@ function text_to_tspans(cid, svg_text, text, type) {
38013801
var is_comment = type && type === "text";
38023802
lines = text.split("\n");
38033803
len = lines.length;
3804-
// Get fontsize (minus the trailing "px")
3805-
fontsize = svg_text.getAttribute("font-size").slice(0, -2);
3804+
// Get fontsize (minus the trailing "px" if needed)
3805+
fontsize = svg_text.getAttribute("font-size");
3806+
if (fontsize.includes("px"))
3807+
fontsize = fontsize.slice(0, -2);
38063808
var dy = text_line_height_kludge(+fontsize, "gui");
38073809
var init_attr, style = {}, fill = null;
38083810
function make_tspan(span) {

0 commit comments

Comments
 (0)