Skip to content

Lini 1.0.6

Choose a tag to compare

@monfa-red monfa-red released this 17 Sep 16:05
· 6 commits to main since this release

A figure now keeps the font its boxes were measured with, even on a page whose stylesheet says otherwise. That is the whole release: one rule moves, and text stops walking out of its box when a Lini SVG is inlined somewhere with opinions about text.

cargo install lini

Nothing in the language changed. SPEC.md is the contract, and 1.x stays compatible with it.

The font is stated on the glyphs, not inherited by them

A box is sized at compile time from the metrics of the family the compiler picked. The stylesheet stated that family once, on the root <svg>, and let it inherit down to every <text>. Inheritance is the weakest thing in the CSS cascade: a bare text { font-family: … } in the host page — specificity 0,0,1, the feeblest selector that exists — replaces it, and from then on the boxes are drawn for one face and filled with another.

That is not a theoretical loss. A 19-character label measured at 118px paints at 171px in a monospace face and clears its 155px box by 20px on each side. It surfaced in obsidian-lini-view, where note styling reaches into inlined SVG, but any host that styles text, svg text, or a * inside its content area could do it.

Worth being precise about the cause, because the obvious diagnosis is wrong: it is not the declared fallbacks. Measured in a browser, every one of them fits — the declared stack at 118.2px, system-ui at 120.5px, Helvetica Neue at 116.1px, against 130.7px of content width. They are all proportional and within a couple of percent of each other. Only a face from outside the stack, arriving via a host rule, is wide enough to overflow.

So the family now rides its own selector list — the root and the glyph elements:

.lini-scope-abc123, .lini-scope-abc123 text { font-family: … }

One declaration, stated once, with nothing left to inherit away. The root rule keeps font-size, font-weight and color, which no host stylesheet was stealing.

An authored font still wins

A rule that matches <text> directly also outranks an ancestor's inline font-family — so |box| { font-family: "Courier New" } would have lost its face while keeping the width it was measured at, the same bug inverted. A text leaf now diffs that property against its effective attributes rather than its own, so an authored family inlines onto the leaf and beats the rule, while a leaf at the default carries nothing. The rule stays the only place the default is written.

If you want a different default face — a monospace one, say — set font-family in the source, where the compiler measures with it. What cannot work is changing the font after the widths are committed.

Also in this release

  • The wordmark follows the reader's theme. assets/logo/lini.svg was compiled with --static, which bakes the palette to literal hex and stamps an opaque white rect behind the mark — so on a dark README it read as a pasted screenshot. It is built like every other asset now: transparent, with its colours on var().
  • The editor extensions are a search away. Both are published: VS Code and Zed. Search Lini in the extensions pane rather than copying a folder.
  • The community's integrations have their own shelf in the README, starting with obsidian-lini-view — a ```lini fence that draws in the note itself, live in the editor.
  • Issue forms, so a bug report arrives with the source that drew the figure in it.

Downstream

lini-wasm@1.0.6 carries the fix to every JavaScript host — that is the one an Obsidian, Docusaurus or Astro site wants. remark-lini-lang@0.1.1, astro-lini@0.2.1 and mdbook-lini@0.5.4 follow it. No API moved; the floors move so the fix is not left to a caret to maybe pick up.