Skip to content

Commit 6cafe26

Browse files
authored
Merge pull request #55 from frankframework/do-not-deform-characters
2 parents adb8cd3 + a33a32b commit 6cafe26

4 files changed

Lines changed: 34 additions & 10 deletions

File tree

projects/frank-config-layout/src/lib/graphics/svg-generator.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ function renderDefs(): string {
8080
font-family: "Inter", "trebuchet ms", serif;
8181
}
8282
83-
.rect-text > text[data-html-node="a"] {
84-
font-size: 28px;
85-
}
86-
8783
.rect-text > text[data-html-node="b"] {
8884
font-weight: bold;
8985
}
@@ -215,5 +211,5 @@ function getSvgTextElements(node: PlacedNode, border: number, fontSize: number):
215211
}
216212

217213
function getSvgTextElement(textPart: NodeTextPart, x: number, y: number): string {
218-
return `<text data-html-node=${textPart.name} x="${x}" y="${y}" textLength="${textPart.innerWidth}" lengthAdjust="spacingAndGlyphs">${textPart.text}</text>`;
214+
return `<text data-html-node=${textPart.name} x="${x}" y="${y}">${textPart.text}</text>`;
219215
}

projects/frank-config-layout/src/lib/model/text.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@ export function createNodeText(html: string, d: NodeTextDimensions): NodeText {
8989
const node = nodes[index];
9090
const name = node.nodeName.toLowerCase();
9191
if (name === 'br') continue;
92+
const isBold: boolean = name === 'b';
9293
const text = node.textContent ?? '';
93-
textParts.push(createNodeTextPart(name, text, d));
94+
textParts.push(createNodeTextPart(name, text, isBold, d));
9495
}
9596
const innerWidth = Math.max(...textParts.map((p) => p.innerWidth));
9697
return {
@@ -101,9 +102,8 @@ export function createNodeText(html: string, d: NodeTextDimensions): NodeText {
101102
};
102103
}
103104

104-
function createNodeTextPart(nodeName: string, text: string, d: NodeTextDimensions): NodeTextPart {
105-
// TODO: Calculate this only once.
106-
const fontWidth: number = calculateAverageFontCharacterWidth(d.nodeTextFontSize);
105+
function createNodeTextPart(nodeName: string, text: string, isBold: boolean, d: NodeTextDimensions): NodeTextPart {
106+
const fontWidth: number = calculateAverageFontCharacterWidth(d.nodeTextFontSize, isBold);
107107
const innerWidth: number = Math.round(text.length * fontWidth);
108108
const outerWidth: number = innerWidth + 2 * d.nodeTextBorder;
109109
return {

projects/frank-config-layout/src/public_api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function initMermaid2Svg(d: Dimensions): void {
4646
export function getFactoryDimensions(): Dimensions {
4747
return {
4848
nodeTextFontSize: 16,
49-
nodeTextBorder: 8,
49+
nodeTextBorder: 12,
5050
layerHeight: 60,
5151
layerDistance: 120,
5252
nodeBoxHeight: 54,

src/assets/nodeTextSizeTest.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
flowchart
2+
  d266e7("<b>DirectoryListener<b>"):::listener
3+
d266e10("<a style='font-size:28px'>MFHIn</a>"):::normal
4+
  d266e32("FixedQuerySender"):::sender
5+
  d266e55("JdbcTableListener"):::listener
6+
  d266e60("JavaListener"):::listener
7+
  d266e63("<b>MFHProcessor</b>"):::normal
8+
  classDef normal fill:#fff,stroke-width:4px,stroke:#8bc34a;
9+
  classDef listener0 fill:#fff,stroke-width:4px,stroke:#fe41ff;
10+
  classDef listener1 fill:#fff,stroke-width:4px,stroke:#18a689;
11+
  classDef listener2 fill:#fff,stroke-width:4px,stroke:#18a689;
12+
  classDef listener3 fill:#fff,stroke-width:4px,stroke:#4150ff;
13+
  classDef listener4 fill:#fff,stroke-width:4px,stroke:#ffc107;
14+
  classDef listener5 fill:#fff,stroke-width:4px,stroke:#ff417e;
15+
  classDef sender0 fill:#fff,stroke-width:4px,stroke:#fe41ff;
16+
  classDef sender1 fill:#fff,stroke-width:4px,stroke:#8bc34a;
17+
  classDef sender2 fill:#fff,stroke-width:4px,stroke:#00abff;
18+
  classDef sender3 fill:#fff,stroke-width:4px,stroke:#4150ff;
19+
  classDef sender4 fill:#fff,stroke-width:4px,stroke:#ffc107;
20+
  classDef sender5 fill:#fff,stroke-width:4px,stroke:#ff417e;
21+
  classDef sender6 fill:#fff,stroke-width:4px,stroke:#8a41ff;
22+
  classDef sender7 fill:#fff,stroke-width:4px,stroke:#ff8741;
23+
  classDef sender8 fill:#fff,stroke-width:4px,stroke:#8bc34a;
24+
  d266e7 --> d266e10
25+
  d266e10 --> d266e32
26+
  d266e55 --> d266e63
27+
  d266e60 --> d266e63
28+
  linkStyle 0,1,2,3 stroke:#8bc34a,stroke-width:3px,fill:none;

0 commit comments

Comments
 (0)