@cardenelabs/cdl 0.110.0 → 0.111.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cardenelabs/cdl",
3
- "version": "0.110.0",
3
+ "version": "0.111.0",
4
4
  "description": "CDL (Chainome Diagram Language). Mermaid-like declarative DSL that compiles to animated SVG diagrams. Built for blockchain / Solidity flows, generic enough for sequence / flow / state / ER / topology diagrams.",
5
5
  "license": "MIT",
6
6
  "author": "cardene777",
@@ -141,11 +141,16 @@ function bottomLabel(node: LaidNode, cx: number, plan: ReturnType<typeof labelPl
141
141
  // 下限を当てるのは題の行だけ (#957) = 補いの行に当てると、収まっている行を大きくしてから
142
142
  // 切ることになる
143
143
  const 収める = (t: string, 大きさ: number, 字間: number, 題か = false) => {
144
+ // **縮める時と切る時で同じ測り方を使う** (#959)。 絵の中の字は等幅の字送りと字形の
145
+ // 大きい方を採る (`絵の中の字の幅`) ので、`幅の倍率` の `textWidth` で倍率を出すと
146
+ // 「収まる」 と言った行を切る側が「はみ出す」 と判定する (実測 = 幅 140 の箱で 9 種)
144
147
  const 測る = (u: string, f: number, ls: number) => 字の幅(u, f) + ls * [...u].length;
148
+ const 素の幅 = 測る(t, 大きさ, 字間);
149
+ const 収まる = 素の幅 > node.w && node.w > 0 ? node.w / 素の幅 : 1;
145
150
  const 下限 = 題か ? 切って収まる下限(t, 大きさ, 字間, node.w, 測る) : 0;
146
- const 倍率 = Math.max(幅の倍率(t, 大きさ, 字間, node.w), 下限);
151
+ const 倍率 = Math.max(収まる, 下限);
147
152
  const size = 大きさ * 倍率;
148
- return { 倍率, text: 帯で切る(t, size, node.w, (u, f) => 字の幅(u, f) + 字間 * 倍率 * [...u].length) };
153
+ return { 倍率, text: 帯で切る(t, size, node.w, (u, f) => 測る(u, f, 字間 * 倍率)) };
149
154
  };
150
155
  const 肩 = node.eyebrow && plan.肩書 ? 収める(node.eyebrow, plan.肩書.size, 2) : { 倍率: 1, text: node.eyebrow ?? "" };
151
156
  const 名 = 収める(node.title ?? "", plan.名前.size, 0, true);