Font-aware unit sizing; half-height unit toggle; bump to 0.86

Paths-mode unit rendering now always goes through _markup_unit_svg,
which fits the font's actual ink bounds (width AND height) to the
unit box — correct for all fonts, not just ГОСТ тип А.

Added half-height unit toggle: restricts the unit label to the upper
half of the panel box (y1 = midpoint at 103.8 mm), keeping it clear
of the numeric labels when they visually crowd the unit area.
This commit is contained in:
2026-07-15 00:10:02 +02:00
parent 62d9f02a82
commit 6bf7c70231
3 changed files with 34 additions and 14 deletions
+17
View File
@@ -302,6 +302,14 @@
<label>Unit</label>
<input name="unit" type="text" value="%" required>
<span style="font-family:var(--f-mono);font-size:0.65rem;color:var(--muted)">Markup: cm^2 · H_2O · {1/2} fraction · nests, e.g. {m/s^2}</span>
<div style="display:flex;align-items:center;gap:0.5rem;margin-top:0.2rem">
<div class="mode-toggle" role="group" aria-label="Unit height">
<button type="button" class="mode-btn active" data-unit-height="normal">Full height</button>
<button type="button" class="mode-btn" data-unit-height="half"
title="Restrict unit label to the upper half of the panel — use when numeric labels visually crowd the unit">Half height</button>
</div>
<input type="hidden" name="half_height_unit" id="half-height-unit" value="0">
</div>
</div>
<div class="field">
<label>Range label</label>
@@ -511,6 +519,15 @@
document.getElementById('font-select').addEventListener('change', doGenerate);
document.querySelectorAll('[data-unit-height]').forEach(btn => {
btn.addEventListener('click', () => {
document.querySelectorAll('[data-unit-height]').forEach(b => b.classList.remove('active'));
btn.classList.add('active');
document.getElementById('half-height-unit').value = btn.dataset.unitHeight === 'half' ? '1' : '0';
doGenerate();
});
});
doGenerate();
</script>
</body>