Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

fix(text-fit): keep a wide base wide when VS15 asks for text presentation

Claudee27141f554ce
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bd03a391..77490883 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ All notable changes are documented here. Format loosely follows [Keep a Changelo
> Development identity: `v2.17.0-dev.1`. Not a stable release.
### Fixed
+- **Text-presentation selectors no longer halve a wide glyph.** `textUnits` measured a `U+FE0E` (VS15) sequence as one unit for every base, so any East Asian Wide character followed by the selector was counted at half its advance. Shared node, boundary, legend, lane, and connection-label measurement now reads VS15 as a presentation choice that leaves the base's width untouched, while `U+FE0F` (VS16) keeps forcing the square emoji advance. Labels that overflowed their node while the layout receipt still read clean are now rejected with the same measurement as the identical label written without the selector.
- **DSH plugin refresh.** Adapter 0.2.0 pins the current Archify development snapshot, includes the newer runtime and CLI fixes, and targets DSH 0.1.2-rc.1. Release metadata replaces the frozen 0.1.0 packaging source; the tarball uses the canonical clean-Skill stager and documents independent plugin upgrades.
- **Machine-readable CLI argument failures (#330).** `validate --json` and `deliver --json` now keep invalid or missing option values, unknown options and diagram types, unsupported option combinations, and usage errors inside one versioned failure receipt on stdout. These failures use the `arguments` stage, stable diagnostic codes, and exit status 2, while human-mode stderr behavior remains unchanged.
- **Complete artifact-check receipts (#311).** The checker now lets stdout drain before exiting, so large JSON receipts remain complete through pipes. Validation, delivery, and architecture comparison retain their original success/failure status without truncated-JSON errors.
diff --git a/archify.zip b/archify.zip
index b4f4d8af..8dcf71d0 100644
Binary files a/archify.zip and b/archify.zip differ
diff --git a/archify/renderers/shared/utils.mjs b/archify/renderers/shared/utils.mjs
index 83075183..468aa8d6 100644
--- a/archify/renderers/shared/utils.mjs
+++ b/archify/renderers/shared/utils.mjs
@@ -201,20 +201,27 @@ export function applyTemplate(template, {
const FULLWIDTH_RE = /[\u1100-\u115F\u231A-\u231B\u2329-\u232A\u23E9-\u23EC\u23F0\u23F3\u25FD-\u25FE\u2614-\u2615\u2630-\u2637\u2648-\u2653\u267F\u268A-\u268F\u2693\u26A1\u26AA-\u26AB\u26BD-\u26BE\u26C4-\u26C5\u26CE\u26D4\u26EA\u26F2-\u26F3\u26F5\u26FA\u26FD\u2705\u270A-\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B-\u2B1C\u2B50\u2B55\u2E80-\uA4CF\uA960-\uA97C\uAC00-\uD7A3\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE6F\uFF01-\uFF60\uFFE0-\uFFE6\u{16FE0}-\u{18DFF}\u{1AFF0}-\u{1AFFF}\u{1B000}-\u{1B2FF}\u{1F000}-\u{1FAFF}\u{20000}-\u{3FFFD}]/u;
// A variation selector (U+FE00-U+FE0F) carries no advance of its own: it
-// re-presents the character before it. VS15 (U+FE0E) asks for text
-// presentation, which renders narrow; VS16 (U+FE0F) asks for emoji
-// presentation, which renders at the square emoji advance. So a base plus a
-// selector is measured from the selector, not from the base -- otherwise
-// widening the emoji-presentation bases above turns U+2B50 U+FE0F from two
-// units into three while the glyph on screen stays one square, and leaves
-// U+2708 U+FE0F at two only because its base happens to be narrow.
+// re-presents the character before it. Only VS16 (U+FE0F) changes the advance:
+// it asks for emoji presentation, which renders at the square emoji advance
+// whatever the base was worth on its own -- otherwise widening the
+// emoji-presentation bases above turns U+2B50 U+FE0F from two units into three
+// while the glyph on screen stays one square, and leaves U+2708 U+FE0F at two
+// only because its base happens to be narrow.
+//
+// VS15 (U+FE0E) asks for text presentation, which selects the monochrome glyph
+// without touching the base's East Asian Width -- the property FULLWIDTH_RE
+// above encodes, and the only thing this function measures. So a VS15 sequence
+// is worth exactly its base: U+2708 U+FE0E stays one unit because U+2708 is
+// Neutral, while U+2B50 U+FE0E stays two because U+2B50 is Wide. Reading VS15
+// as "renders narrow" instead halved every Wide base it followed, and
+// under-measuring is the direction that spills a label out of its box while
+// the layout receipt still reads clean.
//
// A selector following a base that cannot take emoji presentation is
// malformed input; measuring it wide is the safe direction here, since
// over-measuring pads a box while under-measuring spills the label out of it.
const VARIATION_SELECTOR_FIRST = 0xfe00;
const VARIATION_SELECTOR_LAST = 0xfe0f;
-const VARIATION_SELECTOR_TEXT = 0xfe0e;
const VARIATION_SELECTOR_EMOJI = 0xfe0f;
export function textUnits(text) {
@@ -225,7 +232,6 @@ export function textUnits(text) {
if (codePoint >= VARIATION_SELECTOR_FIRST && codePoint <= VARIATION_SELECTOR_LAST) continue;
const next = i + 1 < chars.length ? chars[i + 1].codePointAt(0) : -1;
if (next === VARIATION_SELECTOR_EMOJI) units += 2;
- else if (next === VARIATION_SELECTOR_TEXT) units += 1;
else units += FULLWIDTH_RE.test(chars[i]) ? 2 : 1;
}
return units;
diff --git a/archify/test/geometry.test.mjs b/archify/test/geometry.test.mjs
index 2b93f8c4..1259313e 100644
--- a/archify/test/geometry.test.mjs
+++ b/archify/test/geometry.test.mjs
@@ -637,15 +637,39 @@ test('textUnits measures a variation-selector sequence from the selector', () =>
// renders as a square and is two units, not one.
assert.equal(textUnits('✈️'), 2); // airplane
assert.equal(textUnits('❤️'), 2); // red heart
- // VS15 asks for text presentation, which renders narrow.
- assert.equal(textUnits('⭐︎'), 1);
- assert.equal(textUnits('✈︎'), 1);
+ // VS15 asks for text presentation. That picks the monochrome glyph without
+ // changing the base's East Asian Width, so the sequence is worth its base.
+ assert.equal(textUnits('✈︎'), 1); // airplane: U+2708 is Neutral
+ assert.equal(textUnits('⭐︎'), 2); // star: U+2B50 is Wide
// The selector never adds width of its own, alone or in a run.
assert.equal(textUnits('️'), 0);
assert.equal(textUnits('✅️ Done'), 7);
assert.equal(textUnits('⭐️⭐️'), 4);
});
+test('textUnits keeps a Wide base wide when VS15 asks for text presentation', () => {
+ // Regression: VS15 was read as "renders narrow" and applied to the sequence
+ // rather than to the base, so every Wide base it followed was measured at
+ // half its advance. A zero-advance selector must never shrink the glyph in
+ // front of it -- that under-measures the label and spills it out of its node
+ // while the layout receipt still reads clean.
+ for (const base of ['⭐', '❗', '⛔', '⚓', '⚡', '✅', '⭕', '㊙', '〽', '中']) {
+ assert.equal(textUnits(base + '︎'), textUnits(base), `VS15 changed the width of ${JSON.stringify(base)}`);
+ assert.equal(textUnits(base + '︎'), 2);
+ }
+ // Neutral bases are unaffected: they were already worth one unit.
+ for (const base of ['✈', '™', '☀', '☎']) {
+ assert.equal(textUnits(base + '︎'), 1);
+ }
+ // VS16 still forces the square emoji advance, whatever the base is worth.
+ assert.equal(textUnits('✈️'), 2);
+ assert.equal(textUnits('⭐️'), 2);
+ // A run of Wide bases carrying VS15 measures the same as the run without it.
+ const run = '⭐❗⛔⚓⚡';
+ assert.equal(textUnits(Array.from(run).map((c) => c + '︎').join('')), textUnits(run));
+ assert.equal(textUnits(run), 10);
+});
+
test('semantic sigils cover every component and lifecycle kind without literal color', () => {
const kinds = [
'frontend', 'backend', 'database', 'cloud', 'security', 'messagebus', 'external',