Skip to content
This repository was archived by the owner on Nov 12, 2026. It is now read-only.

feat(dioxus): Type::faces, font files a host brings for parley to measure with - #22

Merged
adammharris merged 1 commit into
mainfrom
host-faces
Oct 23, 2026
Merged

adammharris merged 1 commit into
mainfrom
host-faces

Conversation

@adammharris

Copy link
Copy Markdown
Member

leaf-dioxus measured text only with the system's fonts. A host could name a face only if the machine had it installed. A browser has no system fonts that parley can read. Diaryx wants the same page on the Mac, iOS and the web (diaryx's proposals A page is set in the same faces everywhere and The author's app runs in a browser), so it brings its own files.

What changes

  • Type gains faces: Faces: a cheap-to-clone list of TrueType or OpenType files, built with collect() from anything AsRef<[u8]>.
  • Fonts registers each file into its parley collection once, by blob id, when the type is set (Fonts::new and set_ty). body and mono can then name a bundled face, and has_family sees it.
  • Faces::blobs() gives the host the same blobs to register in Blitz's collection (dioxus_native::Config::with_font_ctx). Then parley measures exactly what Blitz draws.
  • The stylesheet does not change. Type::default() still names Iowan and Menlo: which faces to use is the host's choice, and leaf provides only the mechanism.
  • leaf-dioxus and leaf-dioxus-tui pass faces: Default::default().

A 5.6 KB test face (Atkinson Hyperlegible Next, OFL, cut down to the alphabet and renamed Leaf Test Face, so no system has it) shows that parley sets text in a host's file. The test checks that the glyph run's font is the host's blob.

Breaking

Type has a new public field. A struct literal that lists every field must add faces: Default::default() or end with ..Type::default(). diaryx already uses ..Type::default().

Checked

  • ship ci dioxus (fmt, clippy for both renderers, and tests for the widget and the app): green.
  • cargo check for apps/leaf-dioxus-tui: green.
  • diaryx's app built against this branch: its new test finds every bundled family in Blitz's collection.

…sure with

leaf-dioxus measured only with the system's fonts, so a host could name a
face only if the machine had it installed. A browser has no system fonts
that parley can read, and a host that wants the same page on every platform
has to bring its own files.

`Type` gains `faces: Faces`, a cheap-to-clone list of TrueType or OpenType
files. `Fonts` registers each file into its parley collection once, by blob
id, when the type is set, so `body` and `mono` can name a bundled face. The
stylesheet is unchanged: the files are the renderer's to load, and the host
gives Blitz's collection the same blobs (`Faces::blobs`). Which faces they
are is the host's choice. `Type::default()` still names Iowan and Menlo.

A test face, Atkinson Hyperlegible Next cut to the alphabet and renamed so
no system has it, shows parley sets text in a host's file.

Behavioural-change: `Type` has a new public field, `faces`, so a `Type { .. }`
  literal that lists every field no longer compiles; add
  `faces: Default::default()` or end the literal with `..Type::default()`.
@adammharris
adammharris merged commit b6a4eeb into main Oct 23, 2026
6 checks passed
@adammharris
adammharris deleted the host-faces branch October 30, 2026 01:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant