From 79aea5c009e05826ba55139b799bf0c6cf983274 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 4 Dec 2026 17:41:34 -0800 Subject: [PATCH 1/2] Place: placed type keeps an installed font that shares a composite font's name A native file's composite font named like an installed font is not lent while the file's type is measured for placement, so the type is laid out in the installed font. Adoption still brought that definition in under a free name such as "Source Sans 3 2" and renamed the type to it, so the placed type switched to the composite font it was never measured in. Adoption now skips the source definitions the font database does not lend: one named like an installed font, or one that fails its own checks. --- crates/engine/src/cmd/place/adopt.rs | 15 +++++++++---- .../engine/tests/native_composite_adoption.rs | 21 +++++++++++++++++++ docs/mcp.md | 3 +++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/cmd/place/adopt.rs b/crates/engine/src/cmd/place/adopt.rs index c32aff52e1..f346d68b8f 100644 --- a/crates/engine/src/cmd/place/adopt.rs +++ b/crates/engine/src/cmd/place/adopt.rs @@ -597,12 +597,19 @@ fn collect_resources(src: &Document, nodes: &mut [Node], composites: bool) -> (U pub(crate) fn adopt(dst: &mut Document, src: &Document, nodes: &mut [Node], cmd: &str) -> Result<()> { let composites = !src.composite_fonts.is_empty() || !dst.composite_fonts.is_empty(); let (used, mut src_brushes, families) = collect_resources(src, nodes, composites); - let fonts = src.composite_fonts.iter().filter(|font| families.contains(&font.name.to_lowercase())).cloned().collect::>(); + // The source's type was measured without its composite fonts that fail their checks or are + // named like an installed font (the font database does not lend them), so they don't come in. + let db = vectorcraft_text::FontDb::global(); + let fonts = src + .composite_fonts + .iter() + .filter(|font| families.contains(&font.name.to_lowercase()) && font.check().is_ok() && !db.has_installed_family(&font.name)) + .cloned() + .collect::>(); // A family the source does not define as a composite font, which the destination defines as // one, would draw in the destination's composite font after placement. - let undefined_clash = families - .iter() - .any(|family| CompositeFont::named(&src.composite_fonts, family).is_none() && CompositeFont::named(&dst.composite_fonts, family).is_some()); + let undefined_clash = + families.iter().any(|family| CompositeFont::named(&fonts, family).is_none() && CompositeFont::named(&dst.composite_fonts, family).is_some()); // All representability/validation errors precede incoming or destination mutation. let plan = if fonts.is_empty() && !undefined_clash { None } else { Some(plan_import(fonts, families, dst, cmd)?) }; let staged; diff --git a/crates/engine/tests/native_composite_adoption.rs b/crates/engine/tests/native_composite_adoption.rs index cd033801ab..657dd2c668 100644 --- a/crates/engine/tests/native_composite_adoption.rs +++ b/crates/engine/tests/native_composite_adoption.rs @@ -102,6 +102,27 @@ fn kept_text(session: &mut Session, font: &CompositeFont) -> (NodeId, Node) { (id, document(session).node(id).unwrap().clone()) } +#[test] +fn placing_a_document_whose_composite_font_names_an_installed_font_keeps_the_installed_font() { + let _context = FontContext::hold(); + assert!(FontDb::global().has_installed_family("Source Sans 3"), "CONTROL: the bundled test face is installed"); + let mut source = destination(&[]); + source.execute("text.create", &json!({"x": 4, "y": 16, "text": "Ab", "font": "Source Sans 3"})).unwrap(); + let mut doc: Document = document(&source).clone(); + *doc.composite_fonts = vec![CompositeFont::new("Source Sans 3", "NativeInstalledNamePart", "Regular")]; + let dir = TempDir::new("native-composite-installed"); + let path = dir.join("installed.vectorcraft"); + let options = vectorcraft_format::SaveOptions { include_linked: true, precision: None, ..Default::default() }; + std::fs::write(&path, vectorcraft_format::save_with(&doc, &options).unwrap()).unwrap(); + for linked in [false, true] { + let mut session = destination(&[]); + let id = place(&mut session, &path, linked); + assert_eq!(placed_family(&session, id), "Source Sans 3", "the placed type keeps the installed family it was measured in"); + let fonts = &document(&session).composite_fonts; + assert!(fonts.is_empty(), "no composite font comes in for a name the source could not use: {fonts:?}"); + } +} + #[test] fn native_composite_meanings_survive_editable_and_embedded_placement() { let _context = FontContext::hold(); diff --git a/docs/mcp.md b/docs/mcp.md index 183f042d80..0c4d156d5e 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -11827,6 +11827,9 @@ with `link: false` or from `dataBase64` it is one group. `at` centres it, `rect` swaps the selected object (keeping its place and transform), `template` puts it on a new template layer. When placed editable art names a font family it does not define as a composite font, and the document defines a composite font of that name, the placed type gets a free name such as "Name 2" so it keeps the font it was laid out in. +A composite font of the placed file that is named like an installed font, or whose own name or part values are out of +range, does not come in: the file's type was laid out without it, and keeps that font. Two definitions of one name +that both come in still refuse the placement. A DCS file (Desktop Color Separation, version 1.0 or 2.0: an EPS file whose header names one EPS program per printing plate, ) is placed only from its `path` with link, as one linked image ([Import DCS files](https://helpx.adobe.com/illustrator/desktop/add-and-import-files/import-other-file-types/import-dcs-files.html)). From b54ce6910e65dbdfb9606aca2bf4c9235ea723dc Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 4 Dec 2026 20:08:54 -0800 Subject: [PATCH 2/2] Revert "Merge pull request #10894 from dotCooCoo/fix/font-hinting-back-on" This reverts commit 88851063c01e264d8bf6969f01a2d37611c4a528, reversing changes made to 7802fe94be291ee0332fff988b463601921e0ab7. --- crates/ui-egui/src/graphics.rs | 3 ++- crates/ui-egui/src/tests/font_menu.rs | 14 +++++++------- crates/ui-egui/src/ui_fonts.rs | 11 +++++++++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/crates/ui-egui/src/graphics.rs b/crates/ui-egui/src/graphics.rs index 0e200259b5..b90827aea0 100644 --- a/crates/ui-egui/src/graphics.rs +++ b/crates/ui-egui/src/graphics.rs @@ -127,13 +127,14 @@ impl VectorcraftApp { /// after losing its graphics), everything uploaded to the old one is made again: the fonts and /// theme, the canvas, the place cursor's thumbnails and every [`TexCache`]. The host hands it /// the window's context when it creates the app, so the first frame's input has the app's - /// commands. + /// commands. Each new context draws its text without hinting ([`crate::ui_fonts::hinting_off`]). pub fn adopt_context(&mut self, ctx: &egui::Context) { let tag = context_tag(ctx); self.ui_ctx = Some(ctx.clone()); if self.context == tag { return; } + crate::ui_fonts::hinting_off(ctx); if self.context != 0 { log::info!("vectorcraft: new graphics context: uploading the UI again"); forget_textures(); diff --git a/crates/ui-egui/src/tests/font_menu.rs b/crates/ui-egui/src/tests/font_menu.rs index 2fc247cfe9..2045e85976 100644 --- a/crates/ui-egui/src/tests/font_menu.rs +++ b/crates/ui-egui/src/tests/font_menu.rs @@ -77,10 +77,10 @@ fn samples_show_the_text_in_the_family_or_a_generic_sample() { /// A face with no hinting instructions draws a sample in a context the app has adopted, as the font list and the /// font picker draw each family's sample in its own face (a document face of the context): a Hebrew letter that is a -/// bar 20 by 700 thousandths of an em. The context hints text in both themes, so the sample goes through skrifa's -/// automatic hinter, whose blue-zone search for such a letter ends with the pinned skrifa. The face is served to the -/// fixture's context only, so the font database other tests read does not change. The sample is one rasterized glyph -/// from that face. It is drawn on a thread of its own, and the test fails when it has not ended after 300 s. +/// bar 20 by 700 thousandths of an em, whose blue zones the automatic hinter of skrifa 0.44 never finishes measuring. +/// The face is served to the fixture's context only, so the font database other tests read does not change. The +/// sample is one rasterized glyph from that face. It is drawn on a thread of its own, and the test fails when it has +/// not ended after 300 s. #[test] fn a_face_without_hinting_instructions_draws_its_sample() { use std::sync::{Arc, Mutex}; @@ -145,9 +145,9 @@ fn a_face_without_hinting_instructions_draws_its_sample() { let (texts, [hinting, light_hinting, dark_hinting], fixture_has_glyph, nonempty_glyph) = rx.recv_timeout(std::time::Duration::from_secs(300)).unwrap_or_else(|e| panic!("drawing the sample: {e}")); assert!(texts.iter().any(|t| t == "\u{5d1}"), "the sample is the letter, in the face: {texts:?}"); - assert!(hinting, "a context the app adopts hints text"); - assert!(light_hinting, "the light theme hints text"); - assert!(dark_hinting, "the dark theme hints text"); + assert!(!hinting, "a context the app adopts draws text without hinting"); + assert!(!light_hinting, "the light theme draws text without hinting"); + assert!(!dark_hinting, "the dark theme draws text without hinting"); assert!(fixture_has_glyph, "the sample's face maps U+05D1"); assert!(nonempty_glyph, "the sample is one rasterized glyph for U+05D1"); } diff --git a/crates/ui-egui/src/ui_fonts.rs b/crates/ui-egui/src/ui_fonts.rs index 24260dc24c..e75c8e21b1 100644 --- a/crates/ui-egui/src/ui_fonts.rs +++ b/crates/ui-egui/src/ui_fonts.rs @@ -24,6 +24,17 @@ pub fn ui_fonts() -> UiFonts<'static> { } } +/// Turns font hinting off for all text `ctx` draws, in both themes. With hinting on, egui hints a TrueType face that +/// has no hinting instructions (no `fpgm`, no `prep` and no glyph instructions) with skrifa 0.44's automatic hinter, +/// whose blue-zone search never ends for some glyphs, such as a tall narrow Hebrew letter, so the font list stops +/// responding when a row draws such a face. The font list and the samples get their faces through craft-libs, which +/// sets no hinting option per face, so the switch covers every face of the context. Hinting stays off until the +/// skrifa blue-zone exit (storytold/craft-libs#5222) is in the build; the craft-libs pin that brings it removes this +/// function and its call. +pub(crate) fn hinting_off(ctx: &egui::Context) { + ctx.all_styles_mut(|style| style.visuals.text_options.font_hinting = false); +} + #[derive(Clone)] struct FontSelection { language: Lang,