DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Fonts: macOS fonts that font services and managers activate are listed
aiongg833c0ec8d631
diff --git a/Cargo.lock b/Cargo.lockindex 484bfa1b8..439c8f582 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -787,6 +787,18 @@ dependencies = ["libc",]+[[package]]+name = "core-text"+version = "20.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c9d2790b5c08465d49f8dc05c8bcae9fea467855947db39b0f8145c091aaced5"+dependencies = [+ "core-foundation",+ "core-graphics",+ "foreign-types",+ "libc",+]+[[package]]name = "core_maths"version = "0.1.1"@@ -988,6 +1000,7 @@ dependencies = [name = "designcraft-fonts"version = "0.6.0"dependencies = [+ "core-text","harfrust 0.13.3","kurbo","log",diff --git a/ROADMAP.md b/ROADMAP.mdindex 0d1c1ef5e..20f027307 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -2,7 +2,7 @@**Stage: pre-alpha** · next: alpha, ~0% and ~15–25 h away; beta ~28 points and ~420–750 h beyond that (the core-workflow gate, not the percentage: ready for real work is already ~47%)-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-10 · **Change:** minor (stage re-normalized to pre-alpha by the core-workflow gate; earlier today: major, full re-measure against InDesign 2026 21.6; restructured to the craftrules progress-docs standard) · **Target:** Adobe InDesign 2026+> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-11 · **Change:** minor (macOS lists fonts that font services and managers activate) · **Target:** Adobe InDesign 2026DesignCraft aims at full Adobe InDesign parity, and to be better: faster, open (documented JSONformat + IDML), scriptable by agents (MCP), and available on the web.@@ -129,6 +129,8 @@ list) · [roadmap.md](docs/roadmap.md) (milestones, plan) · [parity-checklist.mNewest first.+- **2026-10-11** · macOS: fonts that font services and managers activate (Adobe Fonts,+ RightFont) are listed, read from the files CoreText has available (#261, #327).- **2026-10-10** · Version 0.6.0; releases add a Linux riscv64 tar.gz (cross-compiled, CLIsmoke-tested under QEMU).- **2026-10-10** · Readiness per audience: full ~47% (method aligned with the standard, wasdiff --git a/crates/fonts/Cargo.toml b/crates/fonts/Cargo.tomlindex d30d210a4..84e4aed8a 100644--- a/crates/fonts/Cargo.toml+++ b/crates/fonts/Cargo.toml@@ -19,3 +19,9 @@ harfrust = { workspace = true }unicode-bidi = { workspace = true }unicode-script = { workspace = true }log = { workspace = true }++[target.'cfg(target_os = "macos")'.dependencies]+# The font files CoreText has available (src/mac_fonts.rs): fonts that font services and managers+# register from their own folders. A safe API; MIT OR Apache-2.0. 20.x shares core-foundation 0.9+# and core-graphics 0.23 with the dependencies already locked.+core-text = "=20.1.0"diff --git a/crates/fonts/src/fontdb.rs b/crates/fonts/src/fontdb.rsindex 14441e144..20108e30f 100644--- a/crates/fonts/src/fontdb.rs+++ b/crates/fonts/src/fontdb.rs@@ -52,7 +52,8 @@ pub enum FontSource {Bundled,/// Font data handed to [`FontDb::add_font`], with no file behind it.Memory,- /// An installed font file (the system's or the user's font folders).+ /// An installed font file (the system's or the user's font folders, or one the platform+ /// lists outside them).Installed(std::path::PathBuf),/// A font file in a document's `Document Fonts` folder ([`FontDb::load_document_fonts`]).Document(std::path::PathBuf),@@ -334,6 +335,10 @@ pub struct FontDb {/// The folders the system font scan reads (the platform's font folders for [`FontDb::global`]).#[cfg_attr(target_arch = "wasm32", allow(dead_code))]font_dirs: Vec<std::path::PathBuf>,+ /// Lists the font files outside `font_dirs` that the system font scan reads too, asked again by+ /// each scan ([`platform_font_files`] for [`FontDb::global`]).+ #[cfg_attr(target_arch = "wasm32", allow(dead_code))]+ font_files: fn() -> Vec<std::path::PathBuf>,/// Set once the font folders have been scanned. Lookups by family name wait for the first/// scan, so what they find doesn't depend on what ran before them.#[cfg(not(target_arch = "wasm32"))]@@ -617,6 +622,29 @@ pub fn system_font_dirs() -> Vec<std::path::PathBuf> {dirs}+/// The font files outside the font folders that the platform has available, which+/// [`FontDb::global`]'s scan reads too: on macOS, those CoreText's font manager lists, such as the+/// fonts font services and font managers register from their own folders. None elsewhere.+#[cfg(target_os = "macos")]+use crate::mac_fonts::available_font_files as platform_font_files;+#[cfg(not(target_os = "macos"))]+fn platform_font_files() -> Vec<std::path::PathBuf> {+ Vec::new()+}++/// The files in `listed` that aren't in `scanned` (canonical paths), each once and added to+/// `scanned`; paths that don't lead to a file (gone, unreadable folder) are left out.+#[cfg(not(target_arch = "wasm32"))]+fn unscanned_font_files(listed: Vec<std::path::PathBuf>, scanned: &mut std::collections::HashSet<std::path::PathBuf>) -> Vec<std::path::PathBuf> {+ listed+ .into_iter()+ .filter(|p| {+ let Ok(canonical) = std::fs::canonicalize(p) else { return false };+ canonical.is_file() && scanned.insert(canonical)+ })+ .collect()+}+/// One face found in a font file: index, family, style and (variable fonts) the named instance's/// axis settings.type Found = (u32, String, String, Vec<([u8; 4], f32)>);@@ -780,6 +808,7 @@ impl FontDb {#[cfg(not(target_arch = "wasm32"))]catalog: RwLock::new(Vec::new()),font_dirs,+ font_files: Vec::new,#[cfg(not(target_arch = "wasm32"))]cataloged: std::sync::OnceLock::new(),#[cfg(not(target_arch = "wasm32"))]@@ -798,12 +827,13 @@ impl FontDb {let _ = on;}- /// Process-wide database: the bundled fonts, then the installed system fonts, cataloged the+ /// Process-wide database: the bundled fonts, then the installed system fonts (the font+ /// folders' and the platform's other font files, see [`platform_font_files`]), cataloged the/// first time a lookup by family name needs them (or ahead of time by/// [`FontDb::scan_in_background`]).pub fn global() -> &'static FontDb {static DB: std::sync::OnceLock<FontDb> = std::sync::OnceLock::new();- DB.get_or_init(|| FontDb::with_font_dirs(system_font_dirs()))+ DB.get_or_init(|| FontDb { font_files: platform_font_files, ..FontDb::with_font_dirs(system_font_dirs()) })}fn read_faces(&self) -> std::sync::RwLockReadGuard<'_, Vec<Arc<FontFace>>> {@@ -909,6 +939,8 @@ impl FontDb {let mut stack = self.font_dirs.clone();// Each folder once, however links lead back to it.let mut visited = std::collections::HashSet::new();+ // The font files read, by canonical path, so the platform's list adds only the others.+ let mut scanned = std::collections::HashSet::new();while let Some(d) = stack.pop() {if !visited.insert(std::fs::canonicalize(&d).unwrap_or_else(|_| d.clone())) {continue;@@ -924,11 +956,19 @@ impl FontDb {if !matches!(ext.as_deref(), Some("ttf" | "otf" | "ttc" | "otc")) {continue;}+ scanned.insert(std::fs::canonicalize(&p).unwrap_or_else(|_| p.clone()));for f in file_face_names(&p) {found.push(CatalogEntry { family: f.family, style: f.style, path: p.clone(), group: f.group, native: f.native });}}}+ // Font services name their files as they like (no extension, say): the face names read+ // decide what is a font.+ for p in unscanned_font_files((self.font_files)(), &mut scanned) {+ for f in file_face_names(&p) {+ found.push(CatalogEntry { family: f.family, style: f.style, path: p.clone(), group: f.group, native: f.native });+ }+ }let n = found.len();log::debug!("cataloged {n} system font faces");*self.catalog.write().unwrap_or_else(|e| e.into_inner()) = found;diff --git a/crates/fonts/src/lib.rs b/crates/fonts/src/lib.rsindex c1d744780..bd3827d62 100644--- a/crates/fonts/src/lib.rs+++ b/crates/fonts/src/lib.rs@@ -9,6 +9,8 @@mod fontdb;mod group;+#[cfg(target_os = "macos")]+mod mac_fonts;#[cfg(any(test, feature = "testing"))]pub mod testing;mod vertical;diff --git a/crates/fonts/src/mac_fonts.rs b/crates/fonts/src/mac_fonts.rsnew file mode 100644index 000000000..3f5b0b9a1--- /dev/null+++ b/crates/fonts/src/mac_fonts.rs@@ -0,0 +1,28 @@+//! macOS: the font files CoreText's font manager has available, which the system font scan reads+//! with the font folders.+//!+//! Font services and font managers (Adobe Fonts through Creative Cloud, RightFont, …) register+//! fonts with CoreText from files in their own folders, outside the font folders+//! (<https://developer.apple.com/documentation/coretext/ctfontmanagerregisterfontsforurl(_:_:_:)>).+//! CoreText's collection of available fonts holds them+//! (<https://developer.apple.com/documentation/coretext/ctfontcollectioncreatefromavailablefonts(_:)>),+//! so the scan reads their files in place (#261, #327).++use std::path::PathBuf;++/// The most font descriptors read from the collection (a system has a few thousand faces).+const MAX_FONTS: usize = 1 << 16;++/// The files of the fonts available to the process as CoreText lists them now, fonts registered+/// since the last call included. A file holding several faces is listed once per face.+pub(crate) fn available_font_files() -> Vec<PathBuf> {+ // `core-text` asserts that each attribute has the type CoreText documents; should one not, the+ // scan goes on with the font folders alone.+ std::panic::catch_unwind(|| {+ let Some(descriptors) = core_text::font_collection::create_for_all_families().get_descriptors() else {+ return Vec::new();+ };+ descriptors.iter().take(MAX_FONTS).filter_map(|d| d.font_path()).collect()+ })+ .unwrap_or_default()+}diff --git a/crates/fonts/src/tests_sysfonts.rs b/crates/fonts/src/tests_sysfonts.rsindex a9cda7cdc..d437444a7 100644--- a/crates/fonts/src/tests_sysfonts.rs+++ b/crates/fonts/src/tests_sysfonts.rs@@ -126,6 +126,38 @@ fn a_link_back_to_a_parent_folder_ends_the_scan() {assert_eq!(db.load_system_fonts(), 2);}+/// The folder a font service keeps its fonts in, outside the font folders, and the font folder+/// of [`fonts_the_platform_lists_outside_the_font_folders_are_cataloged_once`].+fn service_dirs() -> (PathBuf, PathBuf) {+ let tmp = std::env::temp_dir();+ let id = std::process::id();+ (tmp.join(format!("dc-sysfonts-{id}-service")), tmp.join(format!("dc-sysfonts-{id}-platform")))+}++/// The platform's list: a font service's file without an extension (twice, as for each face of a+/// collection), a font folder's file by another path, a file gone since and a folder.+fn service_files() -> Vec<PathBuf> {+ let (service, folder) = service_dirs();+ vec![service.join(".r/.12345"), folder.join("Sub/../Sysfont-Regular.ttf"), service.join(".r/.12345"), service.join("gone.otf"), service.clone()]+}++#[test]+fn fonts_the_platform_lists_outside_the_font_folders_are_cataloged_once() {+ let (service, folder) = service_dirs();+ let dir = font_dir("platform");+ assert_eq!(dir, folder);+ let _ = std::fs::remove_dir_all(&service);+ std::fs::create_dir_all(service.join(".r")).unwrap();+ std::fs::write(service.join(".r/.12345"), renamed("SourceSans3-It.ttf")).unwrap();+ let db = FontDb { font_files: service_files, ..FontDb::with_font_dirs(vec![dir]) };+ assert_eq!(db.styles(FAMILY), ["Regular", "Bold", "Italic"]);+ assert_eq!(db.load_system_fonts(), 3, "the font folder's Regular listed again isn't cataloged twice");+ let italic = db.face(FAMILY, "Italic");+ assert_eq!(italic.style, "Italic");+ assert_eq!(italic.source.path(), Some(service.join(".r/.12345").as_path()));+ let _ = std::fs::remove_dir_all(&service);+}+#[test]fn the_scan_reads_names_without_loading_the_font() {let dir = font_dir("names");diff --git a/docs/gaps.md b/docs/gaps.mdindex b8be72673..1e3c142c5 100644--- a/docs/gaps.md+++ b/docs/gaps.md@@ -1,6 +1,6 @@# Where DesignCraft falls short of InDesign-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-10 · **Change:** minor (stage re-normalized to pre-alpha by the core-workflow gate; earlier today: major, first version: gaps from the full re-measure and the issue tracker) · **Target:** Adobe InDesign 2026 (21.6)+> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-11 · **Change:** minor (gap 6: macOS lists fonts that font services and managers activate) · **Target:** Adobe InDesign 2026 (21.6)Every known shortfall against InDesign 2026, one entry each, ranked by how much it stops anInDesign professional from doing real work. This is the work list: agents pick from the top.@@ -88,8 +88,11 @@ Kind: **F** feature · **U** UI/UX · **T** typography · **FF** file format ·- **Doc:** [hardware-parity.md](hardware-parity.md)### 6. Installed fonts not always found (F)-- **Missing:** fonts in user font folders used for text (#161, #110, #107), fonts activated by- font managers and Adobe Fonts (#327, #261), reload when fonts change on disk (#328).+- **Missing:** fonts in user font folders used for text (#161, #110, #107), fonts that font+ services and managers activate on Windows, reload when fonts change on disk (#328).+- **Evidence:** on macOS the scan reads the font files CoreText has available, so fonts that+ Adobe Fonts and font managers activate are listed (#261, #327, 2026-10-11); not yet confirmed+ by the reporters.- **Impact:** documents set in the client's fonts render in Source Sans 3: wrong everywhere.- **Estimate:** 10–20 h (VectorCraft has a port, #261).- **Doc:** [typography-parity.md](typography-parity.md)diff --git a/docs/hardware-parity.md b/docs/hardware-parity.mdindex 1b75d1d34..031bec2ad 100644--- a/docs/hardware-parity.md+++ b/docs/hardware-parity.md@@ -1,6 +1,6 @@# Hardware and platform parity-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-10 · **Change:** major (first version) · **Target:** Adobe InDesign 2026 (21.6)+> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-11 · **Change:** minor (font managers on macOS) · **Target:** Adobe InDesign 2026 (21.6)What InDesign does with hardware, per platform, against DesignCraft. Layout is not aGPU-hungry workload, so this dimension carries little weight, but a start that fails on a@@ -28,7 +28,7 @@ graphics driver loses the user entirely. Overall numbers: [target-app-parity.md]| Platform | InDesign 2026 | DesignCraft | Evidence ||---|---|---|---|-| macOS (Apple silicon, Intel) | ✓ | ✓ primary development platform | Intel GPU start failure (#334); window controls misaligned (#333); font managers (#327) |+| macOS (Apple silicon, Intel) | ✓ | ✓ primary development platform | Intel GPU start failure (#334); window controls misaligned (#333) || Windows x64 | ✓ | ~ builds and installers ship | copy/paste and context menus (#351, #312), installer confusion (#64), launch failures (#273, #167) || Windows ARM64 | ✓ | ~ build (CI workflow) | not exercised at runtime || Linux (x86_64, aarch64; riscv64 tar.gz) | ✗ | ~ deb, AppImage, Flatpak | clipboard (#164), panels don't scroll (#267), CJK UI font (#332) |diff --git a/docs/typography-parity.md b/docs/typography-parity.mdindex 0339faf1e..a52754fbc 100644--- a/docs/typography-parity.md+++ b/docs/typography-parity.md@@ -1,6 +1,6 @@# Typography and composition parity-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-10 · **Change:** major (first version, from the full re-measure) · **Target:** Adobe InDesign 2026 (21.6)+> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-11 · **Change:** minor (macOS lists fonts that font services and managers activate) · **Target:** Adobe InDesign 2026 (21.6)Typesetting is what InDesign is bought for. A feature can exist and still set text differentlyfrom InDesign: different line breaks, different page count, overset where InDesign fits. This@@ -64,7 +64,7 @@ Fidelity: **unmeasured** unless stated.| CJK composition | mojikumi, kinsoku, aki, tsume, ruby, kenten, warichu, frame grid | most; mojikumi tables kept but not applied; ruby group-only; no frame grid | ~ | cjk.md, cjk-typography.md || Arabic / Hebrew | kashida, digits, diacritic positioning, RTL stories and tables | ✓ | ~ | vendor justification presets unsupported; list bullets and multi-column RTL (#100) || Missing glyphs and fonts | pink highlight, substitution | ✓ | ✓ | |-| Installed fonts | every activated font | system font folders; user folders, font managers and Adobe Fonts not always found | ~ | #161, #110, #107, #327, #261 |+| Installed fonts | every activated font | system font folders; on macOS also fonts that font managers and Adobe Fonts activate; user folders not always found | ~ | #161, #110, #107, #327, #261 || Composition highlights | H&J, keeps, custom tracking/kerning, substituted fonts | ✓ | ✓ | |Measured from the table above (2026-10-10): 34 rows, 18 ✓, 16 ~, 0 ✗, scoring ✓ = 1 and ~ = 0.5: