diff --git a/Cargo.lock b/Cargo.lock index e9d8af57..2a178fd0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -415,6 +415,7 @@ dependencies = [ "fontdb", "harfrust", "skrifa", + "unicode-bidi", ] [[package]] @@ -5225,6 +5226,12 @@ version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "357cc3acc6a036009fd6c973ed009037c732d60d0b4f6c673e9041497482a28f" +[[package]] +name = "unicode-bidi" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" + [[package]] name = "unicode-general-category" version = "1.1.0" diff --git a/crates/text/Cargo.toml b/crates/text/Cargo.toml index 6214daf1..79dfffa5 100644 --- a/crates/text/Cargo.toml +++ b/crates/text/Cargo.toml @@ -14,6 +14,8 @@ fontdb.workspace = true # Shaping (a HarfBuzz port) and outlines/metrics: both already in the tree through egui. harfrust = "0.12" skrifa = { version = "0.44", default-features = false, features = ["std"] } +# The Unicode bidi algorithm (UAX #9), for text that mixes right-to-left and left-to-right runs. +unicode-bidi = "0.3" [lints] workspace = true diff --git a/docs/adr/0012-text.md b/docs/adr/0012-text.md index c43fd737..d3460173 100644 --- a/docs/adr/0012-text.md +++ b/docs/adr/0012-text.md @@ -34,6 +34,12 @@ so neither may depend on which fonts happen to be installed. embedded Inter), shapes with `harfrust` (a HarfBuzz port), reads outlines and metrics with `skrifa`, and breaks lines (paragraphs at line breaks; with a width, greedily at spaces). These crates are already in the dependency tree through egui, so no new licences. + Text that mixes directions (Arabic or Hebrew with numbers or Latin words) follows the + Unicode bidi algorithm through `unicode-bidi` (MIT OR Apache-2.0): lines are found in + reading order, then each line's runs are shaped in their own direction and placed in + visual order. Characters the chosen face doesn't have (Arabic in Inter, say) come from the + first of `FALLBACK_FAMILIES` that has them, character by character, so the rest of the block + keeps its face; any that no face has are counted, and the command says they show as boxes. Bold and italic pick the matching face of the family; there is no synthetic styling. 5. **Break Apart** turns a text element into a shape with the same outlines, as Animate's second Break Apart does. @@ -46,8 +52,8 @@ so neither may depend on which fonts happen to be installed. edited, and the user is told. * Text in Animate documents imports onto this model (ADR 0014). * Not yet: per-character styles in one block, vertical text, text along a path, font - embedding for export, glyph fallback across - fonts for missing characters (missing glyphs draw as the font's "notdef" box). + embedding for export, fallback to installed fonts outside the fallback list (a character + none of the loaded faces has draws as the font's "notdef" box, and the command says so). ## Note (2026-11-11): text fields