Add unit-label markup: super/subscripts and stacked fractions

Lighter shorthand (^x, _x, {a/b}) rendered as glyph paths in the ГОСТ
font — no LaTeX engine, so typography and self-contained output are
preserved. Constructs nest (e.g. {m/s^2}, x^{1/2}). A marked-up unit is
sized to its true ink bounding box and centered in the unit box with
white space, fitting in both axes so tall fractions don't overflow.

Also fit plain units by measured glyph width rather than a per-character
estimate. Bump to 0.77.
This commit is contained in:
2026-07-14 16:37:35 +02:00
parent edeb696238
commit f676651edb
4 changed files with 280 additions and 16 deletions
+13 -1
View File
@@ -46,7 +46,7 @@ The font must be installed at `/usr/local/share/fonts/г/ГОСТ_тип_А.ttf`
| Field | Description |
|---|---|
| Unit | Symbol shown in the left panel (e.g. `U`, `mA`, `%`) |
| Unit | Symbol shown in the left panel (e.g. `U`, `mA`, `%`). Supports inline markup — see below |
| Range label | Text inside the coloured bar on the right (e.g. `5mA`) |
| Mapping | **Linear** or **Log**. Log spaces values geometrically (major ticks evenly spaced, minor ticks crowding toward the high end) and requires Min and Max greater than 0 |
| Min / Max | Numeric range of the scale |
@@ -58,6 +58,18 @@ The font must be installed at `/usr/local/share/fonts/г/ГОСТ_тип_А.ttf`
Calculated numbers are rendered in fixed-point notation at 4 significant figures — never scientific (e.g. `10000`, not `1e+04`).
### Unit markup
The Unit field accepts a lightweight shorthand (no LaTeX engine — everything is drawn as glyph paths in the ГОСТ тип А font and auto-sized to fit the panel):
| Markup | Result |
|---|---|
| `cm^2` | superscript (`^{...}` for multiple characters) |
| `H_2O` | subscript (`_{...}` for multiple characters) |
| `{1/2}` | stacked fraction with a horizontal rule; a bare `/` stays inline |
Constructs nest: `{m/s^2}` is a fraction with a superscript in the denominator, `x^{1/2}` a superscripted fraction. A unit containing markup is always emitted as paths, even in text-output mode, since it is a composite of glyphs and a rule.
## Container
```bash