Fix for text sizing calculations ans possibly insertion of a bug

This commit is contained in:
Knut Sveidqvist
2024-09-26 15:33:02 +02:00
parent 0ba4265bc3
commit 9e3bd1fb19
2 changed files with 7 additions and 3 deletions

View File

@@ -38,7 +38,8 @@ async function addHtmlSpan(element, node, width, classes, addBackground = false)
applyStyle(div, node.labelStyle); applyStyle(div, node.labelStyle);
div.style('display', 'table-cell'); div.style('display', 'table-cell');
div.style('white-space', 'nowrap'); // KS: Why is this here?
// div.style('white-space', 'nowrap');
div.style('line-height', '1.5'); div.style('line-height', '1.5');
div.style('max-width', width + 'px'); div.style('max-width', width + 'px');
div.style('text-align', 'center'); div.style('text-align', 'center');

View File

@@ -9,8 +9,11 @@ export async function text(parent: SVGAElement, node: Node): Promise<SVGAElement
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node)); const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
const totalWidth = Math.max(bbox.width + node.padding, node?.width || 0); // width > labelWidth
const totalHeight = Math.max(bbox.height + node.padding, node?.height || 0);
// labelWidth > width
const totalWidth = node?.width ?? bbox.width;
const totalHeight = Math.max(bbox.height, node?.height ?? 0);
const x = -totalWidth / 2; const x = -totalWidth / 2;
const y = -totalHeight / 2; const y = -totalHeight / 2;