Problem
With fontSize: 14, a sequence diagram draws participant names at 14 px and message labels at 12 px, but the frame keywords (alt, loop, opt, …) and the autonumber badges at 11 px: both use Math.round(fontSize * 0.75) (src/diagrams/sequence/render.ts L219-L221). On a page that requires every text to be at least 12 px, the only option that lifts them is fontSize, and the smallest whole value that does is 16, Pele's default. That also raises names to 16 px and messages to 14 px, and makes the diagram larger: 184 × 378 becomes 193 × 405 in the reproduction below.
Mermaid draws the frame keyword at sequence.messageFontSize; Pele 1.13.0 ignores that key, as well as actorFontSize, noteFontSize and themeVariables.fontSize. A CSS rule on .pele-frame-kind and .pele-sequence-number text raises the drawn size today, but those classes are not in the documented class list, and the badge and tab stay measured at the smaller size (L300, L443).
Reproduction and output
import { render } from 'pele';
const source = `sequenceDiagram
autonumber
Alice->>Bob: Hello Bob
alt Bob is free
Bob-->>Alice: Hi Alice
else Bob is busy
Bob-->>Alice: Later
end
loop Every minute
Alice->>Bob: Ping
end`;
const px = (svg, re) => svg.match(re)?.[1];
for (const fontSize of [14, 16]) {
const { svg, width, height } = render(source, { fontSize });
console.log(JSON.stringify({ fontSize, width, height,
names: px(svg, /font:([\d.]+)px/),
messages: px(svg, /class="pele-edge-labels" font-size="([\d.]+)"/),
keyword: px(svg, /class="pele-frame-kind"[^>]*font-size="([\d.]+)"/),
badge: px(svg, /class="pele-sequence-number">.*?<text[^>]*font-size="([\d.]+)"/) }));
}{"fontSize":14,"width":184,"height":378,"names":"14","messages":"12","keyword":"11","badge":"11"}
{"fontSize":16,"width":193,"height":405,"names":"16","messages":"14","keyword":"12","badge":"12"}Ask
A supported way to keep these texts at or above a minimum size, in both layout and drawing, without raising fontSize for the whole diagram. Without the new setting, sizes would stay as they are now.
I am not sure which developer experience fits Pele best, so here are a few options for you to choose from, or to replace with a better one:
- Honour
sequence.messageFontSizefor the frame keyword, as Mermaid does, like thequadrantChartsize keys in #108. Mermaid-compatible and local; the badge still needs its own size, and other diagram types need their own keys. - A render option such as
minFontSizethat floors every size derived fromfontSize. Other types derive smaller sizes the same way (0.875,0.75), so one setting covers them all; it touches every renderer, and text that shrinks to fit a box needs a rule when the floor and the fit disagree. - Document
.pele-frame-kindand.pele-sequence-number, and measure the tab and badge at the size CSS sets. No new option;render()has no DOM access, so onlymount()could measure at a size set in CSS, as it does for--pele-font;render()output would not follow.
Versions
- pele 1.13.0 (npm); the same code is in 1.7.0
- Node 26.13.1
Activity
0No activity yet.