From 7c9fc950c4dcbbdf1dcf34a150f71e2d6aae5ae3 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 11:05:44 -0800 Subject: [PATCH 1/9] Brushes: Add original Paint library --- crates/engine/src/cmd/brushlib.rs | 40 +++++++++++++++++++ crates/engine/src/tests/brushlib.rs | 39 ++++++++++++++++-- crates/ui-egui/src/i18n/bg.tsv | 5 +++ crates/ui-egui/src/i18n/bs.tsv | 5 +++ crates/ui-egui/src/i18n/ca.tsv | 5 +++ crates/ui-egui/src/i18n/cs.tsv | 5 +++ crates/ui-egui/src/i18n/da.tsv | 5 +++ crates/ui-egui/src/i18n/de.tsv | 5 +++ crates/ui-egui/src/i18n/el.tsv | 5 +++ crates/ui-egui/src/i18n/es.tsv | 5 +++ crates/ui-egui/src/i18n/fi.tsv | 5 +++ crates/ui-egui/src/i18n/fr.tsv | 5 +++ crates/ui-egui/src/i18n/gu.tsv | 5 +++ crates/ui-egui/src/i18n/hi.tsv | 5 +++ crates/ui-egui/src/i18n/hu.tsv | 5 +++ crates/ui-egui/src/i18n/id.tsv | 5 +++ crates/ui-egui/src/i18n/it.tsv | 5 +++ crates/ui-egui/src/i18n/ja.tsv | 5 +++ crates/ui-egui/src/i18n/ka.tsv | 5 +++ crates/ui-egui/src/i18n/ko.tsv | 5 +++ crates/ui-egui/src/i18n/nl.tsv | 5 +++ crates/ui-egui/src/i18n/pl.tsv | 5 +++ crates/ui-egui/src/i18n/pt-br.tsv | 5 +++ crates/ui-egui/src/i18n/ru.tsv | 5 +++ crates/ui-egui/src/i18n/sv.tsv | 5 +++ crates/ui-egui/src/i18n/tests.rs | 3 +- crates/ui-egui/src/i18n/tr.tsv | 5 +++ crates/ui-egui/src/i18n/uk.tsv | 5 +++ crates/ui-egui/src/i18n/vi.tsv | 5 +++ crates/ui-egui/src/i18n/zh-hans.tsv | 5 +++ crates/ui-egui/src/i18n/zh-hant.tsv | 5 +++ .../src/panels/tests_brush_libraries.rs | 12 ++++++ docs/mcp.md | 4 +- docs/target-app-parity.md | 1 + 34 files changed, 233 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/cmd/brushlib.rs b/crates/engine/src/cmd/brushlib.rs index 34becd7c02..fed29ea06f 100644 --- a/crates/engine/src/cmd/brushlib.rs +++ b/crates/engine/src/cmd/brushlib.rs @@ -173,6 +173,7 @@ pub const BUILTIN: &[BuiltinBrushLibrary] = &[ BuiltinBrushLibrary { id: "ink-and-wash", name: "Ink and Wash", make: ink_and_wash }, BuiltinBrushLibrary { id: "calligraphic-nibs", name: "Calligraphic Nibs", make: calligraphic_nibs }, BuiltinBrushLibrary { id: "bristle-brushes", name: "Bristle Brushes", make: bristle_brushes }, + BuiltinBrushLibrary { id: "paint", name: "Paint", make: paint }, BuiltinBrushLibrary { id: "pattern-borders", name: "Pattern Borders", make: pattern_borders }, BuiltinBrushLibrary { id: "scatter-shapes", name: "Scatter Shapes", make: scatter_shapes }, BuiltinBrushLibrary { id: "game-trails", name: "Game Trails", make: game_trails }, @@ -457,6 +458,45 @@ fn spacer(r: Rect) -> Node { } /// Pattern Borders: pattern brushes of tiles drawn here; Beads has corner tiles. +/// Paint: original filled vector art with broad, broken, loaded, and fanned marks. Each is one +/// stroke stretched along the path, with an intentionally different edge and paint distribution. +fn paint() -> BrushLibrary { + let flat_sweep = group(vec![ + black(band(100.0, 5.0, 64, |x| 0.8 * (x / 100.0 * std::f64::consts::TAU).sin())), + black(polygon(&[(0.0, -2.5), (7.0, -3.8), (18.0, -2.5)])), + black(polygon(&[(78.0, 2.5), (94.0, 4.0), (100.0, 2.5)])), + ]); + let mut dry_drag = vec![]; + for (y, shift) in [(-5.0, 0.0), (-3.2, 4.0), (-1.3, 1.0), (0.8, 6.0), (2.8, 3.0), (4.8, 8.0)] { + dry_drag.push(black(shapes::rectangle(Rect::new(2.0 + shift, y, 35.0 + shift, y + 0.8)))); + dry_drag.push(black(shapes::rectangle(Rect::new(40.0 + shift, y, 75.0 - shift / 2.0, y + 0.8)))); + dry_drag.push(black(shapes::rectangle(Rect::new(80.0 - shift / 2.0, y, 98.0, y + 0.8)))); + } + let mut loaded_stroke = vec![black(band(100.0, 6.0, 64, |x| 1.2 * (x / 100.0 * 2.0 * std::f64::consts::TAU).sin()))]; + for (x, r) in [(12.0, 4.2), (39.0, 3.6), (64.0, 4.8), (88.0, 3.9)] { + loaded_stroke.push(black(shapes::ellipse(Rect::new(x - r, -r - 1.5, x + r, r + 1.5)))); + } + let mut fan_sweep = vec![]; + for i in -2..=2 { + let offset = i as f64; + fan_sweep.push(black(band(100.0, 1.2, 48, |x| offset * (1.4 + x * 0.045) + 0.3 * (x / 100.0 * std::f64::consts::TAU).sin()))); + } + let paint_art = |name: &str, art: Node| Brush { + name: name.into(), + kind: BrushKind::Art(ArtBrush { art, width: 150.0, colorization: Colorization::Tints, ..Default::default() }), + }; + built( + "Paint", + Document::new(100.0, 100.0), + vec![ + paint_art("Flat Sweep", flat_sweep), + paint_art("Dry Drag", group(dry_drag)), + paint_art("Loaded Stroke", group(loaded_stroke)), + paint_art("Fan Sweep", group(fan_sweep)), + ], + ) +} + fn pattern_borders() -> BrushLibrary { let zigzag = black(polygon(&[(0.0, 1.4), (5.0, -2.6), (10.0, 1.4), (10.0, 2.6), (5.0, -1.4), (0.0, 2.6)])); let beads = group(vec![black(shapes::rectangle(Rect::new(0.0, -0.3, 8.0, 0.3))), black(shapes::ellipse(Rect::new(1.5, -2.5, 6.5, 2.5)))]); diff --git a/crates/engine/src/tests/brushlib.rs b/crates/engine/src/tests/brushlib.rs index 4f0b739951..50964bb3a0 100644 --- a/crates/engine/src/tests/brushlib.rs +++ b/crates/engine/src/tests/brushlib.rs @@ -111,6 +111,7 @@ fn the_builtin_libraries_are_original_brushes_generated_in_code() { "ink-and-wash", "calligraphic-nibs", "bristle-brushes", + "paint", "pattern-borders", "scatter-shapes", "game-trails", @@ -131,19 +132,19 @@ fn the_builtin_libraries_are_original_brushes_generated_in_code() { trails["brushes"].as_array().unwrap().iter().map(|b| b["name"].as_str().unwrap()).collect::>(), ["Speed Line", "Dash Trail", "Burst Ray", "Zigzag"] ); - assert_eq!(libs[6]["count"].as_u64(), Some(4)); + assert_eq!(libs[7]["count"].as_u64(), Some(4)); let beams = run(&mut s, "brush.library", json!({"library": "energy-beams"})); assert_eq!( beams["brushes"].as_array().unwrap().iter().map(|b| b["name"].as_str().unwrap()).collect::>(), ["Laser Bolt", "Plasma Arc", "Charge Wave", "Spark Trail"] ); - assert_eq!(libs[7]["count"].as_u64(), Some(4)); + assert_eq!(libs[8]["count"].as_u64(), Some(4)); let dry = run(&mut s, "brush.library", json!({"library": "Dry Media"})); assert_eq!( dry["brushes"].as_array().unwrap().iter().map(|b| (b["name"].as_str().unwrap(), b["type"].as_str().unwrap())).collect::>(), [("Chalk Grain", "art"), ("Graphite Pencil", "art"), ("Wax Crayon", "art"), ("Charcoal Dust", "art")] ); - assert_eq!((libs[8]["name"].as_str(), libs[8]["count"].as_u64()), (Some("Dry Media"), Some(4))); + assert_eq!((libs[9]["name"].as_str(), libs[9]["count"].as_u64()), (Some("Dry Media"), Some(4))); run(&mut s, "file.new", json!({"width": 200, "height": 200})); let id = run(&mut s, "shape.rectangle", json!({"x": 10, "y": 20, "width": 40, "height": 8}))["id"].as_u64().unwrap(); let added = run(&mut s, "brush.addFromLibrary", json!({"library": "energy-beams", "name": "Laser Bolt", "apply": true, "ids": [id]})); @@ -155,6 +156,7 @@ fn the_builtin_libraries_are_original_brushes_generated_in_code() { ("ink-and-wash", "art"), ("calligraphic-nibs", "calligraphic"), ("bristle-brushes", "bristle"), + ("paint", "art"), ("pattern-borders", "pattern"), ("scatter-shapes", "scatter"), ("game-trails", "art"), @@ -299,6 +301,37 @@ fn the_tech_circuit_library_constructs_adds_and_applies_each_brush() { assert_eq!(vectorcraft_brush::library(&reopened), lib.brushes); } +#[test] +fn paint_brushes_draw_distinct_marks_and_survive_a_saved_library() { + let mut s = session(); + let (_, lib) = cmd::brushlib::library(&s, "Paint").unwrap(); + let names = ["Flat Sweep", "Dry Drag", "Loaded Stroke", "Fan Sweep"]; + assert_eq!(lib.brushes.iter().map(|b| b.name.as_str()).collect::>(), names); + let path = run(&mut s, "shape.line", json!({"x1": 10, "y1": 40, "x2": 190, "y2": 40}))["id"].as_u64().unwrap(); + let mut curve = line_to(20.0); + curve.curve_to((60.0, -25.0), (140.0, 25.0), (180.0, 0.0)); + for b in &lib.brushes { + let BrushKind::Art(art) = &b.kind else { panic!("{} is not an art brush", b.name) }; + assert_eq!(art.colorization, vectorcraft_brush::Colorization::Tints); + assert_eq!(art.width, 150.0); + for line in [line_to(2.0), line_to(180.0), curve.clone()] { + let pieces = vectorcraft_brush::stroke_pieces(&lib.doc, b, &line, &black_stroke()); + let points = anchors(&pieces.iter().collect::>()); + assert!(!points.is_empty() && points.iter().all(|p| p.x.is_finite() && p.y.is_finite()), "{}", b.name); + } + let before = undo_len(&s); + let added = run(&mut s, "brush.addFromLibrary", json!({"library": "paint", "name": b.name, "apply": true, "ids": [path]})); + assert_eq!(strs(&added["added"]), [b.name.as_str()]); + assert_eq!(added["applied"], json!([path])); + assert_eq!(undo_len(&s), before + 1); + assert_eq!(doc(&s).node(NodeId(path)).unwrap().appearance.stroke().unwrap().brush.as_deref(), Some(b.name.as_str())); + } + let saved = run(&mut s, "brush.saveLibrary", json!({"names": names})); + let bytes = vectorcraft_format::base64_decode(saved["dataBase64"].as_str().unwrap()).unwrap(); + let reopened = vectorcraft_format::load(&bytes).unwrap(); + assert_eq!(vectorcraft_brush::library(&reopened), lib.brushes); +} + /// Ink and Wash: a tapered ink art brush, a brush pen whose size follows the pen pressure and two /// translucent washes, with names of their own and a few paths of art each. #[test] diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index bb039bb08e..cd22397872 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -7237,3 +7237,8 @@ breakText Glyphs Глифи @msg A fold line is on a non-printing layer. Линия на сгъване е на слой, който не се печата. @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} Панели: {panels}, панти: {hinges}, грешки: {errors}, предупреждения: {warnings} @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer трябва да е "singleLine", "everyLine", "standardSingleLine" или "standardEveryLine" + Paint Боя + Flat Sweep Плосък замах + Dry Drag Сухо влачене + Loaded Stroke Плътен мазок + Fan Sweep Ветрилообразен замах diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index 99f23d313c..14f63f8989 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -7291,3 +7291,8 @@ shape Open Otvoren @msg A fold line is on a non-printing layer. Linija savijanja je na sloju koji se ne štampa. @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} Paneli: {panels}, šarke: {hinges}, greške: {errors}, upozorenja: {warnings} @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer mora biti "singleLine", "everyLine", "standardSingleLine" ili "standardEveryLine" + Paint Boja + Flat Sweep Ravni potez + Dry Drag Suhi potez + Loaded Stroke Bogati potez + Fan Sweep Lepezasti potez diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index c54311799d..d61e9f991a 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -8126,3 +8126,8 @@ breakText Glyphs Glifs @msg A fold line is on a non-printing layer. Una línia de plegat és en una capa que no s’imprimeix. @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} Panells: {panels}, frontisses: {hinges}, errors: {errors}, avisos: {warnings} @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer ha de ser "singleLine", "everyLine", "standardSingleLine" o "standardEveryLine" + Paint Pintura + Flat Sweep Traç pla + Dry Drag Arrossegament sec + Loaded Stroke Traç carregat + Fan Sweep Traç en ventall diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index a5d7bb948a..f6ba8d3996 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -9917,3 +9917,8 @@ breakText Glyphs Glyfy @msg A panel is not joined to the rest by a crease. Panel není se zbytkem spojen žádnou linií bigu. @msg A fold line is on a non-printing layer. Linie skladu je na netisknutelné vrstvě. @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} Panely: {panels}, panty: {hinges}, chyby: {errors}, upozornění: {warnings} + Paint Malba + Flat Sweep Plochý tah + Dry Drag Suchý tah + Loaded Stroke Sytý tah + Fan Sweep Vějířový tah diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 08100f593f..cad239d70d 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -10025,3 +10025,8 @@ breakText Glyphs Glyffer @msg A fold line is on a non-printing layer. En foldelinje ligger på et lag, der ikke udskrives. @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} Paneler: {panels}, hængsler: {hinges}, fejl: {errors}, advarsler: {warnings} @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer skal være "singleLine", "everyLine", "standardSingleLine" eller "standardEveryLine" + Paint Maling + Flat Sweep Fladt strøg + Dry Drag Tørt træk + Loaded Stroke Fyldigt strøg + Fan Sweep Viftestrøg diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 10147b2d45..7db1bdd21c 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -9516,3 +9516,8 @@ breakText Glyphs Glyphen @msg A panel is not joined to the rest by a crease. Ein Feld ist durch keine Rilllinie mit den übrigen verbunden. @msg A fold line is on a non-printing layer. Eine Faltlinie liegt auf einer nicht druckbaren Ebene. @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} Felder: {panels}, Scharniere: {hinges}, Fehler: {errors}, Warnungen: {warnings} + Paint Farbe + Flat Sweep Flacher Schwung + Dry Drag Trockener Zug + Loaded Stroke Satter Pinselstrich + Fan Sweep Fächerschwung diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 1ebf6e5684..2d4a38b47a 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -8100,3 +8100,8 @@ breakText Glyphs Γλύφοι @msg A fold line is on a non-printing layer. Μια γραμμή δίπλωσης βρίσκεται σε επίπεδο που δεν εκτυπώνεται. @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} Πάνελ: {panels}, μεντεσέδες: {hinges}, σφάλματα: {errors}, προειδοποιήσεις: {warnings} @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" το composer πρέπει να είναι "singleLine", "everyLine", "standardSingleLine" ή "standardEveryLine" + Paint Ζωγραφική + Flat Sweep Επίπεδη πινελιά + Dry Drag Στεγνό σύρσιμο + Loaded Stroke Γεμάτη πινελιά + Fan Sweep Βεντάλια diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index a456910a16..ee042d3021 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -8087,3 +8087,8 @@ breakText Glyphs Glifos @msg A fold line is on a non-printing layer. Una línea de plegado está en una capa que no se imprime. @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} Paneles: {panels}, bisagras: {hinges}, errores: {errors}, advertencias: {warnings} @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer debe ser "singleLine", "everyLine", "standardSingleLine" o "standardEveryLine" + Paint Pintura + Flat Sweep Barrido plano + Dry Drag Arrastre seco + Loaded Stroke Trazo cargado + Fan Sweep Barrido en abanico diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index bff46fc0d7..261ef086f5 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -8183,3 +8183,8 @@ breakText Glyphs Merkit @msg A fold line is on a non-printing layer. Taittoviiva on tasolla, jota ei tulosteta. @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} Paneelit: {panels}, saranat: {hinges}, virheet: {errors}, varoitukset: {warnings} @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer on oltava "singleLine", "everyLine", "standardSingleLine" tai "standardEveryLine" + Paint Maalaus + Flat Sweep Tasainen veto + Dry Drag Kuiva veto + Loaded Stroke Runsas siveltimenveto + Fan Sweep Viuhkaveto diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 3be3497f97..4a9f0140ea 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -9902,3 +9902,8 @@ breakText Glyphs Glyphes @msg A fold line is on a non-printing layer. Une ligne de pliage se trouve sur un calque non imprimable. @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} {panels} panneau(x), {hinges} charnière(s), {errors} erreur(s), {warnings} avertissement(s) @msg {_1} × {_2} pixels is too large for GIF (at most 65535 pixels a side): lower the resolution {_1} × {_2} pixels, c’est trop grand pour le GIF (65535 pixels par côté au plus) : réduisez la résolution + Paint Peinture + Flat Sweep Balayage plat + Dry Drag Traînée sèche + Loaded Stroke Trait chargé + Fan Sweep Balayage en éventail diff --git a/crates/ui-egui/src/i18n/gu.tsv b/crates/ui-egui/src/i18n/gu.tsv index c427fc527c..1462bace7a 100644 --- a/crates/ui-egui/src/i18n/gu.tsv +++ b/crates/ui-egui/src/i18n/gu.tsv @@ -4987,3 +4987,8 @@ swatch [Registration] [રજિસ્ટ્રેશન] Standard Single-line Composer સ્ટાન્ડર્ડ સિંગલ-લાઇન કમ્પોઝર Standard Every-line Composer સ્ટાન્ડર્ડ એવરી-લાઇન કમ્પોઝર @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer આમાંથી એક હોવું જોઈએ: "singleLine", "everyLine", "standardSingleLine" અથવા "standardEveryLine" + Paint રંગકામ + Flat Sweep સપાટ લસરકો + Dry Drag સૂકો ઘસારો + Loaded Stroke ઘાટો પીંછીનો ઘસારો + Fan Sweep પંખા જેવો લસરકો diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index cbfb4f51d1..ca12681a52 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -9524,3 +9524,8 @@ theme Appearance अपीयरेंस @msg A panel is not joined to the rest by a crease. कोई पैनल किसी क्रीज़ लाइन से बाकी से जुड़ा नहीं है। @msg A fold line is on a non-printing layer. एक फ़ोल्ड लाइन नॉन-प्रिंटिंग लेयर पर है। @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} पैनल: {panels}, हिंज: {hinges}, एरर: {errors}, वॉर्निंग: {warnings} + Paint चित्रकारी + Flat Sweep सपाट फेरा + Dry Drag सूखा घिसाव + Loaded Stroke गाढ़ा ब्रश स्ट्रोक + Fan Sweep पंखे जैसा फेरा diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 0f81a72036..ce8e5c2907 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -9905,3 +9905,8 @@ breakText Glyphs Glifák @msg A panel is not joined to the rest by a crease. Egy panelt egyetlen bigvonal sem köt a többihez. @msg A fold line is on a non-printing layer. Egy hajtásvonal nem nyomtatható rétegen van. @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} Panelek: {panels}, zsanérok: {hinges}, hibák: {errors}, figyelmeztetések: {warnings} + Paint Festék + Flat Sweep Lapos húzás + Dry Drag Száraz húzás + Loaded Stroke Telített ecsetvonás + Fan Sweep Legyezővonás diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 28ea2b5ab3..e47d5a98bb 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -7252,3 +7252,8 @@ breakText Glyphs Glif @msg A fold line is on a non-printing layer. Sebuah garis lipat berada di lapisan yang tidak dicetak. @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} Panel: {panels}, engsel: {hinges}, galat: {errors}, peringatan: {warnings} @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer harus "singleLine", "everyLine", "standardSingleLine", atau "standardEveryLine" + Paint Cat + Flat Sweep Sapuan Datar + Dry Drag Tarikan Kering + Loaded Stroke Sapuan Tebal + Fan Sweep Sapuan Kipas diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 8f2ed3216c..2566851956 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -9550,3 +9550,8 @@ breakText Glyphs Glifi @msg A panel is not joined to the rest by a crease. Un pannello non è unito al resto da alcuna linea di cordonatura. @msg A fold line is on a non-printing layer. Una linea di piega si trova su un livello non stampabile. @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} Pannelli: {panels}, cerniere: {hinges}, errori: {errors}, avvisi: {warnings} + Paint Pittura + Flat Sweep Passata piatta + Dry Drag Trascinamento secco + Loaded Stroke Tratto carico + Fan Sweep Passata a ventaglio diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index c429f204a1..94e50cdc74 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -9617,3 +9617,8 @@ breakText Glyphs 字形 @msg A panel is not joined to the rest by a crease. パネルがどの筋入れ線でも他とつながっていません。 @msg A fold line is on a non-printing layer. 折り線が印刷しないレイヤーにあります。 @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} パネル: {panels}、ヒンジ: {hinges}、エラー: {errors}、警告: {warnings} + Paint ペイント + Flat Sweep 平筆の一掃き + Dry Drag ドライドラッグ + Loaded Stroke 厚塗りストローク + Fan Sweep 扇形の一掃き diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 414f45171c..03a3c344ac 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -10285,3 +10285,8 @@ font-script Japanese იაპონური @msg A fold line is on a non-printing layer. მოკეცვის ხაზი არაბეჭდვად შრეზეა. @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} პანელები: {panels}, ანჯამები: {hinges}, შეცდომები: {errors}, გაფრთხილებები: {warnings} @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer უნდა იყოს "singleLine", "everyLine", "standardSingleLine" ან "standardEveryLine" + Paint საღებავი + Flat Sweep ბრტყელი მოსმა + Dry Drag მშრალი მოსმა + Loaded Stroke სქელი მონასმი + Fan Sweep მარაოსებრი მოსმა diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index dbda53243f..2807a61dd9 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -9514,3 +9514,8 @@ breakText Glyphs 글리프 @msg A panel is not joined to the rest by a crease. 패널이 어떤 오시선으로도 나머지와 연결되어 있지 않습니다. @msg A fold line is on a non-printing layer. 접는 선이 인쇄되지 않는 레이어에 있습니다. @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} 패널: {panels}, 힌지: {hinges}, 오류: {errors}, 경고: {warnings} + Paint 페인트 + Flat Sweep 평평한 붓질 + Dry Drag 마른 붓질 + Loaded Stroke 두터운 붓질 + Fan Sweep 부채꼴 붓질 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 69aef91cfc..0663cb82b6 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -9953,3 +9953,8 @@ breakText Glyphs Glyphs @msg A panel is not joined to the rest by a crease. Een paneel is door geen rillijn met de rest verbonden. @msg A fold line is on a non-printing layer. Een vouwlijn staat op een laag die niet wordt afgedrukt. @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} Panelen: {panels}, scharnieren: {hinges}, fouten: {errors}, waarschuwingen: {warnings} + Paint Verf + Flat Sweep Vlakke streek + Dry Drag Droge sleep + Loaded Stroke Dikke verfstreek + Fan Sweep Waaierstreek diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 0147515ffe..d0de53fc6c 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -9770,3 +9770,8 @@ breakText Glyphs Glify @msg A panel is not joined to the rest by a crease. Panel nie jest połączony z resztą żadną linią bigowania. @msg A fold line is on a non-printing layer. Linia zgięcia znajduje się na warstwie niedrukowanej. @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} Panele: {panels}, zawiasy: {hinges}, błędy: {errors}, ostrzeżenia: {warnings} + Paint Farba + Flat Sweep Płaskie pociągnięcie + Dry Drag Suche przeciągnięcie + Loaded Stroke Grube pociągnięcie + Fan Sweep Wachlarzowy ślad diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 8201db7ab6..2ac8fa3915 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -9988,3 +9988,8 @@ swatch Yellow Green Verde-amarelado @msg A panel is not joined to the rest by a crease. Um painel não está unido ao restante por nenhuma linha de vinco. @msg A fold line is on a non-printing layer. Uma linha de dobra está em uma camada não imprimível. @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} Painéis: {panels}, dobradiças: {hinges}, erros: {errors}, avisos: {warnings} + Paint Pintura + Flat Sweep Pincelada plana + Dry Drag Arrasto seco + Loaded Stroke Traço carregado + Fan Sweep Pincelada em leque diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index d1593508d3..cece3bfbcf 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -10011,3 +10011,8 @@ shape Open Открытый @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} Панели: {panels}, шарниры: {hinges}, ошибки: {errors}, предупреждения: {warnings} @msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} пикселей — слишком большой размер для PSD (не более {MAX_SIDE} пикселей по стороне): уменьшите разрешение @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer должен быть "singleLine", "everyLine", "standardSingleLine" или "standardEveryLine" + Paint Краска + Flat Sweep Плоский мазок + Dry Drag Сухой протяг + Loaded Stroke Густой мазок + Fan Sweep Веерный мазок diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 5c0420fcd3..e292b118cf 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -9601,3 +9601,8 @@ digits Hindi Hindi @msg A fold line is on a non-printing layer. En falslinje ligger på ett lager som inte skrivs ut. @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} Paneler: {panels}, gångjärn: {hinges}, fel: {errors}, varningar: {warnings} @msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} pixlar är för stort för PSD (högst {MAX_SIDE} pixlar per sida): sänk upplösningen + Paint Färg + Flat Sweep Platt penseldrag + Dry Drag Torrt drag + Loaded Stroke Fylligt penseldrag + Fan Sweep Solfjädersdrag diff --git a/crates/ui-egui/src/i18n/tests.rs b/crates/ui-egui/src/i18n/tests.rs index 97fccd9167..bf6fa61a89 100644 --- a/crates/ui-egui/src/i18n/tests.rs +++ b/crates/ui-egui/src/i18n/tests.rs @@ -501,8 +501,9 @@ fn built_in_library_brush_names_are_in_complete_catalogs() { .flat_map(|(_, lib)| lib.brushes.iter().map(|b| b.name.clone()).collect::>()) .collect(); names.sort(); + let duplicates: Vec<&str> = names.windows(2).filter(|pair| pair[0] == pair[1]).map(|pair| pair[0].as_str()).collect(); + assert_eq!(duplicates, ["Zigzag"], "only the established Pattern Borders / Game Trails name is shared"); names.dedup(); - assert_eq!(names.len(), 46, "{names:?}"); let mut bad = vec![]; for lang in LANGUAGES.iter().filter(|lang| lang.complete_menus) { let missing: Vec<&String> = names.iter().filter(|n| lang.catalog().plain(n).is_none()).collect(); diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 910a7fc5b1..b11502fb7f 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -9875,3 +9875,8 @@ breakText Glyphs Glifler @msg A panel is not joined to the rest by a crease. Bir panel geri kalanlara hiçbir pilyaj çizgisiyle bağlı değil. @msg A fold line is on a non-printing layer. Bir katlama çizgisi yazdırılmayan bir katmanda. @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} Paneller: {panels}, menteşeler: {hinges}, hatalar: {errors}, uyarılar: {warnings} + Paint Boya + Flat Sweep Düz fırça izi + Dry Drag Kuru sürükleme + Loaded Stroke Yoğun fırça izi + Fan Sweep Yelpaze izi diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index dbd6d2609e..cdde39fcce 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -9526,3 +9526,8 @@ breakText Glyphs Гліфи @msg A panel is not joined to the rest by a crease. Панель не з’єднана з рештою жодною лінією біговки. @msg A fold line is on a non-printing layer. Лінія згину лежить на шарі, що не друкується. @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} Панелі: {panels}, шарніри: {hinges}, помилки: {errors}, попередження: {warnings} + Paint Фарба + Flat Sweep Плоский мазок + Dry Drag Сухий протяг + Loaded Stroke Густий мазок + Fan Sweep Віяловий мазок diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 519c5d8f0d..081dedde4c 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -7759,3 +7759,8 @@ breakText Glyphs Glyph @msg {width} × {height} pixels is too large for Targa (at most 65535 pixels a side): lower the resolution {width} × {height} điểm ảnh quá lớn cho Targa (tối đa 65535 điểm ảnh mỗi cạnh): hãy giảm độ phân giải @msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} điểm ảnh quá lớn cho PSD (tối đa {MAX_SIDE} điểm ảnh mỗi cạnh): hãy giảm độ phân giải @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer phải là "singleLine", "everyLine", "standardSingleLine" hoặc "standardEveryLine" + Paint Sơn + Flat Sweep Nét quét phẳng + Dry Drag Nét kéo khô + Loaded Stroke Nét cọ đậm + Fan Sweep Nét quét hình quạt diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index c6696a9ec6..4c7fe63028 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -9758,3 +9758,8 @@ breakText Glyphs 字形 @msg A fold line is on a non-printing layer. 一条折线位于不打印的图层上。 @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} 面板:{panels},铰链:{hinges},错误:{errors},警告:{warnings} @msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} 像素对 PSD 而言过大 (每边最多 {MAX_SIDE} 像素):请降低分辨率 + Paint 绘画 + Flat Sweep 平刷 + Dry Drag 干拖 + Loaded Stroke 厚涂笔触 + Fan Sweep 扇形笔触 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 1480422931..3c3afe5861 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -9568,3 +9568,8 @@ breakText Glyphs 字符 @msg A fold line is on a non-printing layer. 一條摺線位於不列印的圖層上。 @msg Panels: {panels}, hinges: {hinges}, errors: {errors}, warnings: {warnings} 面板:{panels},鉸鏈:{hinges},錯誤:{errors},警告:{warnings} @msg {what} would print on more than {MAX_TILES} tiles: scale it down {what} 會列印在超過 {MAX_TILES} 個拼貼上:請縮小 + Paint 繪畫 + Flat Sweep 平刷 + Dry Drag 乾拖 + Loaded Stroke 厚塗筆觸 + Fan Sweep 扇形筆觸 diff --git a/crates/ui-egui/src/panels/tests_brush_libraries.rs b/crates/ui-egui/src/panels/tests_brush_libraries.rs index 87fe34953f..8cb564e242 100644 --- a/crates/ui-egui/src/panels/tests_brush_libraries.rs +++ b/crates/ui-egui/src/panels/tests_brush_libraries.rs @@ -196,6 +196,7 @@ fn the_window_menu_and_the_brushes_panel_open_brush_libraries() { json!("ink-and-wash"), json!("calligraphic-nibs"), json!("bristle-brushes"), + json!("paint"), json!("pattern-borders"), json!("scatter-shapes"), json!("game-trails"), @@ -232,6 +233,17 @@ fn the_window_menu_and_the_brushes_panel_open_brush_libraries() { click(&mut app, &ctx, "Circuit Trace", Modifiers::NONE, 2.0); assert!(has(&app, "Circuit Trace") && !has(&app, "Bus Lines")); assert_eq!(undo_len(&app), undo + 1); + let r = app.run("window.brushLibrary", json!({"library": "Paint"})).unwrap(); + assert_eq!((r["open"].as_str(), r["count"].as_u64()), (Some("paint"), Some(4))); + let path = app.run("shape.line", json!({"x1": 10, "y1": 100, "x2": 180, "y2": 100})).unwrap()["id"].as_u64().unwrap(); + let undo = undo_len(&app); + click(&mut app, &ctx, "Flat Sweep", Modifiers::NONE, 3.0); + assert!(has(&app, "Flat Sweep") && !has(&app, "Dry Drag")); + assert_eq!(undo_len(&app), undo + 1); + assert_eq!( + app.session.doc().unwrap().doc.node(vectorcraft_doc::NodeId(path)).unwrap().appearance.stroke().unwrap().brush.as_deref(), + Some("Flat Sweep") + ); // Without brushes there is nothing to save. let all: Vec = vectorcraft_brush::library(&app.session.doc().unwrap().doc).into_iter().map(|b| b.name).collect(); app.run("brush.delete", json!({ "names": all })).unwrap(); diff --git a/docs/mcp.md b/docs/mcp.md index 092faabc4c..8348f967b1 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -5035,8 +5035,8 @@ error. ## Brush libraries -Brush libraries are read-only sets of brushes: ten generated in code (Art Ribbons, Ink and Wash, Calligraphic Nibs, Bristle -Brushes with one bristle brush for each tip shape, Pattern Borders, Scatter Shapes, Game Trails, Energy Beams, and Dry Media with the Chalk Grain, Graphite Pencil, Wax Crayon and +Brush libraries are read-only sets of brushes: eleven generated in code (Art Ribbons, Ink and Wash, Calligraphic Nibs, Bristle +Brushes with one bristle brush for each tip shape, Paint with Flat Sweep, Dry Drag, Loaded Stroke and Fan Sweep, Pattern Borders, Scatter Shapes, Game Trails, Energy Beams, and Dry Media with the Chalk Grain, Graphite Pencil, Wax Crayon and Charcoal Dust art brushes, id `dry-media`, and Tech Circuit with Circuit Trace (art), Bus Lines and Terminal Nodes (pattern), id `tech-circuit`), the `.vectorcraft` files in the user library folder of the desktop app (User Defined) and the brushes of any document loaded with `brush.loadLibrary` (a document without brushes of its own has the default ones). `brush.libraries` lists them (`id`, `name`, `category`: `builtIn`, `user` or `loaded`, `count`) and diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index e9fc9a6820..8e539775c9 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1102,6 +1102,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Brush libraries** ([public source](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/create-new-brush-libraries.html), [import](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/import-brushes-from-brush-libraries-or-other-files.html), [Brushes panel](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/brushes-panel-overview.html)): Window › Brush Libraries, the Brushes panel's Brush Libraries Menu and its menu's Open Brush Library open each library in a library panel of its own, as swatch, graphic style and symbol libraries do. The built-in libraries (Art Ribbons, Ink and Wash, Calligraphic Nibs, Bristle Brushes, Pattern Borders, Scatter Shapes, Game Trails, Energy Beams, Dry Media, Tech Circuit) are original brushes generated in code (`crates/engine/src/cmd/brushlib.rs`); Striped Ribbon's art is filled with the library's own pattern and Sparkles scatters the library's own symbol; Ink and Wash adds ink and wash brushes (the [help page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/about-brushes.html) lists an Ink brush library of strokes with varied thickness and texture; the names, shapes and opacities are VectorCraft's own): Tapered Ink, an art brush broad near its start that thins to a fine tip; Brush Pen, a calligraphic brush whose size follows the pen pressure; and Soft Wash and Pooling Wash, art brushes of translucent gray layers that take the stroke color as tints; Game Trails adds motion art brushes (Speed Line, Dash Trail, Burst Ray, Zigzag); Energy Beams adds laser and plasma art brushes (Laser Bolt, Plasma Arc, Charge Wave, Spark Trail); Dry Media adds grainy art brushes (Chalk Grain, Graphite Pencil, Wax Crayon, Charcoal Dust). A click on a brush adds it to the document's Brushes as one undo step with every resource its art uses (patterns, symbols, swatches, graphic styles, images), makes it the current brush and, with paths selected, applies it to them in the same step; a brush the document already has is not added again and a different brush of the same name comes in numbered ("Wave 2"). Shift/Cmd-clicks select brushes for Add to Brushes; a brush dragged onto a path is added and applied to it, and one dragged onto the Brushes panel is added. Save Brushes… / the Brushes panel's Save Brush Library… write the document's brushes (or the selected ones) as a `.vectorcraft` library into the `Brushes` folder next to the preferences, listed under User Defined, or to a file; Other Library… reads the brushes of any document VectorCraft opens. Thumbnails, in the library panels, the Brushes panel and Brush Options, render brush art with the patterns and symbols it uses. Copying brushed art now carries the patterns and symbols its brush's art uses too. Tests: `crates/engine/src/tests/brushlib.rs`, `crates/ui-egui/src/panels/tests_brush_libraries.rs`, `panels::brushes::tests::library_brush_previews_show_the_patterns_their_art_uses`, `canvas::tests::a_library_brush_dropped_on_a_path_is_added_and_applied_in_one_step`. - **Bristle Brushes library** ([What's new](https://helpx.adobe.com/illustrator/desktop/new-features/whats-new.html), [About brushes](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/about-brushes.html)): Window › Brush Libraries › Bristle Brushes holds ten bristle brushes, one for each tip shape (Fine Liner, Pointed Flat, Stubby Round, Dry Scrub, Soft Dome, Filbert, Angled Round, Angled Flat, Fan Blender, Grass Fan). The brushes, their names and their values are VectorCraft's own, and every value lies inside the range the bristle brush keeps (`brush.libraries`, `brush.addFromLibrary`; `the_bristle_brushes_library_covers_every_tip_shape_within_the_bristle_ranges`). - **Tech Circuit library:** Circuit Trace is a chamfered art brush with 45-degree elbows and terminal pads; Bus Lines repeats three parallel conductor lanes; Terminal Nodes repeats solder pads, circular test points and connecting leads. Original vector geometry generated in code, with Tints colorization and continuous pattern tile edges. Evidence: `the_tech_circuit_library_constructs_adds_and_applies_each_brush` in `crates/engine/src/tests/brushlib.rs` covers listing, finite geometry on straight, curved, short and closed paths, add/apply, undo/redo, deduplication and saved-library round trips. G5 remaining estimate 3–13 h (estimated); area scores unchanged. + - **Paint library** ([About brushes](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/about-brushes.html)): Window › Brush Libraries › Paint offers Flat Sweep, Dry Drag, Loaded Stroke and Fan Sweep. These original art brushes stretch broad, broken, loaded and fanned vector marks along a path and take the stroke color as tints. The public source describes the Paint category's varied thickness, textured edges and natural effects; the preset designs and names are VectorCraft's own. Evidence: `paint_brushes_draw_distinct_marks_and_survive_a_saved_library` in `crates/engine/src/tests/brushlib.rs` covers finite output on short, long and curved paths, add/apply and saved-library reopening; `the_window_menu_and_the_brushes_panel_open_brush_libraries` covers opening and clicking from the UI. - **Dry Media library** ([help page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/about-brushes.html)): Window › Brush Libraries › Dry Media holds four art brushes with textured strokes like dry drawing materials, each 100 pt long: Chalk Grain (about 8 pt high), Graphite Pencil (about 2.3 pt), Wax Crayon (about 5.5 pt) and Charcoal Dust (about 7 pt). The brushes, their names, sizes and art are VectorCraft's own: each is filled vector paths from a fixed seed, at most 80 paths and 500 anchors, stretched along the path with Tints colorization, and the chalk and crayon art has even-odd gaps where the paper shows (`brush.libraries`, `brush.addFromLibrary`; `the_dry_media_library_holds_grainy_art_brushes_with_bounded_art`). - **Brush names in library panels**: a built-in brush library's panel shows its brushes' names in the UI language, in its list rows and tooltips, and its Find field matches the name shown or the English name. This is VectorCraft's own rule. A User Defined or Other Library… library's brushes, and the document's Brushes panel, show names as they are stored. A click, a drag, Add to Brushes and `brush.addFromLibrary` still use the English name, so the brush comes into the document under that name (`built_in_library_brushes_are_listed_in_the_ui_language`, `built_in_library_brush_names_are_in_complete_catalogs`). - A canvas context menu: right-click selects the object under the pointer and lists what applies to the selection (Undo/Redo, clipboard, group, isolation, join, Remove Anchor Points when anchors are selected, masks, compound paths, guides, Transform, Arrange, Select, Export Selection, and on type Bullets and Numbering and Spelling › Auto Spell Check, checked while it is on), or the view commands on empty canvas. From 51cf404cee3b2dafe1e35dc44b05b9247ddb8714 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 20:23:57 -0800 Subject: [PATCH 2/9] Docs: count Paint among the built-in brush libraries The area rows, the bundled-content row, the G5 entry and the UI row now name Paint and count eleven built-in brush libraries, and the ROADMAP progress log has a line for it. --- ROADMAP.md | 1 + docs/gaps.md | 6 +++--- docs/target-app-parity.md | 6 +++--- docs/ui-parity.md | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index b2ebdb0545..84f26b75f7 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -126,6 +126,7 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap - 2026-11-14: Built-in symbol library Weather Icons: adds a sixth procedural symbol library (Window › Symbol Libraries, the Symbols panel's Symbol Libraries Menu) containing six original vector symbols (Sun, Moon, Cloud, Rain, Thunder, Snow) generated in code without default 9-slice guides (part of Gap 5). Headline numbers unchanged. - 2026-11-14: Built-in Tech Circuit brush library: Circuit Trace (chamfered art with 45-degree elbows and terminal pads), Bus Lines (parallel conductor pattern) and Terminal Nodes (repeating solder pads, test points and leads), all original geometry generated in code. Ten built-in brush libraries; G5 remaining estimate 3–13 h (estimated), headline numbers unchanged. +- 2026-11-18: Built-in Paint brush library: Flat Sweep, Dry Drag, Loaded Stroke and Fan Sweep, original art brushes generated in code that take the stroke color as tints. Eleven built-in brush libraries; headline numbers unchanged. - 2026-11-05: Window › Toolbars › Keep Tools Beside the Canvas, off by default, docks the Tools panel between left-side panels and the canvas instead of at the window's left edge, and the canvas's left edge then also docks a floating Tools panel (`window.toolsBesideCanvas`, #5395). Workspaces keep the setting; workspaces saved without it keep Tools at the window's edge. An optional VectorCraft layout choice; headline numbers unchanged. - 2026-11-17: The canvas's left edge docks a floating Tools panel whichever way Keep Tools Beside the Canvas is set: a drop there, right of panels docked on the left, turns the setting on, and a drop on the window's left edge turns it off (#7837). Headline numbers unchanged. diff --git a/docs/gaps.md b/docs/gaps.md index 96a94b325c..ddc43e0131 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -671,8 +671,8 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi libraries ([public source](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/create-new-brush-libraries.html), [import](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/import-brushes-from-brush-libraries-or-other-files.html)): Window › Brush Libraries and the Brushes panel's Brush Libraries Menu open each library in a library panel of - its own (ten original libraries generated in code: Art Ribbons, Ink and Wash, Calligraphic Nibs, Bristle Brushes (one - bristle brush for each tip shape), Pattern Borders, Scatter Shapes, Game Trails, Energy Beams, Dry Media (grainy chalk, pencil, crayon and charcoal art brushes) and Tech Circuit (Circuit Trace, Bus Lines and Terminal Nodes); User Defined; Other Library… reads the brushes of any document VectorCraft opens); a + its own (eleven original libraries generated in code: Art Ribbons, Ink and Wash, Calligraphic Nibs, Bristle Brushes (one + bristle brush for each tip shape), Pattern Borders, Scatter Shapes, Game Trails, Energy Beams, Dry Media (grainy chalk, pencil, crayon and charcoal art brushes), Tech Circuit (Circuit Trace, Bus Lines and Terminal Nodes) and Paint (Flat Sweep, Dry Drag, Loaded Stroke and Fan Sweep); User Defined; Other Library… reads the brushes of any document VectorCraft opens); a click adds a brush to the document's Brushes with the patterns, symbols and other resources its art uses, as one undo step (applied to the selected paths in the same step), dragging one onto a path adds and applies it and @@ -694,7 +694,7 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi Fine Grain, Canvas Weave, Burlap Sack, Cracked Glaze, Mosaic Floor, Quilted Squares, Leaded Glass and Damp Paper, painted with the texture effects; User Defined; Other Library…; `graphicStyle.libraries`, `graphicStyle.addFromLibrary`). -- **Missing:** more built-in brush libraries beyond the ten shipped (and further graphic-style libraries beyond the eleven shipped, and further symbol libraries beyond Basic +- **Missing:** more built-in brush libraries beyond the eleven shipped (and further graphic-style libraries beyond the eleven shipped, and further symbol libraries beyond Basic Shapes, UI Frames, Map Markers, Inventory Icons, Skill Icons and Weather Icons; original, generated in code, never Adobe's); dynamic symbols' `.ai` read and write. - **Estimate:** 3–13 h (estimated). diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index fcb92c0d5c..2e89aae85a 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -255,7 +255,7 @@ dominate; 3D, graphs and automation are specialist). They sum to 105. Feature de | Drawing tools (Pen, Curvature, Pencil, shapes, Shaper) | 7 | 85% | Shaper construction widget, Pencil/Pen nuances, Blob Brush options, Touch Type, Dimension tool; see [ui-parity.md](ui-parity.md) | 8–13 | estimated; Curvature point display regression-tested (#1236, in part); Polygon/Star exact-size count persistence regression-covered; Live Corners' Relative rounding done (#3091), score unchanged; Copy and Cut with the Pen or Curvature tool take the anchors a Cmd/Ctrl-lent Direct Selection picked (#6123), score and hours unchanged; the Pen, Smart Pen and Curvature tool show the measurement readout with the rubber band off (#7043), score, gaps and hours unchanged | | Path operations, Pathfinder, Shape Builder, Live Paint | 5 | 80% | Shape Builder on the reporter's file (#937: art past 4,096 segments is cut by lines again; unconfirmed on the file itself); gap detection shares Live Paint’s finder, with a 72 pt custom cap and the existing options; Live Paint Gap Options | 4–8 | estimated; Shape Builder Gap Detection shares Live Paint’s spatial gap finder and temporary merge bridges (#2526); Custom is capped at 72 pt in the existing options dialog (lowered from 86%: open issues); compound attributes regression-tested (#1197); single-result source names survive SVG export/import (#1293), with [SVG ID semantics](https://www.w3.org/TR/SVG2/struct.html#IDAttribute) and original-shape tests; Simplify component selection and preview regression-tested (#1272); Simplify of a Direct Selection part of a path regression-tested (`tests/simplify_part.rs`); Divide open-cutting-path geometry and appearance regression-tested (#1307); the Shape Builder's edge-source grid is bounded in memory and files a segment once per cell (`planar.rs` test `rect_index_holds_a_bounded_number_of_references`); live compound shapes (Make, Alt-click, member Shape Modes, Release, Expand, saved and exported) regression-tested (#4522); Live Paint Bucket face drags, including narrow faces and one Undo, regression-tested (#6373) | | Colour, swatches, gradients, patterns, mesh, recolor | 7 | 92% | Picker Lab entry, picker libraries and Assign-row menus complete the deferred #4028 UI paths (#8031); scores and estimates unchanged; Eyedropper copies effective character dimensions across text transforms (#6404); 30.0's gradient additions are done (dither, perceptual blending, presets); freeform gradients in SVG/PDF, mixed spot/process gradients in SVG, PDF gradients mixing a spot color with RGB or Lab stops, and dithered spot gradient fills and Perceptual spot gradients with RGB or Lab stops other than white or more than 4,096 stops on their curve, which PDF export writes as images in process colors| 4–7 | estimated; Recolor model selection is available through the engine and MCP (#2520), and the dialog's color sliders (HSB, RGB, CMYK, Lab, Tint for a spot color) edit the selected row's new color in its mode, and the Edit tab's Global Adjust sliders (Saturation, Brightness, Temperature, Luminosity, -100% to 100%) change every recolored color at once (lowered from 96%: target moved); unpainted zero-width stroke restoration fixed (#1253), score and hours unchanged; Eyedropper source reads regression-tested (#1251); screen-bounded Recolor Edit chip list (#3416), score and hours unchanged; a point on a gradient mesh's outline locates on its edge on every side (#7006: `mesh_locate_takes_a_point_on_any_side_of_the_outline`, `mesh_add_line_exactly_on_the_edge_needs_no_tolerance`), score and hours unchanged; Color panel spectrum grows with the resized panel (#8005) | -| Strokes, brushes, width profiles | 5 | 88% | Shift-double-click adjoining adjustment is implemented; brush libraries are done (ten generated libraries including Tech Circuit, Ink and Wash, Bristle Brushes, Game Trails, Energy Beams and Dry Media, User Defined, Other Library…, Save Brushes); Art brush Overlap and Pattern brush auto corners are done; remaining: pen pressure on macOS, Stylus Wheel, more built-in brush libraries, tilt, bearing and rotation for Art, Pattern and Bristle brushes and on native Wayland and the web | 8–15 | estimated; width-point creation and adjoining adjustment regression-tested; dialog layout reviewed; evidence below; finite-arithmetic follow-up regressions and full CI passed (evidence below) | +| Strokes, brushes, width profiles | 5 | 88% | Shift-double-click adjoining adjustment is implemented; brush libraries are done (eleven generated libraries including Paint, Tech Circuit, Ink and Wash, Bristle Brushes, Game Trails, Energy Beams and Dry Media, User Defined, Other Library…, Save Brushes); Art brush Overlap and Pattern brush auto corners are done; remaining: pen pressure on macOS, Stylus Wheel, more built-in brush libraries, tilt, bearing and rotation for Art, Pattern and Bristle brushes and on native Wayland and the web | 8–15 | estimated; width-point creation and adjoining adjustment regression-tested; dialog layout reviewed; evidence below; finite-arithmetic follow-up regressions and full CI passed (evidence below) | | Appearance, transparency, graphic styles, masks | 5 | 97% | raster effect reach in preview bounds | 1–2 | estimated; Transform typing, sliders, preview, and undo are covered in `crates/ui-egui/src/panels/tests_appearance.rs` | | 3D and Materials (and Turntable) | 4 | ~25% | live Revolve with automatic smooth vector shading and default-on continuous circular caps, Extrude & Bevel (twist, taper, caps, five bevel shapes), Inflate and Rotate with Position presets (colored Inflate uses smooth membrane lighting; white-light Inflate retains its existing shading; Extrude & Bevel and Rotate retain planar shading; one to ten colored lights, shared neutral ambient, painter visibility); materials, light presets, shadows, ray tracing, the rest of 3D Classic (Map Art), Turntable views, textures, map art and shading in 3D export | 30–55 | estimated (Extrude & Bevel, Inflate and Rotate added 2026-10-12); every 3D seam has round joins (2026-11-12, [three-d.md](three-d.md#seams)), score, gaps and hours unchanged | | Type core | 9 | 80% | Auto-leading style resets are implemented; Hyphenation… and Justification… options are done (#2310, #2755), and a paragraph's Auto Leading also sets the Character panel's Leading, the Alt+↑/↓ leading nudge and Fill with Placeholder Text; remaining: Optical Margin Alignment, Middle Eastern features beyond bidi layout (the Middle Eastern & South Asian and Standard composers are done per paragraph, #4935; `.ai`/EPS/PDF files carry no composer), optional group font-size preservation; transformed character controls fixed (#1034), see [type-parity.md](type-parity.md) | 14–19 | estimated; eleven-language pattern hyphenation in both composers, with grapheme and shaping-cluster protection (#4947, `hyphen::tests` and `layout::wrapping_tests`); Sanskrit patterns pending an allowlisted source; recent-font groups in font pickers (#3515); full-name font matches regression-tested (#1258); mixed paragraph alignment indication implemented; headless regressions, full integration CI and visual review pass; localized legacy family-name fallback with loaded/catalog regressions (#2208); Fractional Widths per type object regression-tested; color emoji fonts with bitmap glyphs (`sbix`, `CBDT`) draw and export; threading ports: every selected area type and type on a path shows its in and out ports (empty, arrow, red "+"), and the Selection tool threads from either, the in port into a frame before it, and a double-click on a threaded port breaks the thread there (`threads::tests::break_splits_the_thread_and_the_story_flows_into_the_first_part`, `select::tests::a_double_click_on_a_threaded_port_breaks_the_thread`, `canvas::tests::a_double_click_on_a_threaded_out_port_breaks_the_thread`) (#2572; `select::tests::a_click_on_the_in_port_threads_into_a_frame_before_it`, `text::tests::selected_type_shows_its_ports_in_each_state`, `threads::tests::add_before_threads_the_story_from_the_new_frame_into_the_clicked_one`, live screenshot); the Glyphs panel highlights and scrolls to the character selected with the Type tool (#4908, `panels::glyphs` tests); the OpenType panel lists only `ss01`–`ss20` sets present in the selected font and uses its custom names when supplied; Type-range desktop Copy publishes styled art and keeps font family, size and color on canvas Paste after editing (#5636); paint-only Arabic harakat keep joining with conditional GDEF-mark ownership and Insert Kashidas base-letter paint (`tests::harakat`) | @@ -524,7 +524,7 @@ about 1–1.5 agent-hours each, so the other rows (estimated on the older scale) | Drawing tools | 7 | 86% | rough-square Shaper recognition and orientation steps corrected; editable Shaper Groups landed; Pencil: Alt key toggles to Smooth Tool (#2001); remaining: Shaper construction widget/gesture refinements, pencil and the remaining pen modifier nuances, Blob Brush Merge Only with Selection, Touch Type, Live Corners' Relative rounding | 7–12 | | Path operations, Pathfinder, Shape Builder, Live Paint | 5 | 86% | Live Paint gap options, Shape Builder gap detection, options (Tool Options dialog, clicking a stroke in merge mode) and Shift-drag marquee | 3–6 | | Colour, swatches, gradients, patterns, mesh, recolor | 7 | 96% | Picker Lab entry, picker libraries and Assign-row menus complete the deferred #4028 UI paths (#8031); scores and estimates unchanged; Library panels' lists (swatch, Color Book, brush, symbol and graphic style libraries) fill a taller panel above its footer (#2992; scores and estimates unchanged); Swatches list fills a taller panel above its footer (#1638; `the_list_fills_a_tall_panel_above_its_footer`; scores and estimates unchanged); freeform gradients in SVG/PDF and mixed spot/process gradients in SVG (exported as stops; PDF export keeps the spot inks in a DeviceN shading, except next to RGB or Lab stops; dithered fills and Perceptual gradients with RGB or Lab stops other than white or more than 4,096 stops on their curve are written as images in process colors), pattern fills in Expand | 2–4; Eyedropper source reads regression-tested (#1251) | -| Strokes, brushes, width profiles | 5 | 90% | more built-in brush libraries (ten generated in code including Tech Circuit, Ink and Wash, Bristle Brushes, Game Trails, Energy Beams and Dry Media are done; Art brush Overlap and Pattern brush auto corners are done), pen pressure on macOS (the windowing layer reports none there), Stylus Wheel, tilt, bearing and rotation for Art, Pattern and Bristle brushes and on native Wayland and the web | 8–15 | +| Strokes, brushes, width profiles | 5 | 90% | more built-in brush libraries (eleven generated in code including Paint, Tech Circuit, Ink and Wash, Bristle Brushes, Game Trails, Energy Beams and Dry Media are done; Art brush Overlap and Pattern brush auto corners are done), pen pressure on macOS (the windowing layer reports none there), Stylus Wheel, tilt, bearing and rotation for Art, Pattern and Bristle brushes and on native Wayland and the web | 8–15 | | Appearance, transparency, graphic styles, masks | 5 | 98% | Graphic Styles list fills a taller panel above its footer (#2992; scores and estimates unchanged); raster effect reach in preview bounds (flattener presets apply in PDF, EPS and print) | 1–2 | | Live vector effects | 5 | 85% | Outline Object, Pathfinder Hard/Soft Mix and Trap (since done: #3061, #3063, #3785), SVG Filters, Transform Patterns and Scale Strokes & Effects on a fill's or stroke's own Transform effect | 6–10 | | 3D and Materials | 4 | ~25% | Initial Revolve, Extrude & Bevel, Inflate and Rotate, with simple lighting; materials, light presets, shadows, ray tracing, Rotate (Classic), Map Art and more complete visibility remain | 25–45 | @@ -576,7 +576,7 @@ since 2026-10-01. | **Interaction fidelity:** modifiers, cursors, small behaviours | ~30–40% | The dedicated pass hasn't started, and there has been no side-by-side session with Illustrator yet. A power user notices this first | | **Look & feel** | ~75–80% | Measured against Illustrator 2026 screenshots (2026-10-02); the panels added since haven't been re-measured | | **File interop** | ~85% | SVG/SVGZ, PDF and PDF-compatible `.ai` (and legacy version 7 `.ai` out, keeping layers, groups and type as text), EPS, DXF, EMF/WMF, raster formats, PSD export and PSD/PSB placement (merged image), Place and Links, Package, Print, clipboard flavours. Affinity documents (Affinity 1–3) open natively as editable art, checked against 51 pinned public files (33 current `.af`), with selected saved-thumbnail comparisons and every-board native/SVG/PDF/PSD checks for current files; Affinity export is missing and effects, adjustments and brushes don't import. Affinity isn't an Illustrator feature, so this doesn't raise the parity score. The editing copy inside an Illustrator EPS or `.ai` is read for its structure: layers, groups, names, hidden objects and type, colours, gradients, transparency, images and every artboard (see Out of scope for what it doesn't read yet); DWG has no open spec | -| **Bundled content:** brush, symbol, style and swatch libraries | ~46% | Ours are original and generated in code, and far fewer than Illustrator ships; symbol libraries have six (Basic Shapes, UI Frames with default 9-slice, Map Markers, Inventory Icons, Skill Icons, Weather Icons), graphic style libraries eleven (including Game HUD, Status Effects and Neon & Glow) and brush libraries ten (Art Ribbons, Ink and Wash, Calligraphic Nibs, Bristle Brushes, Pattern Borders, Scatter Shapes, Game Trails, Energy Beams, Dry Media, Tech Circuit) beside User Defined and Other Library… | +| **Bundled content:** brush, symbol, style and swatch libraries | ~46% | Ours are original and generated in code, and far fewer than Illustrator ships; symbol libraries have six (Basic Shapes, UI Frames with default 9-slice, Map Markers, Inventory Icons, Skill Icons, Weather Icons), graphic style libraries eleven (including Game HUD, Status Effects and Neon & Glow) and brush libraries eleven (Art Ribbons, Ink and Wash, Calligraphic Nibs, Bristle Brushes, Paint, Pattern Borders, Scatter Shapes, Game Trails, Energy Beams, Dry Media, Tech Circuit) beside User Defined and Other Library… | | **Performance** | unverified | Multithreaded, off-thread rendering and caches are in place. The last budget run (2026-10-01, loaded machine) measured 290 ms for a 50k-path fit against a 16 ms budget. Re-run `vectorcraft-cli perf` on an idle machine | | **Robustness** | good, new | ~2,840 tests, property tests, no panics in shipped code (lints, the `guard` safety net, import fuzzing), Data Recovery. Missing: a corpus of real-world files, Windows/Linux/browser QA | | **Platforms and 1.0 polish** | ~60% | The macOS app and the web build work, and Finder opens every readable format with the macOS app (#295, #354); on macOS the menus are in the system menu bar, laid out as a Mac app's, with the in-window menus as a fallback (`--in-window-menus`; verified on Windows and by cross-compilation, not yet by hand on a Mac); hybrid-graphics laptops render on the power-saving GPU by default on Windows and macOS (#306), and Windows starts on Direct3D 12, falling back to OpenGL, and loads no Vulkan driver unless `WGPU_BACKEND` asks for it (#545: Vulkan flickered black on an Intel GPU, DX12 and OpenGL didn't; #806: a faulty Vulkan driver crashed the app before its window appeared; verified by unit tests and the reporter's runs with `WGPU_BACKEND`), and Linux on the GPU the desktop runs on, since a Wayland compositor may refuse frames from the other one; a window that fails on its GPU while starting up starts again on the next one instead of crashing (#502; the dual-GPU Wayland case is verified by unit tests and cross-compilation, not on such hardware); web drops land in the document they were dropped on (#359); desktop drops carry no pointer position (winit 0.30), so a dropped document opens as a tab of its own and a picture or text is placed in the middle of the view, while the web places anything dropped on the canvas and opens what is dropped off it, as Illustrator does (#472); a web page that loses its WebGPU device or WebGL context restarts its graphics with the same documents (#369); on Linux/Wayland the clipboard reads the compositor's own (data-control) and copied image files paste, but files can't be dropped on the window under native Wayland until eframe moves to winit 0.31 (#398; the Wayland side is verified by compilation only), so Preferences › Performance › Linux Display Server › X11 (XWayland) opens the window through XWayland, where drops work (#1151; verified by unit tests and cross-compilation, not on a Wayland desktop); on Linux the Paste menu checks the system clipboard on a background thread, so a clipboard owner that never answers no longer freezes the window, while Windows and macOS keep their quick in-line check (#510; the X11 hang verified by the contributor, here by headless tests); on KDE Plasma 6.3+ under Wayland, pens and pen displays reach the app only under XWayland (`WAYLAND_DISPLAY=`) or with KWin's `KWIN_WAYLAND_EMULATE_TABLET=1`, since winit 0.30 has no Wayland tablet input (#491, not verified on hardware); Windows/Linux packaging and accessibility are pending | diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 8ddaf7c662..cbef0749e2 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -451,7 +451,7 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po | Info panel follows the tool in use: W and H show the change in x and y, with the distance and the angle, while the selection moves or the Gradient tool draws a vector; the Scale tool's percentages; the center and angles of a Rotate, Reflect or Shear tool drag; the Zoom tool's magnification; the Paintbrush's brush. W and H follow Use Preview Bounds, several selected objects show only the paint and type they share, and Show Options names a tint or a gradient swatch | done | `info.readout`; `Tool::readout`; behavior from the Info panel overview in the [archived user guide](https://web.archive.org/web/20220911143322/https://helpx.adobe.com/pdf/cs6/illustrator_reference.pdf#page=76); number formats, the rows shown between drags and the Direct Selection and Group Selection readouts are VectorCraft's own | | Make Compound Path on a group (such as outlined type) keeps its backmost path's paint; compound paths joined into one keep their holes | done | #1537 | | Symbol libraries: Window › Symbol Libraries (Basic Shapes, UI Frames, Map Markers, Inventory Icons, Skill Icons, User Defined, Other Library…, Save Symbols…) and the Symbols panel's Symbol Libraries Menu button and its menu's Open Symbol Library / Save Symbol Library…; a click on a library symbol adds it to the document's Symbols (one undo step, it becomes the current symbol), Shift/Cmd-clicks select for Add to Symbols, and a symbol dragged onto the canvas is added and placed where it is dropped | done | [public source](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/create-or-import-symbol-libraries.html), [Symbols panel options](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/symbols-panel-options.html), [placing from a library](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/create-and-place-symbols.html); `window.symbolLibrary`, `window.symbolLibrary.other`, `ui.saveSymbolLibrary` (dialog `saveSymbolLibrary`), `window.userSymbolLibrary1`…`10`; `panels::tests_symbol_libraries`; five built-in libraries (Basic Shapes, UI Frames with default 9-slice, Map Markers, Inventory Icons, Skill Icons; original, generated in code) | -| Brush libraries: Window › Brush Libraries (Art Ribbons, Ink and Wash, Calligraphic Nibs, Bristle Brushes, Pattern Borders, Scatter Shapes, Game Trails, Energy Beams, Dry Media, Tech Circuit, User Defined, Other Library…, Save Brushes…) and the Brushes panel's Brush Libraries Menu button and its menu's Open Brush Library / Save Brush Library…; a click on a library brush adds it to the document's Brushes (one undo step, it becomes the current brush, and selected paths take it in the same step), Shift/Cmd-clicks select for Add to Brushes, a brush dragged onto a path is added and applied to it and one dragged onto the Brushes panel is added; thumbnails render with the library's patterns and symbols | done | [public source](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/create-new-brush-libraries.html), [import brushes](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/import-brushes-from-brush-libraries-or-other-files.html), [Brushes panel overview](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/brushes-panel-overview.html); `window.brushLibrary`, `window.brushLibrary.other`, `ui.saveBrushLibrary` (dialog `saveBrushLibrary`), `window.userBrushLibrary1`…`10`; `panels::tests_brush_libraries`; ten built-in libraries (original, generated in code) | +| Brush libraries: Window › Brush Libraries (Art Ribbons, Ink and Wash, Calligraphic Nibs, Bristle Brushes, Paint, Pattern Borders, Scatter Shapes, Game Trails, Energy Beams, Dry Media, Tech Circuit, User Defined, Other Library…, Save Brushes…) and the Brushes panel's Brush Libraries Menu button and its menu's Open Brush Library / Save Brush Library…; a click on a library brush adds it to the document's Brushes (one undo step, it becomes the current brush, and selected paths take it in the same step), Shift/Cmd-clicks select for Add to Brushes, a brush dragged onto a path is added and applied to it and one dragged onto the Brushes panel is added; thumbnails render with the library's patterns and symbols | done | [public source](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/create-new-brush-libraries.html), [import brushes](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/import-brushes-from-brush-libraries-or-other-files.html), [Brushes panel overview](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/brushes-panel-overview.html); `window.brushLibrary`, `window.brushLibrary.other`, `ui.saveBrushLibrary` (dialog `saveBrushLibrary`), `window.userBrushLibrary1`…`10`; `panels::tests_brush_libraries`; eleven built-in libraries (original, generated in code) | | Brushes panel menu › Options of Selected Object…: changes the selected brushed paths' brush settings on those paths only, leaving the brush and its other strokes as they are; the brush type's options dialog opens without the Name row (and without an art brush's scale and direction options or a pattern brush's tiles), and OK sends only the values changed in it | done | [Modify brushes](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/modify-brushes.html), [Brushes panel overview](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/brushes-panel-overview.html); `brush.objectOptions`, `ui.brushObjectOptions`; which fields a path can set is VectorCraft's own choice (calligraphic, scatter, art and pattern brushes; not bristle); `options_of_selected_object_*` tests in `crates/engine/src/tests/brushsym.rs` and `crates/ui-egui/src/dialogs/brush_options/tests.rs`, brush tests in `crates/brush/src/tests.rs` | | Symbols panel: New Symbol opens Symbol Options (Name) before making the symbol; Alt-click skips it | partial | #1560 (#1566); Registration 9-point grid in Symbol Options (`symbol.new` / `symbol.place`); Export Type (Graphic / Movie Clip) and Enable Guides for 9-Slice Scaling (scaled instances keep their corners; in symbol editing mode the guides are drawn over the art and the Selection tool drags them); Symbol Type (Dynamic Symbol / Static Symbol, new symbols dynamic; #4938); Align to Pixel Grid (`alignToPixelGrid` on `symbol.new` / `symbol.options`: the art snaps at the symbol's natural size and instances at that size stay on whole points; [Aligning symbols to pixel grid](https://web.archive.org/web/20220911143322/https://helpx.adobe.com/pdf/cs6/illustrator_reference.pdf#page=28)) | | Dynamic symbols: an instance changes the fill, stroke, opacity and blend of objects in its symbol's art and stays linked; Reset in the Properties panel's Quick Actions and the Symbols panel menu (Reset Symbol Instance) | partial | #4938; `symbol.instance.setAppearance` (by child-index path) and `symbol.instance.reset`; redefining keeps the changes, Break Link bakes them; Direct Selection of a path, compound path or type object inside an instance, with the Fill/Stroke controls setting its solid fill or stroke, is on canvas; on-canvas editing beyond a solid fill and stroke, and `.ai` read and write, remain | From 021587a1135f0fdc2b3e6c597bfe57bb6204d78d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 18 Nov 2026 15:22:44 -0800 Subject: [PATCH 3/9] Brushes: keep the Pattern Borders doc comment on its own function --- crates/engine/src/cmd/brushlib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/brushlib.rs b/crates/engine/src/cmd/brushlib.rs index 5300cc084a..258fe76d2f 100644 --- a/crates/engine/src/cmd/brushlib.rs +++ b/crates/engine/src/cmd/brushlib.rs @@ -549,7 +549,6 @@ fn spacer(r: Rect) -> Node { Node::path(NodeId(0), shapes::rectangle(r), Appearance::default()) } -/// Pattern Borders: pattern brushes of tiles drawn here; Beads has corner tiles. /// Paint: original filled vector art with broad, broken, loaded, and fanned marks. Each is one /// stroke stretched along the path, with an intentionally different edge and paint distribution. fn paint() -> BrushLibrary { @@ -589,6 +588,7 @@ fn paint() -> BrushLibrary { ) } +/// Pattern Borders: pattern brushes of tiles drawn here; Beads has corner tiles. fn pattern_borders() -> BrushLibrary { let zigzag = black(polygon(&[(0.0, 1.4), (5.0, -2.6), (10.0, 1.4), (10.0, 2.6), (5.0, -1.4), (0.0, 2.6)])); let beads = group(vec![black(shapes::rectangle(Rect::new(0.0, -0.3, 8.0, 0.3))), black(shapes::ellipse(Rect::new(1.5, -2.5, 6.5, 2.5)))]); From 9dcc6913d8bb5c1ae1f7f1008e04c98ec3b15dd7 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 19 Nov 2026 02:32:34 -0800 Subject: [PATCH 4/9] Metafile import: text in the opaque background mode fills its character cells A metafile playback starts in the opaque background mode with a white background color, and text drawn in that mode fills its character cells with the background color before the glyphs. EMF and WMF import now adds one filled rectangle of the background color behind each line of such text, before the type, from the font's OS/2 usWinAscent above the baseline to its usWinDescent below it, as far as the line's advances reach (NULs and negative advances included). Files that never set the background mode now import with a background behind their text. Top and bottom aligned text now has the top or the bottom of that cell at the reference point instead of 0.8 and 0.2 of the em. A single line without advances is aligned as long as its glyphs' advances, trailing spaces included. NULs after a line break move the start of that line, and underlined or struck through blanks draw their bars. Face::win_ascent_descent gives the OS/2 usWinAscent and usWinDescent separately, at a variable font's instance. --- crates/metafile/src/import/picture.rs | 270 ++++++++++++++++++++++---- crates/metafile/src/tests/import.rs | 190 +++++++++++++++++- crates/text/src/fontdb/face.rs | 10 +- crates/text/src/tests.rs | 7 +- docs/mcp.md | 8 +- 5 files changed, 434 insertions(+), 51 deletions(-) diff --git a/crates/metafile/src/import/picture.rs b/crates/metafile/src/import/picture.rs index 125126790c..5f596e2389 100644 --- a/crates/metafile/src/import/picture.rs +++ b/crates/metafile/src/import/picture.rs @@ -16,7 +16,13 @@ //! range reaches, or a tab) are point type of their own, and an underline or strikethrough is carried across the space between. //! It is also carried on to the end of the last character's advance. Type on more than one line //! is placed a line at a time: each line is aligned by its own advances and split as a single -//! line is. +//! line is. NULs at the start, or after a line break, move the start of their line. A +//! character cell runs from the font's OS/2 usWinAscent above the baseline to its usWinDescent +//! below it, and top or bottom aligned text has the top or the bottom of its cells at the +//! reference point. One line without advances is aligned as long as its glyphs' advances, +//! trailing spaces included. Text drawn in the opaque background mode (the mode a playback +//! starts in) has one rectangle of the background color behind the character cells of each +//! line, as far as its advances reach. //! - Clip regions and clip paths become clipping groups around what they clip; a rectangle around //! the whole picture clips nothing and is left out. //! @@ -539,24 +545,44 @@ impl Mapper { fn text(&mut self, t: &craft_metafile::Text, chain: Vec>) { // The characters without NULs, and each one's advance (text units) when the file gives // one for every character: a NUL's advance goes to the character before it, or moves the - // start when the string begins with one. + // start when the string, or a line after a line break, begins with one. let advances = t.dx.len() == t.text.chars().count() && t.dx.iter().all(|d| d.is_finite()); - let (mut s, mut dx, mut lead) = (String::new(), Vec::new(), 0.0f64); + let (mut s, mut dx) = (String::new(), Vec::new()); + // How far before and after its start each character's advances (its own and the NULs' + // after it) reach (text units): an advance may be negative. And before each character, + // the advance of the NULs that move its line's start, with how far they reach. + let (mut reach, mut leads) = (Vec::new(), Vec::new()); + let mut lead = Lead::default(); + let breaks = |c: char| matches!(c, '\n' | '\r' | '\u{b}' | '\u{c}' | '\u{85}' | '\u{2028}' | '\u{2029}'); for (c, d) in t.text.chars().zip(t.dx.iter().map(|d| f64::from(*d)).chain(std::iter::repeat(0.0))) { if c != '\0' { s.push(c); dx.push(d); - } else if let Some(last) = dx.last_mut() { + reach.push((d.min(0.0), d.max(0.0))); + leads.push(std::mem::take(&mut lead)); + } else if let (Some(last), Some(r), false) = (dx.last_mut(), reach.last_mut(), s.chars().next_back().is_none_or(breaks)) { *last += d; + *r = (r.0.min(*last), r.1.max(*last)); } else { - lead += d; + lead.by += d; + lead.reach = (lead.reach.0.min(lead.by), lead.reach.1.max(lead.by)); } } if !advances { dx.clear(); - lead = 0.0; + reach.clear(); + leads.clear(); + lead = Lead::default(); } - if s.trim().is_empty() || t.color[3] == 0 { + // The leading NULs of the first line, or of a string of NULs alone. + let first = leads.first().copied().unwrap_or(lead); + // Type that draws nothing still fills its character cells on an opaque background. Blanks + // draw when they are underlined or struck through. + let background = t.background.filter(|c| c[3] > 0); + let shows = (!s.trim().is_empty() || t.font.underline || t.font.strike) && t.color[3] > 0; + // A string of NULs only fills the cells across its advances. + let nuls = s.is_empty() && first.reach.0 < first.reach.1 && background.is_some(); + if (s.is_empty() && !nuls) || !(shows || background.is_some()) { return; } // Text space → document without the move: its vertical scale gives the type size, and what @@ -613,11 +639,26 @@ impl Mapper { if !dx.is_empty() { style.kerning = Some(0.0); } - // Where the baseline is below the reference point. + // The character cell above and below the baseline (points): the face's OS/2 usWinAscent + // and usWinDescent at the type size (its own ascent and descent when it has no OS/2 + // table), as tall as a positive height asks. + let cell = face + .as_ref() + .map(|face| { + let (a, d) = face.win_ascent_descent().unwrap_or_else(|| face.vertical_metrics()); + (a / face.units_per_em() * size, d / face.units_per_em() * size) + }) + .filter(|(a, d)| a.is_finite() && d.is_finite() && *a >= 0.0 && *d >= 0.0 && a + d > 0.0) + .unwrap_or_else(|| { + let c = if h > 0.0 { size / 0.85 } else { size }; + (0.8 * c, 0.2 * c) + }); + // Where the baseline is below the reference point: the top or the bottom of the cell is at + // the reference point. let drop = match t.v_align { VAlign::Baseline => 0.0, - VAlign::Bottom => -0.2 * size, - VAlign::Top => 0.8 * size, + VAlign::Bottom => -cell.1, + VAlign::Top => cell.0, }; let origin = self.xf * Point::new(t.transform[4], t.transform[5]); let base = Affine::translate(origin.to_vec2()) * shape; @@ -633,19 +674,56 @@ impl Mapper { }; let whole = point(&s); let opacity = f32::from(t.color[3]) / 255.0; + let line = Line { + base, + drop, + align: &t.h_align, + decorated: f.underline || f.strike, + shows, + color: t.color, + opacity, + background, + cell, + point: &point, + }; + // The backgrounds of every line and piece, and the type added after them so that none of + // them covers it. + let mut out = TextOut::default(); if dx.is_empty() { let mut text = whole; - text.xf = base * Affine::translate((0.0, drop)); - text.cached_bounds = Some(vectorcraft_text::layout(db, &text).bounds); - let mut n = Node::new(NodeId(0), NodeKind::Text(Box::new(text))); - n.opacity = opacity; - self.push(chain, n); - return; + let laid = vectorcraft_text::layout(db, &text); + // One line is as long as its advances, its trailing blanks included, where the + // alignment puts a line that long. + let along = laid + .glyphs + .iter() + .fold((f64::INFINITY, 0.0), |(from, width), g| (from.min(g.origin.x.min(g.origin.x + g.advance)), width + g.advance)); + let one = laid.lines.len() == 1 && along.0.is_finite() && along.1.is_finite(); + let shift = if one { aligned(0.0, along.1, &t.h_align) - along.0 } else { 0.0 }; + text.xf = base * Affine::translate((if shift.is_finite() { shift } else { 0.0 }, drop)); + text.cached_bounds = Some(laid.bounds); + // The cells of one line run across its advances, those of more than one across each + // line's glyphs. NULs alone span their advances, where the alignment puts them. + let cells = if nuls { + let start = aligned(first.by * k, 0.0, &t.h_align) - first.by * k; + cell_rect(start + first.reach.0 * k, start + first.reach.1 * k, 0.0, cell) + } else if one { + cell_rect(along.0, along.0 + along.1, laid.glyphs.first().map_or(0.0, |g| g.origin.y), cell) + } else { + cells(&laid, &s, cell, &t.h_align) + }; + out.backs.extend(self.background(&line, cells, text.xf)); + if shows { + let mut n = Node::new(NodeId(0), NodeKind::Text(Box::new(text))); + n.opacity = opacity; + out.texts.push(n); + } + return self.add_text(&chain, out); } // Text units grow by `k` along the baseline in the text object's own space. let dx: Vec = dx.iter().map(|d| d * k).collect(); + let reach: Vec<(f64, f64)> = reach.iter().map(|(lo, hi)| (lo * k, hi * k)).collect(); let chars: Vec = s.chars().collect(); - let line = Line { base, drop, align: &t.h_align, decorated: f.underline || f.strike, color: t.color, opacity, point: &point, chain: &chain }; // Type on more than one line is placed a line at a time, each line aligned by its own // advances (layout leaves the tracking after a line's last character out of the width it // aligns, and each line ends with its own) and its underline carried on to its own end. @@ -655,25 +733,68 @@ impl Mapper { // a search. let starts: Vec = s.char_indices().map(|(at, _)| at).collect(); let count = |to: usize| starts.partition_point(|at| *at < to); - let first = laid.lines.first().map_or(0.0, |l| l.baseline); - for (n, l) in laid.lines.iter().enumerate() { + let top = laid.lines.first().map_or(0.0, |l| l.baseline); + for l in &laid.lines { let (from, to) = (count(l.start), count(l.end)); - let (Some(cs), Some(dx)) = (chars.get(from..to), dx.get(from..to)) else { continue }; - // A leading NUL's advance comes before the first line only. - let lead = if n == 0 { lead * k } else { 0.0 }; - let down = l.baseline - first; - self.line(&line, cs, dx, lead, if down.is_finite() { down } else { 0.0 }); + let (Some(cs), Some(dx), Some(reach)) = (chars.get(from..to), dx.get(from..to), reach.get(from..to)) else { continue }; + // The NULs before the line's first character, at the start or after a line break. + let lead = leads.get(from).copied().unwrap_or_default().scaled(k); + let down = l.baseline - top; + self.line(&line, cs, Advances { dx, reach, lead }, if down.is_finite() { down } else { 0.0 }, &mut out); } } else { - self.line(&line, &chars, &dx, lead * k, 0.0); + self.line(&line, &chars, Advances { dx: &dx, reach: &reach, lead: first.scaled(k) }, 0.0, &mut out); + } + self.add_text(&chain, out); + } + + /// Adds a text record's backgrounds and then its type, leaving out backgrounds when there is + /// no room for both. + fn add_text(&mut self, chain: &[Arc], out: TextOut) { + let TextOut { mut backs, texts } = out; + let keep = MAX_NODES.saturating_sub(self.out.len()).saturating_sub(texts.len()); + if backs.len() > keep { + backs.truncate(keep); + self.warn(TOO_MANY); + } + for n in backs.into_iter().chain(texts) { + self.push(chain.to_vec(), n); } } - /// One line of text with advances `dx` (points along the baseline) for its characters `chars`, - /// `down` below the first line's baseline: in pieces, each a text object of its own, a new - /// piece after each cluster that tracking can't space by its advance. - fn line(&mut self, line: &Line, chars: &[char], dx: &[f64], lead: f64, down: f64) { - if chars.is_empty() || (chars.iter().all(|c| c.is_whitespace()) && !line.decorated) { + /// Character cells `cells`, placed by `xf`, filled with the line's background when it has one. + fn background(&self, line: &Line, mut cells: BezPath, xf: Affine) -> Option { + let bg = line.background?; + if cells.elements().is_empty() { + return None; + } + cells.apply_affine(xf); + self.path_node(cells, Some(bg), None, false) + } + + /// One line of text with advances `adv` (points along the baseline) for its characters + /// `chars`, `down` below the first line's baseline: in pieces, each a text object of its own, + /// a new piece after each cluster that tracking can't space by its advance. + fn line(&mut self, line: &Line, chars: &[char], adv: Advances, down: f64, out: &mut TextOut) { + let Advances { dx, reach, lead } = adv; + if chars.is_empty() { + return; + } + // The line's cells, one rectangle behind every piece, run as far each way as its + // advances reach (an advance may be negative), from where the leading NULs' advances + // start, which the alignment puts where it puts a line as long as its advances. + let start = aligned(lead.by, dx.iter().sum(), line.align); + let (mut lo, mut hi, mut pos) = (lead.reach.0 - lead.by, lead.reach.1 - lead.by, 0.0f64); + for (d, r) in dx.iter().zip(reach) { + (lo, hi) = (lo.min(pos + r.0), hi.max(pos + r.1)); + pos += d; + } + let xf = line.base * Affine::translate((0.0, line.drop + down)); + out.backs.extend(self.background(line, cell_rect(start + lo, start + hi, 0.0, line.cell), xf)); + let blank = |cs: &[char]| cs.iter().all(|c| c.is_whitespace()); + // A piece's type draws when it shows: blanks only when underlined or struck through. + let draws = |cs: &[char]| line.shows && (!blank(cs) || line.decorated); + if !draws(chars) { return; } let db = vectorcraft_text::FontDb::global(); @@ -684,13 +805,13 @@ impl Mapper { // Along the baseline (the text object's own space), where the next piece starts from the // reference point: the line as long as its advances (a leading NUL's included), where the // alignment puts it. - let mut at = aligned(lead, dx.iter().sum(), line.align); + let mut at = start; let last = pieces.len().saturating_sub(1); for (i, (from, to)) in pieces.into_iter().enumerate() { - let piece: String = chars.get(from..to).unwrap_or_default().iter().collect(); + let cs = chars.get(from..to).unwrap_or_default(); + let piece: String = cs.iter().collect(); let dx = dx.get(from..to).unwrap_or_default(); - // Blanks of their own draw nothing unless they are underlined or struck through. - if piece.trim().is_empty() && !line.decorated { + if !draws(cs) { at += dx.iter().sum::(); continue; } @@ -715,12 +836,12 @@ impl Mapper { let gap = if (split && i < last) || (i == last && line.decorated) { gaps(&laid, db, &text, x0 + span) } else { BezPath::new() }; let mut n = Node::new(NodeId(0), NodeKind::Text(Box::new(text.clone()))); n.opacity = line.opacity; - self.push(line.chain.to_vec(), n); + out.texts.push(n); if !gap.elements().is_empty() { let mut gap = gap; gap.apply_affine(text.xf); if let Some(n) = self.path_node(gap, Some(line.color), None, false) { - self.push(line.chain.to_vec(), n); + out.texts.push(n); } } } @@ -785,16 +906,89 @@ fn aligned(lead: f64, span: f64, align: &HAlign) -> f64 { /// What every piece of a text record's lines shares: the text space (`base`, with the baseline /// `drop` below the reference point), the alignment, whether the type is underlined or struck -/// through, its color and opacity, a point type object of a string in its style, and its clips. +/// through, whether the type shows, its color and opacity, its background and the character cell +/// above and below the baseline (points), and a point type object of a string in its style. struct Line<'a> { base: Affine, drop: f64, align: &'a HAlign, decorated: bool, + shows: bool, color: [u8; 4], opacity: f32, + background: Option<[u8; 4]>, + cell: (f64, f64), point: &'a dyn Fn(&str) -> TextObject, - chain: &'a [Arc], +} + +/// What a text record draws: the backgrounds behind its character cells, and its type (with the +/// bars that carry an underline or strikethrough on), added after them. +#[derive(Default)] +struct TextOut { + backs: Vec, + texts: Vec, +} + +/// One line's advances (points along the baseline): each character's own, how far before and +/// after its start the advances from it to the next character reach, and the leading NULs'. +struct Advances<'a> { + dx: &'a [f64], + reach: &'a [(f64, f64)], + lead: Lead, +} + +/// The NULs that move a line's start: their advance, and how far before and after the line's +/// start they reach. +#[derive(Clone, Copy, Default)] +struct Lead { + by: f64, + reach: (f64, f64), +} + +impl Lead { + /// The same NULs with their advances grown by `k`. + fn scaled(self, k: f64) -> Lead { + Lead { by: self.by * k, reach: (self.reach.0 * k, self.reach.1 * k) } + } +} + +/// The character cell from `x0` to `x1` along a baseline at `y`, `cell.0` above and `cell.1` +/// below it (points); empty when it has no area. +fn cell_rect(x0: f64, x1: f64, y: f64, cell: (f64, f64)) -> BezPath { + let r = Rect::new(x0, y - cell.0, x1, y + cell.1).abs(); + if r.width() > 0.0 && r.height() > 0.0 && r.is_finite() { shapes::rectangle(r).to_bezpath() } else { BezPath::new() } +} + +/// The character cells of `laid` (the type `s` laid out on more than one line), `cell.0` above +/// and `cell.1` below each baseline (points), as one rectangle a line: across the line as layout +/// places it (its trailing blanks are left out of the width layout aligns), or for a line of +/// blanks alone as wide as their advances, where `align` puts a line that long. +fn cells(laid: &vectorcraft_text::TextLayout, s: &str, cell: (f64, f64), align: &HAlign) -> BezPath { + // Each line's baseline, the sum of its glyphs' advances and whether they are all blanks. + // Glyphs come line by line. + let mut lines: Vec<(usize, f64, f64, bool)> = Vec::new(); + for g in &laid.glyphs { + let blank = s.get(g.byte..).and_then(|r| r.chars().next()).is_none_or(char::is_whitespace); + match lines.last_mut() { + Some((line, _, width, all)) if *line == g.line => { + *width += g.advance; + *all &= blank; + } + _ => lines.push((g.line, g.origin.y, g.advance, blank)), + } + } + let mut bp = BezPath::new(); + for (line, y, width, blank) in lines { + let (x0, x1) = match laid.lines.get(line) { + Some(l) if !blank => (l.x0, l.x1), + _ => { + let x0 = aligned(0.0, width, align); + (x0, x0 + width) + } + }; + bp.extend(cell_rect(x0, x1, y, cell)); + } + bp } /// The most times [`advanced`] lays the type out again to correct its tracking. diff --git a/crates/metafile/src/tests/import.rs b/crates/metafile/src/tests/import.rs index 01883c740b..64f826b16a 100644 --- a/crates/metafile/src/tests/import.rs +++ b/crates/metafile/src/tests/import.rs @@ -274,7 +274,9 @@ fn hand_built_emf_plays_like_gdi() { let lines = &children[1]; assert_eq!(lines.appearance.items.len(), 1); assert!(near(lines.geometric_bounds().unwrap(), Rect::new(0.0, 0.0, 5.0 * mm, 5.0 * mm), 0.01)); - let NodeKind::Text(t) = &children[2].kind else { panic!("text") }; + // The background mode starts opaque: the text's cells are filled white behind it. + assert_eq!(fill_rgb(&children[2]), Some([255, 255, 255])); + let NodeKind::Text(t) = &children[3].kind else { panic!("text") }; assert_eq!(t.plain_text(), "Hi"); let st = &t.runs[0].style; assert_eq!((st.font_family.as_str(), st.font_style.as_str()), ("Arial", "Bold")); @@ -884,6 +886,38 @@ fn wmf_font_width_becomes_horizontal_scale() { assert!((st.h_scale - want).abs() < 1e-9, "{} for {want}", st.h_scale); } +#[test] +fn wmf_text_fills_its_cells_in_the_opaque_background_mode() { + // CREATEFONTINDIRECT and SELECTOBJECT: a 0.1 inch em; SETBKCOLOR green; SETBKMODE `mode` + // (none when 0); TEXTOUT "Hi" at (720, 360), top aligned. + let backgrounds = |mode: i16| { + let mut font = le16(&[-144, 0, 0, 0, 400]); + font.extend([0u8; 8]); + font.extend(b"Source Sans 3".iter().copied().chain(std::iter::repeat_n(0, 19))); + let mut text = le16(&[2]); + text.extend(b"Hi"); + text.extend(le16(&[360, 720])); + let mut records = vec![(0x02FB, font), (0x012D, le16(&[0])), (0x0201, 0x0000_ff00u32.to_le_bytes().to_vec())]; + if mode != 0 { + records.push((0x0102, le16(&[mode, 0]))); + } + records.push((0x0521, text)); + paths(&import(&hand_wmf(1440, 1440, &records)).unwrap().document) + }; + let mm = 72.0 / 25.4; + // A file that never sets the mode, and one that sets OPAQUE: one green rectangle whose top + // is at the reference point and whose left edge is at the start of the text. + for mode in [0, 2] { + let p = backgrounds(mode); + assert_eq!(p.len(), 1, "{mode}"); + assert_eq!(fill_rgb(&p[0]), Some([0, 255, 0]), "{mode}"); + let b = p[0].geometric_bounds().unwrap(); + assert!((b.x0 - 12.7 * mm).abs() < 0.01 && (b.y0 - 6.35 * mm).abs() < 0.01 && b.x1 > b.x0 && b.y1 > b.y0, "{mode}: {b:?}"); + } + // TRANSPARENT: no background. + assert!(backgrounds(1).is_empty()); +} + #[test] fn a_clip_whose_box_holds_the_picture_still_clips() { // A diamond around the middle of the picture, whose box holds the whole frame but which cuts @@ -1001,7 +1035,8 @@ fn clipped_text_is_clipped_to_its_rectangle() { let mut font = le(&[2, -1000, 0, 0, 0, 400]); font.extend([0, 1, 1, 0, 0, 0, 0, 0]); font.extend("Arial".encode_utf16().chain(std::iter::repeat_n(0, 27)).flat_map(u16::to_le_bytes)); - let mut records = vec![(82, font), (37, le(&[2])), (84, text)]; + // SETBKMODE TRANSPARENT: no background behind the text. + let mut records = vec![(18, le(&[1])), (82, font), (37, le(&[2])), (84, text)]; let back = import(&hand_emf(5000, 3000, &records)).unwrap(); let layer = back.document.layers[0].children().unwrap(); assert_eq!(layer.len(), 1); @@ -1030,6 +1065,142 @@ fn clipped_text_is_clipped_to_its_rectangle() { assert!(matches!(children[1].kind, NodeKind::Text(_))); } +/// The layer of an EMF that sets the background color green, the background mode `mode` (none +/// when 0) and the text alignment `align`, then draws `s` at (`x`, 1500) in `font` with the +/// advances `dx`. +fn on_background(mode: i32, align: i32, x: i32, font: Vec, s: &str, dx: &[i32]) -> Vec> { + let mut records = vec![(25, le(&[0x0000_ff00])), (22, le(&[align])), (82, font), (37, le(&[2])), (84, text_out(x, s, dx))]; + if mode > 0 { + records.insert(0, (18, le(&[mode]))); + } + import(&hand_emf(5000, 3000, &records)).unwrap().document.layers[0].children().unwrap().clone() +} + +#[test] +fn opaque_backgrounds_fill_behind_the_character_cells() { + let mm = 72.0 / 25.4; + let aligned = on_background; + // TA_BASELINE: the baseline at (10, 15) mm. + let drawn = |mode: i32, font: Vec, s: &str, dx: &[i32]| aligned(mode, 24, 1000, font, s, dx); + let opaque = |font: Vec, s: &str, dx: &[i32]| drawn(2, font, s, dx); + // "Hi" with advances of 20 and 10 mm in a 10 mm em: the cells run across the advances, from + // the face's usWinAscent above the baseline to its usWinDescent below it, behind the type. + let layer = opaque(arial(), "Hi", &[2000, 1000]); + assert_eq!(layer.len(), 2); + assert_eq!(fill_rgb(&layer[0]), Some([0, 255, 0])); + let NodeKind::Text(t) = &layer[1].kind else { panic!("text") }; + let face = vectorcraft_text::FontDb::global().style_face(&t.runs[0].style).unwrap(); + let (a, d) = face.win_ascent_descent().unwrap(); + let em = face.units_per_em(); + let b = layer[0].geometric_bounds().unwrap(); + assert!(near(b, Rect::new(10.0 * mm, (15.0 - 10.0 * a / em) * mm, 40.0 * mm, (15.0 + 10.0 * d / em) * mm), 0.01), "{b:?}"); + // TA_TOP and TA_BOTTOM put the top and the bottom of the cell at the reference point: the + // baseline is usWinAscent below it, or usWinDescent above it. + for (align, top) in [(0, 15.0), (8, 15.0 - 10.0 * (a + d) / em)] { + let layer = aligned(2, align, 1000, arial(), "Hi", &[2000, 1000]); + let b = layer[0].geometric_bounds().unwrap(); + assert!((b.y0 - top * mm).abs() < 0.01 && (b.height() - 10.0 * (a + d) / em * mm).abs() < 0.01, "{align}: {b:?}"); + let NodeKind::Text(t) = &layer[1].kind else { panic!("text") }; + let baseline = (t.xf * vectorcraft_geom::Point::ZERO).y; + assert!((baseline - (top + 10.0 * a / em) * mm).abs() < 0.01, "{align}: {baseline}"); + } + // A leading NUL's advance is filled too: right aligned at 50 mm, "\0Hi" fills from 10 mm. + let b = aligned(2, 26, 5000, arial(), "\0Hi", &[1000, 2000, 1000])[0].geometric_bounds().unwrap(); + assert!((b.x0 - 10.0 * mm).abs() < 0.01 && (b.x1 - 50.0 * mm).abs() < 0.01, "{b:?}"); + // A positive height is the cell: 10 mm from top to bottom. + let mut font = le(&[2, 1000, 0, 0, 0, 400]); + font.extend([0; 8]); + font.extend("Arial".encode_utf16().chain(std::iter::repeat_n(0, 27)).flat_map(u16::to_le_bytes)); + let b = opaque(font, "Hi", &[2000, 1000])[0].geometric_bounds().unwrap(); + assert!((b.height() - 10.0 * mm).abs() < 0.01, "{b:?}"); + // Without advances the cells run across the glyphs' own advances. + let layer = opaque(arial(), "Hi", &[]); + let NodeKind::Text(t) = &layer[1].kind else { panic!("text") }; + let (xs, end) = glyph_xs(t); + let b = layer[0].geometric_bounds().unwrap(); + assert!((b.x0 - xs[0]).abs() < 0.01 && (b.x1 - end).abs() < 0.01, "{b:?} {xs:?} {end}"); + // Type split where an advance is further than tracking reaches: one background across the + // whole line's advances comes before both pieces of type. + let layer = opaque(arial(), "Hiy", &[12000, 500, 1000]); + let kinds: Vec = layer.iter().map(|n| matches!(n.kind, NodeKind::Text(_))).collect(); + assert_eq!(kinds, [false, true, true]); + let b = layer[0].geometric_bounds().unwrap(); + assert!((b.x0 - 10.0 * mm).abs() < 0.01 && (b.x1 - 145.0 * mm).abs() < 0.01, "{b:?}"); + // A NUL after a line break moves the start of the line it begins, as it moves the first + // line's: "\0B" on a line of its own is placed and filled as the same record alone. + // Where the last text object's first glyph starts, and the left edges of the backgrounds. + let placed = |layer: &[std::sync::Arc]| { + let last = layer.iter().rev().find_map(|n| match &n.kind { + NodeKind::Text(t) => Some(glyph_xs(t).0[0]), + _ => None, + }); + let backs: Vec = + layer.iter().filter(|n| matches!(n.kind, NodeKind::Path { .. })).filter_map(|n| n.geometric_bounds()).map(|b| b.x0).collect(); + (last.unwrap(), backs) + }; + let (b_alone, _) = placed(&opaque(arial(), "\0B", &[2000, 1000])); + let (b_together, backs) = placed(&opaque(arial(), "A\n\0B", &[1000, 0, 2000, 1000])); + assert!((b_alone - 30.0 * mm).abs() < 0.01 && (b_together - b_alone).abs() < 0.01, "{b_alone} {b_together}"); + assert!(backs.len() == 2 && backs.iter().all(|x| (x - 10.0 * mm).abs() < 0.01), "{backs:?}"); +} + +#[test] +fn opaque_backgrounds_reach_as_far_as_the_advances() { + let mm = 72.0 / 25.4; + let aligned = on_background; + // TA_BASELINE: the baseline at (10, 15) mm. + let drawn = |mode: i32, font: Vec, s: &str, dx: &[i32]| aligned(mode, 24, 1000, font, s, dx); + let opaque = |font: Vec, s: &str, dx: &[i32]| drawn(2, font, s, dx); + // Two lines: a rectangle behind each, not one block over the space between them. + let layer = opaque(arial(), "Hi\nHi", &[]); + let NodeKind::Path { path, .. } = &layer[0].kind else { panic!("a path") }; + let rects = path.to_bezpath().elements().iter().filter(|e| matches!(e, vectorcraft_geom::PathEl::MoveTo(_))).count(); + assert_eq!(rects, 2); + // Without advances, a line is aligned as long as its advances, trailing spaces included, and + // its cells run across them: right aligned at 40 mm, "Hi " and its cells end there. + let layer = aligned(2, 26, 4000, arial(), "Hi ", &[]); + let NodeKind::Text(t) = &layer[1].kind else { panic!("text") }; + let (xs, end) = glyph_xs(t); + let b = layer[0].geometric_bounds().unwrap(); + assert!(xs.len() == 3 && (end - 40.0 * mm).abs() < 0.01, "{xs:?} {end}"); + assert!((b.x0 - xs[0]).abs() < 0.01 && (b.x1 - end).abs() < 0.01, "{b:?} {xs:?} {end}"); + // On more than one line, each line is aligned without its trailing spaces, and so are its + // cells: right aligned at 40 mm, neither passes it. + let b = aligned(2, 26, 4000, arial(), "Hi \nHi", &[])[0].geometric_bounds().unwrap(); + assert!((b.x1 - 40.0 * mm).abs() < 0.01, "{b:?}"); + // NULs whose advances go forward and back again still fill as far as they reach. + let layer = opaque(arial(), "\0\0", &[1000, -1000]); + assert_eq!(layer.len(), 1); + let b = layer[0].geometric_bounds().unwrap(); + assert!((b.x0 - 10.0 * mm).abs() < 0.01 && (b.x1 - 20.0 * mm).abs() < 0.01, "{b:?}"); + let b = opaque(arial(), "H\0i", &[3000, -2000, 1000])[0].geometric_bounds().unwrap(); + assert!((b.x0 - 10.0 * mm).abs() < 0.01 && (b.x1 - 40.0 * mm).abs() < 0.01, "{b:?}"); + // An advance that goes back: the cells reach as far as the advances go, here to 30 mm. + let b = opaque(arial(), "Hi", &[2000, -1000])[0].geometric_bounds().unwrap(); + assert!((b.x0 - 10.0 * mm).abs() < 0.01 && (b.x1 - 30.0 * mm).abs() < 0.01, "{b:?}"); + // NULs alone fill across their advances. + let layer = opaque(arial(), "\0", &[2000]); + assert_eq!(layer.len(), 1); + let b = layer[0].geometric_bounds().unwrap(); + assert!((b.x0 - 10.0 * mm).abs() < 0.01 && (b.x1 - 30.0 * mm).abs() < 0.01, "{b:?}"); + // Blanks on an opaque background still fill their cells, from the reference point on; on a + // transparent one nothing is left. + let layer = opaque(arial(), " \t", &[]); + assert_eq!(layer.len(), 1); + let b = layer[0].geometric_bounds().unwrap(); + assert!((b.x0 - 10.0 * mm).abs() < 0.01 && b.x1 > 10.0 * mm, "{b:?}"); + assert!(drawn(1, arial(), " \t", &[]).is_empty()); + // Underlined blanks draw their underline, on a transparent background too. + for mode in [1, 2] { + let layer = drawn(mode, font_of("Arial", true), " ", &[]); + assert!(layer.iter().any(|n| matches!(&n.kind, NodeKind::Text(t) if t.runs[0].style.underline)), "{mode}"); + } + // A file that never sets the mode draws in the opaque mode a playback starts in. + let layer = drawn(0, arial(), "Hi", &[]); + assert_eq!(fill_rgb(&layer[0]), Some([0, 255, 0])); + assert!(drawn(1, arial(), "Hi", &[]).iter().all(|n| matches!(n.kind, NodeKind::Text(_)))); +} + /// The first text object of `d`. fn first_text(d: &Document) -> TextObject { all(d) @@ -1195,8 +1366,8 @@ fn multiline_text_with_advances_aligns_each_line() { } assert!(drops.iter().all(|d| (d - drops[0]).abs() < 0.01), "{drops:?}"); // Underlined and left aligned, each line's underline ends with its own advances: no bar runs on - // past either line. - let records = vec![(82, font_of("Arial", true)), (37, le(&[2])), (84, text_out(1000, "Hi\nHi", &[2000, 1000, 0, 2000, 1000]))]; + // past either line (on a transparent background, SETBKMODE). + let records = vec![(18, le(&[1])), (82, font_of("Arial", true)), (37, le(&[2])), (84, text_out(1000, "Hi\nHi", &[2000, 1000, 0, 2000, 1000]))]; let back = import(&hand_emf(5000, 3000, &records)).unwrap(); assert!(all(&back.document).iter().all(|n| !matches!(n.kind, NodeKind::Path { .. }))); for (align, x, second) in [(6, 2500, [15.0, 30.0]), (2, 4000, [20.0, 35.0])] { @@ -1254,8 +1425,9 @@ fn wmf_text_is_spaced_by_its_advances() { fn split_type_keeps_its_underline_and_right_to_left_order() { let mm = 72.0 / 25.4; // Underlined "Hiy" with an advance further than tracking reaches after the "H": the bar runs on - // from the end of the "H"'s underline to where "iy" starts, at 130 mm. - let records = vec![(82, font_of("Arial", true)), (37, le(&[2])), (84, text_out(1000, "Hiy", &[12000, 500, 1000]))]; + // from the end of the "H"'s underline to where "iy" starts, at 130 mm. The background is + // transparent (SETBKMODE) throughout. + let records = vec![(18, le(&[1])), (82, font_of("Arial", true)), (37, le(&[2])), (84, text_out(1000, "Hiy", &[12000, 500, 1000]))]; let back = import(&hand_emf(20000, 3000, &records)).unwrap(); assert_eq!(texts_at(&back.document), vec![("H".to_string(), vec![10.0]), ("iy".to_string(), vec![130.0, 135.0])]); let bars: Vec = @@ -1265,7 +1437,7 @@ fn split_type_keeps_its_underline_and_right_to_left_order() { assert!(b.x0 > 10.0 * mm && b.x0 < 130.0 * mm && (b.x1 - 130.0 * mm).abs() < 0.01 && b.height() < 2.0 * mm, "{b:?}"); // The "H" and the "i" before the split are tracked apart and draw a bar each: only the bar that // ends the piece runs on, from the end of the "i" to 130 mm. - let records = vec![(82, font_of("Arial", true)), (37, le(&[2])), (84, text_out(1000, "Hiy", &[1000, 12000, 1000]))]; + let records = vec![(18, le(&[1])), (82, font_of("Arial", true)), (37, le(&[2])), (84, text_out(1000, "Hiy", &[1000, 12000, 1000]))]; let back = import(&hand_emf(20000, 3000, &records)).unwrap(); assert_eq!(texts_at(&back.document), vec![("Hi".to_string(), vec![10.0, 20.0]), ("y".to_string(), vec![140.0])]); let gaps: Vec = all(&back.document).into_iter().filter(|n| matches!(n.kind, NodeKind::Path { .. })).collect(); @@ -1276,12 +1448,12 @@ fn split_type_keeps_its_underline_and_right_to_left_order() { let b = gaps[0].geometric_bounds().unwrap(); assert!(b.x0 > 20.0 * mm && (b.x1 - 140.0 * mm).abs() < 0.01, "{b:?}"); // Without an underline, nothing but the type. - let records = vec![(82, arial()), (37, le(&[2])), (84, text_out(1000, "Hiy", &[12000, 500, 1000]))]; + let records = vec![(18, le(&[1])), (82, arial()), (37, le(&[2])), (84, text_out(1000, "Hiy", &[12000, 500, 1000]))]; let back = import(&hand_emf(20000, 3000, &records)).unwrap(); assert!(all(&back.document).iter().all(|n| !matches!(n.kind, NodeKind::Path { .. }))); // A last advance further than tracking reaches, right aligned at 140 mm: the "H" and the "i" // start at 10 and 20 mm, and the underline runs on from the "i" to 140 mm. - let records = vec![(22, le(&[2])), (82, font_of("Arial", true)), (37, le(&[2])), (84, text_out(14000, "Hi", &[1000, 12000]))]; + let records = vec![(18, le(&[1])), (22, le(&[2])), (82, font_of("Arial", true)), (37, le(&[2])), (84, text_out(14000, "Hi", &[1000, 12000]))]; let back = import(&hand_emf(20000, 3000, &records)).unwrap(); assert_eq!(texts_at(&back.document), vec![("Hi".to_string(), vec![10.0, 20.0])]); let bars: Vec = diff --git a/crates/text/src/fontdb/face.rs b/crates/text/src/fontdb/face.rs index 5c21fbb4f1..d6e114a33f 100644 --- a/crates/text/src/fontdb/face.rs +++ b/crates/text/src/fontdb/face.rs @@ -372,6 +372,12 @@ impl FontFace { /// `usWinDescent`, at the face's location in a variable font), in font units; `None` when the /// font has no OS/2 table or the sum isn't positive. pub fn win_cell_height(&self) -> Option { + self.win_ascent_descent().map(|(a, d)| a + d) + } + /// The face's character cell on Windows above and below the baseline (the OS/2 table's + /// `usWinAscent` and `usWinDescent`, at the face's location in a variable font), in font + /// units; `None` when the font has no OS/2 table or the sum isn't positive. + pub fn win_ascent_descent(&self) -> Option<(f64, f64)> { use skrifa::raw::TableProvider; let f = self.skrifa()?; let o = f.os2().ok()?; @@ -380,8 +386,8 @@ impl FontFace { let varied = |tag: &[u8; 4]| { f.mvar().ok().and_then(|m| m.metric_delta(skrifa::Tag::new(tag), self.location().coords()).ok()).map_or(0.0, |d| d.to_f64()) }; - let h = f64::from(o.us_win_ascent()) + varied(b"hcla") + f64::from(o.us_win_descent()) + varied(b"hcld"); - (h > 0.0 && h.is_finite()).then_some(h) + let (a, d) = (f64::from(o.us_win_ascent()) + varied(b"hcla"), f64::from(o.us_win_descent()) + varied(b"hcld")); + (a + d > 0.0 && (a + d).is_finite()).then_some((a, d)) } /// The average width of the face's characters (the OS/2 table's `xAvgCharWidth`), in font /// units; `None` when the font has no OS/2 table or gives no positive width. diff --git a/crates/text/src/tests.rs b/crates/text/src/tests.rs index 38a8d97f69..94709cbb23 100644 --- a/crates/text/src/tests.rs +++ b/crates/text/src/tests.rs @@ -875,7 +875,8 @@ fn on_path_align_takes_a_variable_font_instances_em_box() { } /// A variable font's instance takes its Windows character cell from the `usWinAscent` and -/// `usWinDescent` its `MVAR` table varies: 200 units taller in Bold. +/// `usWinDescent` its `MVAR` table varies: 200 units taller in Bold, 120 above the baseline and +/// 80 below it. #[test] fn win_cell_height_takes_a_variable_font_instances_mvar() { use crate::test_fonts::{PATH_ALIGN_VARIABLE_FAMILY, path_align_font}; @@ -885,6 +886,10 @@ fn win_cell_height_takes_a_variable_font_instances_mvar() { let cell = |font_style: &str| db.style_face(&st(font_style)).and_then(|f| f.win_cell_height()).unwrap(); let (regular, bold) = (cell("Regular"), cell("Bold")); assert!((bold - regular - 200.0).abs() < 1e-6, "Regular {regular}, Bold {bold}"); + let split = |font_style: &str| db.style_face(&st(font_style)).and_then(|f| f.win_ascent_descent()).unwrap(); + let ((ra, rd), (ba, bd)) = (split("Regular"), split("Bold")); + assert!((ba - ra - 120.0).abs() < 1e-6 && (bd - rd - 80.0).abs() < 1e-6, "Regular {ra}/{rd}, Bold {ba}/{bd}"); + assert!((ra + rd - regular).abs() < 1e-6); } /// In vertical type, Align to Path moves the glyphs half an em, with their horizontal scale and not diff --git a/docs/mcp.md b/docs/mcp.md index 79f6183e79..95bce038ca 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -9875,7 +9875,13 @@ images and point type in the font the file names. Type keeps the file's characte kerning off. On a single left to right line, an advance that tracking can't give (wider than its range, or a tab) starts a new point type object at the position the advance gives, and an underline or strikethrough is filled across the space between and on to the end of the last character's advance. Type on more than one line is placed a line at a time: each line is aligned by its own advances and -split as a single line is. An EMF that +split as a single line is. NULs at the start of the text, or after a line break, move the start of their line by their +advances. Blanks that are underlined or struck through draw their bars. A character cell runs from the font's OS/2 +`usWinAscent` above the baseline to its `usWinDescent` below it: top and bottom aligned text has the top or the +bottom of its cells at the reference point. A single line without character advances is aligned as long as its +glyphs' advances, trailing spaces included. Text drawn in the opaque background mode, which a file is in until it +sets the mode to transparent, gets one filled rectangle of the background color behind the character cells of each +line, as far as its advances reach (NULs' included), placed before the type. An EMF that draws with EMF+ records is read from them. Hatched and pattern brushes fill with their average color. Records VectorCraft doesn't read are skipped with one warning. A file, or a metafile image inside it, cut short by one of the reader's limits adds one warning without a count. Each of these adds one warning, with a count: images and pattern brushes whose bitmap can't be read, which are left From 8993be043f90bbcce70c5916e72318ec00828fba Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 19 Nov 2026 05:42:41 -0800 Subject: [PATCH 5/9] Metafile import: keep the opaque text background to its own change This takes three behavior changes out of the branch, so that it holds the opaque background and the character cell it fills: - A single line without advances is aligned as before, without its trailing spaces. Its cells run across its glyphs' advances from where its type starts; blanks alone, which draw no type, are filled where the alignment puts them. - NULs after a line break add their advance to the character before them, as before. - Blanks that are underlined or struck through draw nothing, as before. A string of NULs alone in an underlined font now fills its cells and adds no empty type object. docs/mcp.md no longer describes the three, and docs/target-app-parity.md lists the background and the cell. The first commit's body names FontFace::win_ascent_descent as Face::win_ascent_descent. A device context starts with a background color that is typically white; the first commit states white as the playback default. --- crates/metafile/src/import/picture.rs | 56 +++++++++++++-------------- crates/metafile/src/tests/import.rs | 30 +++----------- docs/mcp.md | 6 +-- docs/target-app-parity.md | 1 + 4 files changed, 35 insertions(+), 58 deletions(-) diff --git a/crates/metafile/src/import/picture.rs b/crates/metafile/src/import/picture.rs index 5f596e2389..29e40ed984 100644 --- a/crates/metafile/src/import/picture.rs +++ b/crates/metafile/src/import/picture.rs @@ -16,13 +16,11 @@ //! range reaches, or a tab) are point type of their own, and an underline or strikethrough is carried across the space between. //! It is also carried on to the end of the last character's advance. Type on more than one line //! is placed a line at a time: each line is aligned by its own advances and split as a single -//! line is. NULs at the start, or after a line break, move the start of their line. A -//! character cell runs from the font's OS/2 usWinAscent above the baseline to its usWinDescent -//! below it, and top or bottom aligned text has the top or the bottom of its cells at the -//! reference point. One line without advances is aligned as long as its glyphs' advances, -//! trailing spaces included. Text drawn in the opaque background mode (the mode a playback -//! starts in) has one rectangle of the background color behind the character cells of each -//! line, as far as its advances reach. +//! line is. A character cell runs from the font's OS/2 usWinAscent above the baseline to its +//! usWinDescent below it, and top or bottom aligned text has the top or the bottom of its cells +//! at the reference point. Text drawn in the opaque background mode (the mode a playback starts +//! in) has one rectangle of the background color behind the character cells of each line, as +//! far as its advances reach. //! - Clip regions and clip paths become clipping groups around what they clip; a rectangle around //! the whole picture clips nothing and is left out. //! @@ -545,22 +543,20 @@ impl Mapper { fn text(&mut self, t: &craft_metafile::Text, chain: Vec>) { // The characters without NULs, and each one's advance (text units) when the file gives // one for every character: a NUL's advance goes to the character before it, or moves the - // start when the string, or a line after a line break, begins with one. + // start when the string begins with one. let advances = t.dx.len() == t.text.chars().count() && t.dx.iter().all(|d| d.is_finite()); let (mut s, mut dx) = (String::new(), Vec::new()); // How far before and after its start each character's advances (its own and the NULs' - // after it) reach (text units): an advance may be negative. And before each character, - // the advance of the NULs that move its line's start, with how far they reach. - let (mut reach, mut leads) = (Vec::new(), Vec::new()); + // after it) reach (text units): an advance may be negative. And the advance of the NULs + // that move the start, with how far they reach. + let mut reach = Vec::new(); let mut lead = Lead::default(); - let breaks = |c: char| matches!(c, '\n' | '\r' | '\u{b}' | '\u{c}' | '\u{85}' | '\u{2028}' | '\u{2029}'); for (c, d) in t.text.chars().zip(t.dx.iter().map(|d| f64::from(*d)).chain(std::iter::repeat(0.0))) { if c != '\0' { s.push(c); dx.push(d); reach.push((d.min(0.0), d.max(0.0))); - leads.push(std::mem::take(&mut lead)); - } else if let (Some(last), Some(r), false) = (dx.last_mut(), reach.last_mut(), s.chars().next_back().is_none_or(breaks)) { + } else if let (Some(last), Some(r)) = (dx.last_mut(), reach.last_mut()) { *last += d; *r = (r.0.min(*last), r.1.max(*last)); } else { @@ -571,15 +567,13 @@ impl Mapper { if !advances { dx.clear(); reach.clear(); - leads.clear(); lead = Lead::default(); } - // The leading NULs of the first line, or of a string of NULs alone. - let first = leads.first().copied().unwrap_or(lead); - // Type that draws nothing still fills its character cells on an opaque background. Blanks - // draw when they are underlined or struck through. + // The leading NULs, of the text or of a string of NULs alone. + let first = lead; + // Type that draws nothing still fills its character cells on an opaque background. let background = t.background.filter(|c| c[3] > 0); - let shows = (!s.trim().is_empty() || t.font.underline || t.font.strike) && t.color[3] > 0; + let shows = !s.trim().is_empty() && t.color[3] > 0; // A string of NULs only fills the cells across its advances. let nuls = s.is_empty() && first.reach.0 < first.reach.1 && background.is_some(); if (s.is_empty() && !nuls) || !(shows || background.is_some()) { @@ -692,23 +686,25 @@ impl Mapper { if dx.is_empty() { let mut text = whole; let laid = vectorcraft_text::layout(db, &text); - // One line is as long as its advances, its trailing blanks included, where the - // alignment puts a line that long. + // Where one line's glyphs start, and the sum of their advances, its trailing blanks + // included. let along = laid .glyphs .iter() .fold((f64::INFINITY, 0.0), |(from, width), g| (from.min(g.origin.x.min(g.origin.x + g.advance)), width + g.advance)); let one = laid.lines.len() == 1 && along.0.is_finite() && along.1.is_finite(); - let shift = if one { aligned(0.0, along.1, &t.h_align) - along.0 } else { 0.0 }; - text.xf = base * Affine::translate((if shift.is_finite() { shift } else { 0.0 }, drop)); + text.xf = base * Affine::translate((0.0, drop)); text.cached_bounds = Some(laid.bounds); - // The cells of one line run across its advances, those of more than one across each - // line's glyphs. NULs alone span their advances, where the alignment puts them. + // The cells of one line run across its advances, from where its type starts, or for + // blanks alone, which draw no type, where the alignment puts a line that long. Those + // of more than one line run across each line's glyphs. NULs alone span their + // advances, where the alignment puts them. let cells = if nuls { let start = aligned(first.by * k, 0.0, &t.h_align) - first.by * k; cell_rect(start + first.reach.0 * k, start + first.reach.1 * k, 0.0, cell) } else if one { - cell_rect(along.0, along.0 + along.1, laid.glyphs.first().map_or(0.0, |g| g.origin.y), cell) + let x0 = if shows { along.0 } else { aligned(0.0, along.1, &t.h_align) }; + cell_rect(x0, x0 + along.1, laid.glyphs.first().map_or(0.0, |g| g.origin.y), cell) } else { cells(&laid, &s, cell, &t.h_align) }; @@ -734,11 +730,11 @@ impl Mapper { let starts: Vec = s.char_indices().map(|(at, _)| at).collect(); let count = |to: usize| starts.partition_point(|at| *at < to); let top = laid.lines.first().map_or(0.0, |l| l.baseline); - for l in &laid.lines { + for (n, l) in laid.lines.iter().enumerate() { let (from, to) = (count(l.start), count(l.end)); let (Some(cs), Some(dx), Some(reach)) = (chars.get(from..to), dx.get(from..to), reach.get(from..to)) else { continue }; - // The NULs before the line's first character, at the start or after a line break. - let lead = leads.get(from).copied().unwrap_or_default().scaled(k); + // A leading NUL's advance comes before the first line only. + let lead = if n == 0 { first.scaled(k) } else { Lead::default() }; let down = l.baseline - top; self.line(&line, cs, Advances { dx, reach, lead }, if down.is_finite() { down } else { 0.0 }, &mut out); } diff --git a/crates/metafile/src/tests/import.rs b/crates/metafile/src/tests/import.rs index 64f826b16a..aebed8a859 100644 --- a/crates/metafile/src/tests/import.rs +++ b/crates/metafile/src/tests/import.rs @@ -1126,22 +1126,6 @@ fn opaque_backgrounds_fill_behind_the_character_cells() { assert_eq!(kinds, [false, true, true]); let b = layer[0].geometric_bounds().unwrap(); assert!((b.x0 - 10.0 * mm).abs() < 0.01 && (b.x1 - 145.0 * mm).abs() < 0.01, "{b:?}"); - // A NUL after a line break moves the start of the line it begins, as it moves the first - // line's: "\0B" on a line of its own is placed and filled as the same record alone. - // Where the last text object's first glyph starts, and the left edges of the backgrounds. - let placed = |layer: &[std::sync::Arc]| { - let last = layer.iter().rev().find_map(|n| match &n.kind { - NodeKind::Text(t) => Some(glyph_xs(t).0[0]), - _ => None, - }); - let backs: Vec = - layer.iter().filter(|n| matches!(n.kind, NodeKind::Path { .. })).filter_map(|n| n.geometric_bounds()).map(|b| b.x0).collect(); - (last.unwrap(), backs) - }; - let (b_alone, _) = placed(&opaque(arial(), "\0B", &[2000, 1000])); - let (b_together, backs) = placed(&opaque(arial(), "A\n\0B", &[1000, 0, 2000, 1000])); - assert!((b_alone - 30.0 * mm).abs() < 0.01 && (b_together - b_alone).abs() < 0.01, "{b_alone} {b_together}"); - assert!(backs.len() == 2 && backs.iter().all(|x| (x - 10.0 * mm).abs() < 0.01), "{backs:?}"); } #[test] @@ -1156,13 +1140,13 @@ fn opaque_backgrounds_reach_as_far_as_the_advances() { let NodeKind::Path { path, .. } = &layer[0].kind else { panic!("a path") }; let rects = path.to_bezpath().elements().iter().filter(|e| matches!(e, vectorcraft_geom::PathEl::MoveTo(_))).count(); assert_eq!(rects, 2); - // Without advances, a line is aligned as long as its advances, trailing spaces included, and - // its cells run across them: right aligned at 40 mm, "Hi " and its cells end there. + // Without advances, one line's cells run across its glyphs' advances, trailing spaces + // included: right aligned, they run from the "H" to the end of the space after the "i". let layer = aligned(2, 26, 4000, arial(), "Hi ", &[]); let NodeKind::Text(t) = &layer[1].kind else { panic!("text") }; let (xs, end) = glyph_xs(t); let b = layer[0].geometric_bounds().unwrap(); - assert!(xs.len() == 3 && (end - 40.0 * mm).abs() < 0.01, "{xs:?} {end}"); + assert!(xs.len() == 3, "{xs:?} {end}"); assert!((b.x0 - xs[0]).abs() < 0.01 && (b.x1 - end).abs() < 0.01, "{b:?} {xs:?} {end}"); // On more than one line, each line is aligned without its trailing spaces, and so are its // cells: right aligned at 40 mm, neither passes it. @@ -1190,11 +1174,9 @@ fn opaque_backgrounds_reach_as_far_as_the_advances() { let b = layer[0].geometric_bounds().unwrap(); assert!((b.x0 - 10.0 * mm).abs() < 0.01 && b.x1 > 10.0 * mm, "{b:?}"); assert!(drawn(1, arial(), " \t", &[]).is_empty()); - // Underlined blanks draw their underline, on a transparent background too. - for mode in [1, 2] { - let layer = drawn(mode, font_of("Arial", true), " ", &[]); - assert!(layer.iter().any(|n| matches!(&n.kind, NodeKind::Text(t) if t.runs[0].style.underline)), "{mode}"); - } + // NULs alone in an underlined font fill their cells and add no type. + let layer = opaque(font_of("Arial", true), "\0", &[2000]); + assert!(layer.len() == 1 && matches!(layer[0].kind, NodeKind::Path { .. }), "{layer:?}"); // A file that never sets the mode draws in the opaque mode a playback starts in. let layer = drawn(0, arial(), "Hi", &[]); assert_eq!(fill_rgb(&layer[0]), Some([0, 255, 0])); diff --git a/docs/mcp.md b/docs/mcp.md index 95bce038ca..20c3c80722 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -9875,11 +9875,9 @@ images and point type in the font the file names. Type keeps the file's characte kerning off. On a single left to right line, an advance that tracking can't give (wider than its range, or a tab) starts a new point type object at the position the advance gives, and an underline or strikethrough is filled across the space between and on to the end of the last character's advance. Type on more than one line is placed a line at a time: each line is aligned by its own advances and -split as a single line is. NULs at the start of the text, or after a line break, move the start of their line by their -advances. Blanks that are underlined or struck through draw their bars. A character cell runs from the font's OS/2 +split as a single line is. A character cell runs from the font's OS/2 `usWinAscent` above the baseline to its `usWinDescent` below it: top and bottom aligned text has the top or the -bottom of its cells at the reference point. A single line without character advances is aligned as long as its -glyphs' advances, trailing spaces included. Text drawn in the opaque background mode, which a file is in until it +bottom of its cells at the reference point. Text drawn in the opaque background mode, which a file is in until it sets the mode to transparent, gets one filled rectangle of the background color behind the character cells of each line, as far as its advances reach (NULs' included), placed before the type. An EMF that draws with EMF+ records is read from them. Hatched and pattern brushes fill with their average color. Records VectorCraft doesn't read are skipped with one warning. diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index f4c76fcbbd..24bb533a8d 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -2271,6 +2271,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - EMF and WMF type takes its size from the font's height, where a negative height is the em and a positive height is the character cell, and a font's average character width becomes Horizontal Scale against the face's own average width (OS/2 `xAvgCharWidth`) when the face gives one, as [LOGFONT](https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-logfontw) and [MS-EMF 2.2.13](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-emf/1cd7cb7a-1a7c-48d2-b4a4-c218f9d12100) describe the two fields. VectorCraft's own rules are that the cell is the face's `usWinAscent` plus `usWinDescent` at a variable font's instance (its ascent plus descent without an OS/2 table), that a negative width is read as its absolute value, and that the width is ignored when the height is 0 (`a_font_width_becomes_horizontal_scale`, `a_positive_font_height_is_the_character_cell`, `a_font_the_system_lacks_is_measured_in_the_face_that_draws_it`, `wmf_font_width_becomes_horizontal_scale`). - EMF and WMF files are read by the shared `craft-metafile` reader and open, place and paste as editable paths, clipping groups, images and point type: an EMF drawn with EMF+ records (on their own, or beside plain records) is read from them instead of opening empty, and hatched and pattern brushes fill with their average color (`crates/metafile/src/tests/import.rs`). - EMF, WMF and EMF+ text keeps the character advances the file gives (ExtTextOut's `lpDx`, DrawDriverString positions) as tracking, with pair kerning off; on a single left to right line, an advance that tracking can't give (wider than its range, or a tab) starts a new point type object where the advance puts it, with an underline or strikethrough filled across the space between and on to the end of the last character's advance; type on more than one line is placed a line at a time, each line aligned by its own advances and split as a single line is (`text_is_spaced_by_its_advances`, `multiline_text_with_advances_aligns_each_line`, `wmf_text_is_spaced_by_its_advances`, `emf_plus_driver_strings_keep_their_positions`, `split_type_keeps_its_underline_and_right_to_left_order`). + - EMF and WMF text drawn in the opaque background mode, which a playback starts in ([MS-EMF 2.1.4 BackgroundMode](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-emf/2f57054c-2b69-4303-a6f8-5aacd401f759), [SetBkMode](https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-setbkmode)), gets one rectangle of the background color behind each line's character cells, placed before the type; transparent text gets none. A character cell runs from the font's OS/2 `usWinAscent` above the baseline to its `usWinDescent` below it, and top or bottom aligned text puts the top or the bottom of the cell at the reference point (`opaque_backgrounds_fill_behind_the_character_cells`, `opaque_backgrounds_reach_as_far_as_the_advances`, `wmf_text_fills_its_cells_in_the_opaque_background_mode`). - EMF and WMF import warns about what the reader leaves out or does not play as the file asks: a file, or a metafile image inside it, cut short by one of the reader's limits (items, bytes kept, saved states, clip paths), with one warning without a count, and, with counts, images and pattern brushes that are not read, clips that are not applied, and raster operations other than a plain copy (`a_file_cut_short_by_another_limit_says_so`, `images_the_reader_does_not_read_are_counted`, `clips_that_are_not_applied_are_counted`, `raster_operations_that_are_not_played_are_counted`, `a_wmf_reports_unread_pattern_brushes_and_raster_operations`). - Export As › HP-GL (`document.export {format: "hpgl"}`) writes a `.plt` plot of an artboard, each artboard or the art for pen plotters and cutters: each visible path once along its line in plotter units from the artboard's bottom-left corner or center, a pen per color or a pen table, curves flattened to a tolerance, type as outlines, clipping masks and the artboard's edges applied, and HP-GL or HP-GL/2 (pen colors and encoded polylines); plots read back by the HP-GL reader give the same lines (`crates/cad/src/hpgl/write/tests.rs`, `crates/engine/src/cmd/fileio/tests_hpgl.rs`). - HP-GL export's `insideFirst` cuts each pen's paths inside before outside: a path is drawn only after the pen's paths that lie inside it (a letter's counter, a part's holes, rings within rings), touching outlines counted as inside and crossing ones not, in paint order or nearest first with `sortPaths`, within the plot's work budget; these order rules are VectorCraft's own (`crates/cad/src/hpgl/write/nest.rs`, `crates/cad/src/hpgl/write/tests.rs`, `crates/engine/src/cmd/fileio/tests_hpgl.rs`). From 8dd0824b3f4789a9bde7d817e9d8655ad3fab7b8 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 19 Nov 2026 05:49:23 -0800 Subject: [PATCH 6/9] Metafile import: opaque backgrounds cover trailing spaces and NUL-only lines On more than one line without advances, each line's background now runs across its glyphs' advances, trailing spaces included, as a single line's does; layout leaves the trailing spaces out of the width it aligns. A first line that holds only NULs fills its cells across their advances instead of drawing nothing. --- crates/metafile/src/import/picture.rs | 30 ++++++++++++++------------- crates/metafile/src/tests/import.rs | 14 ++++++++++--- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/crates/metafile/src/import/picture.rs b/crates/metafile/src/import/picture.rs index 29e40ed984..ce9d3a902b 100644 --- a/crates/metafile/src/import/picture.rs +++ b/crates/metafile/src/import/picture.rs @@ -773,12 +773,10 @@ impl Mapper { /// a new piece after each cluster that tracking can't space by its advance. fn line(&mut self, line: &Line, chars: &[char], adv: Advances, down: f64, out: &mut TextOut) { let Advances { dx, reach, lead } = adv; - if chars.is_empty() { - return; - } // The line's cells, one rectangle behind every piece, run as far each way as its // advances reach (an advance may be negative), from where the leading NULs' advances - // start, which the alignment puts where it puts a line as long as its advances. + // start, which the alignment puts where it puts a line as long as its advances. A line + // of leading NULs alone fills the cells across their advances. let start = aligned(lead.by, dx.iter().sum(), line.align); let (mut lo, mut hi, mut pos) = (lead.reach.0 - lead.by, lead.reach.1 - lead.by, 0.0f64); for (d, r) in dx.iter().zip(reach) { @@ -790,7 +788,7 @@ impl Mapper { let blank = |cs: &[char]| cs.iter().all(|c| c.is_whitespace()); // A piece's type draws when it shows: blanks only when underlined or struck through. let draws = |cs: &[char]| line.shows && (!blank(cs) || line.decorated); - if !draws(chars) { + if chars.is_empty() || !draws(chars) { return; } let db = vectorcraft_text::FontDb::global(); @@ -957,26 +955,30 @@ fn cell_rect(x0: f64, x1: f64, y: f64, cell: (f64, f64)) -> BezPath { /// The character cells of `laid` (the type `s` laid out on more than one line), `cell.0` above /// and `cell.1` below each baseline (points), as one rectangle a line: across the line as layout -/// places it (its trailing blanks are left out of the width layout aligns), or for a line of -/// blanks alone as wide as their advances, where `align` puts a line that long. +/// places it and across its glyphs' advances, its trailing blanks included (layout leaves them +/// out of the width it aligns), or for a line of blanks alone as wide as their advances, where +/// `align` puts a line that long. fn cells(laid: &vectorcraft_text::TextLayout, s: &str, cell: (f64, f64), align: &HAlign) -> BezPath { - // Each line's baseline, the sum of its glyphs' advances and whether they are all blanks. - // Glyphs come line by line. - let mut lines: Vec<(usize, f64, f64, bool)> = Vec::new(); + // Each line's baseline, the sum of its glyphs' advances, how far before and after the + // reference point they reach, and whether they are all blanks. Glyphs come line by line. + type Row = (usize, f64, f64, (f64, f64), bool); + let mut lines: Vec = Vec::new(); for g in &laid.glyphs { let blank = s.get(g.byte..).and_then(|r| r.chars().next()).is_none_or(char::is_whitespace); + let (from, to) = (g.origin.x.min(g.origin.x + g.advance), g.origin.x.max(g.origin.x + g.advance)); match lines.last_mut() { - Some((line, _, width, all)) if *line == g.line => { + Some((line, _, width, reach, all)) if *line == g.line => { *width += g.advance; + *reach = (reach.0.min(from), reach.1.max(to)); *all &= blank; } - _ => lines.push((g.line, g.origin.y, g.advance, blank)), + _ => lines.push((g.line, g.origin.y, g.advance, (from, to), blank)), } } let mut bp = BezPath::new(); - for (line, y, width, blank) in lines { + for (line, y, width, reach, blank) in lines { let (x0, x1) = match laid.lines.get(line) { - Some(l) if !blank => (l.x0, l.x1), + Some(l) if !blank => (l.x0.min(reach.0), l.x1.max(reach.1)), _ => { let x0 = aligned(0.0, width, align); (x0, x0 + width) diff --git a/crates/metafile/src/tests/import.rs b/crates/metafile/src/tests/import.rs index aebed8a859..f7937614d4 100644 --- a/crates/metafile/src/tests/import.rs +++ b/crates/metafile/src/tests/import.rs @@ -1148,10 +1148,18 @@ fn opaque_backgrounds_reach_as_far_as_the_advances() { let b = layer[0].geometric_bounds().unwrap(); assert!(xs.len() == 3, "{xs:?} {end}"); assert!((b.x0 - xs[0]).abs() < 0.01 && (b.x1 - end).abs() < 0.01, "{b:?} {xs:?} {end}"); - // On more than one line, each line is aligned without its trailing spaces, and so are its - // cells: right aligned at 40 mm, neither passes it. + // Layout aligns a line without its trailing spaces: right aligned at 40 mm, the space after + // the "i" runs on past it. On more than one line, the cells also run across the trailing + // spaces, as far as on one line. + assert!(end > 41.0 * mm, "{end}"); let b = aligned(2, 26, 4000, arial(), "Hi \nHi", &[])[0].geometric_bounds().unwrap(); - assert!((b.x1 - 40.0 * mm).abs() < 0.01, "{b:?}"); + assert!((b.x1 - end).abs() < 0.01, "{b:?} {end}"); + // Leading NULs on a line of their own fill their cells across their advances, before the + // next line: from 10 to 30 mm. + let layer = opaque(arial(), "\0\nA", &[2000, 0, 1000]); + let first = layer[0].geometric_bounds().unwrap(); + assert!((first.x0 - 10.0 * mm).abs() < 0.01 && (first.x1 - 30.0 * mm).abs() < 0.01, "{first:?}"); + assert!(matches!(layer[1].kind, NodeKind::Path { .. }) && matches!(layer[2].kind, NodeKind::Text(_)), "{layer:?}"); // NULs whose advances go forward and back again still fill as far as they reach. let layer = opaque(arial(), "\0\0", &[1000, -1000]); assert_eq!(layer.len(), 1); From 14318099c29ff5f546cfbea9b6b23b671b45015a Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 19 Nov 2026 05:54:13 -0800 Subject: [PATCH 7/9] Metafile import: an underlined blank line's background follows its bar On more than one line without advances, a line of blanks whose underline or strikethrough draws now has its background across its glyphs, where the bar is drawn, instead of where the alignment puts a line that long. Text without a background no longer measures or builds the cells. --- crates/metafile/src/import/picture.rs | 66 +++++++++++++++------------ crates/metafile/src/tests/import.rs | 24 ++++++++++ 2 files changed, 60 insertions(+), 30 deletions(-) diff --git a/crates/metafile/src/import/picture.rs b/crates/metafile/src/import/picture.rs index ce9d3a902b..226ad0380e 100644 --- a/crates/metafile/src/import/picture.rs +++ b/crates/metafile/src/import/picture.rs @@ -686,29 +686,31 @@ impl Mapper { if dx.is_empty() { let mut text = whole; let laid = vectorcraft_text::layout(db, &text); - // Where one line's glyphs start, and the sum of their advances, its trailing blanks - // included. - let along = laid - .glyphs - .iter() - .fold((f64::INFINITY, 0.0), |(from, width), g| (from.min(g.origin.x.min(g.origin.x + g.advance)), width + g.advance)); - let one = laid.lines.len() == 1 && along.0.is_finite() && along.1.is_finite(); text.xf = base * Affine::translate((0.0, drop)); text.cached_bounds = Some(laid.bounds); - // The cells of one line run across its advances, from where its type starts, or for - // blanks alone, which draw no type, where the alignment puts a line that long. Those - // of more than one line run across each line's glyphs. NULs alone span their - // advances, where the alignment puts them. - let cells = if nuls { - let start = aligned(first.by * k, 0.0, &t.h_align) - first.by * k; - cell_rect(start + first.reach.0 * k, start + first.reach.1 * k, 0.0, cell) - } else if one { - let x0 = if shows { along.0 } else { aligned(0.0, along.1, &t.h_align) }; - cell_rect(x0, x0 + along.1, laid.glyphs.first().map_or(0.0, |g| g.origin.y), cell) - } else { - cells(&laid, &s, cell, &t.h_align) - }; - out.backs.extend(self.background(&line, cells, text.xf)); + if background.is_some() { + // Where one line's glyphs start, and the sum of their advances, its trailing + // blanks included. + let along = laid + .glyphs + .iter() + .fold((f64::INFINITY, 0.0), |(from, width), g| (from.min(g.origin.x.min(g.origin.x + g.advance)), width + g.advance)); + let one = laid.lines.len() == 1 && along.0.is_finite() && along.1.is_finite(); + // The cells of one line run across its advances, from where its type starts, or + // for blanks alone, which draw no type, where the alignment puts a line that long. + // Those of more than one line run across each line's glyphs. NULs alone span + // their advances, where the alignment puts them. + let cells = if nuls { + let start = aligned(first.by * k, 0.0, &t.h_align) - first.by * k; + cell_rect(start + first.reach.0 * k, start + first.reach.1 * k, 0.0, cell) + } else if one { + let x0 = if shows { along.0 } else { aligned(0.0, along.1, &t.h_align) }; + cell_rect(x0, x0 + along.1, laid.glyphs.first().map_or(0.0, |g| g.origin.y), cell) + } else { + cells(&laid, &s, cell, &t.h_align, shows && line.decorated) + }; + out.backs.extend(self.background(&line, cells, text.xf)); + } if shows { let mut n = Node::new(NodeId(0), NodeKind::Text(Box::new(text))); n.opacity = opacity; @@ -778,13 +780,15 @@ impl Mapper { // start, which the alignment puts where it puts a line as long as its advances. A line // of leading NULs alone fills the cells across their advances. let start = aligned(lead.by, dx.iter().sum(), line.align); - let (mut lo, mut hi, mut pos) = (lead.reach.0 - lead.by, lead.reach.1 - lead.by, 0.0f64); - for (d, r) in dx.iter().zip(reach) { - (lo, hi) = (lo.min(pos + r.0), hi.max(pos + r.1)); - pos += d; + if line.background.is_some() { + let (mut lo, mut hi, mut pos) = (lead.reach.0 - lead.by, lead.reach.1 - lead.by, 0.0f64); + for (d, r) in dx.iter().zip(reach) { + (lo, hi) = (lo.min(pos + r.0), hi.max(pos + r.1)); + pos += d; + } + let xf = line.base * Affine::translate((0.0, line.drop + down)); + out.backs.extend(self.background(line, cell_rect(start + lo, start + hi, 0.0, line.cell), xf)); } - let xf = line.base * Affine::translate((0.0, line.drop + down)); - out.backs.extend(self.background(line, cell_rect(start + lo, start + hi, 0.0, line.cell), xf)); let blank = |cs: &[char]| cs.iter().all(|c| c.is_whitespace()); // A piece's type draws when it shows: blanks only when underlined or struck through. let draws = |cs: &[char]| line.shows && (!blank(cs) || line.decorated); @@ -956,9 +960,10 @@ fn cell_rect(x0: f64, x1: f64, y: f64, cell: (f64, f64)) -> BezPath { /// The character cells of `laid` (the type `s` laid out on more than one line), `cell.0` above /// and `cell.1` below each baseline (points), as one rectangle a line: across the line as layout /// places it and across its glyphs' advances, its trailing blanks included (layout leaves them -/// out of the width it aligns), or for a line of blanks alone as wide as their advances, where -/// `align` puts a line that long. -fn cells(laid: &vectorcraft_text::TextLayout, s: &str, cell: (f64, f64), align: &HAlign) -> BezPath { +/// out of the width it aligns). A line of blanks alone runs across its glyphs' advances when +/// the type draws its underline or strikethrough (`decorated`), and otherwise as wide as their +/// advances, where `align` puts a line that long. +fn cells(laid: &vectorcraft_text::TextLayout, s: &str, cell: (f64, f64), align: &HAlign, decorated: bool) -> BezPath { // Each line's baseline, the sum of its glyphs' advances, how far before and after the // reference point they reach, and whether they are all blanks. Glyphs come line by line. type Row = (usize, f64, f64, (f64, f64), bool); @@ -979,6 +984,7 @@ fn cells(laid: &vectorcraft_text::TextLayout, s: &str, cell: (f64, f64), align: for (line, y, width, reach, blank) in lines { let (x0, x1) = match laid.lines.get(line) { Some(l) if !blank => (l.x0.min(reach.0), l.x1.max(reach.1)), + _ if decorated => reach, _ => { let x0 = aligned(0.0, width, align); (x0, x0 + width) diff --git a/crates/metafile/src/tests/import.rs b/crates/metafile/src/tests/import.rs index f7937614d4..217b962dbe 100644 --- a/crates/metafile/src/tests/import.rs +++ b/crates/metafile/src/tests/import.rs @@ -1160,6 +1160,30 @@ fn opaque_backgrounds_reach_as_far_as_the_advances() { let first = layer[0].geometric_bounds().unwrap(); assert!((first.x0 - 10.0 * mm).abs() < 0.01 && (first.x1 - 30.0 * mm).abs() < 0.01, "{first:?}"); assert!(matches!(layer[1].kind, NodeKind::Path { .. }) && matches!(layer[2].kind, NodeKind::Text(_)), "{layer:?}"); + // An underlined line of blanks between two others draws its bar across its glyphs, and its + // cells run across the same glyphs. + let layer = opaque(font_of("Arial", true), "A\n \nB", &[]); + let (NodeKind::Path { path, .. }, NodeKind::Text(t)) = (&layer[0].kind, &layer[1].kind) else { panic!("a path and type") }; + let mut rects: Vec<(f64, f64, f64)> = Vec::new(); + for el in path.to_bezpath().elements() { + let p = match el { + vectorcraft_geom::PathEl::MoveTo(p) => { + rects.push((p.x, p.x, p.y)); + *p + } + vectorcraft_geom::PathEl::LineTo(p) => *p, + _ => continue, + }; + if let Some(r) = rects.last_mut() { + *r = (r.0.min(p.x), r.1.max(p.x), r.2.min(p.y)); + } + } + rects.sort_by(|a, b| a.2.total_cmp(&b.2)); + let laid = vectorcraft_text::layout(vectorcraft_text::FontDb::global(), t); + let spaces: Vec<(f64, f64)> = + laid.glyphs.iter().filter(|g| g.line == 1).map(|g| ((t.xf * g.origin).x, (t.xf * g.origin).x + g.advance)).collect(); + let (from, to) = spaces.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |(a, b), (x0, x1)| (a.min(*x0), b.max(*x1))); + assert!(rects.len() == 3 && (rects[1].0 - from).abs() < 0.01 && (rects[1].1 - to).abs() < 0.01, "{rects:?} {spaces:?}"); // NULs whose advances go forward and back again still fill as far as they reach. let layer = opaque(arial(), "\0\0", &[1000, -1000]); assert_eq!(layer.len(), 1); From 5b25517dc12cb07a5f5d82472739a82870088178 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 19 Nov 2026 05:59:19 -0800 Subject: [PATCH 8/9] Metafile import: one line's background reaches its furthest glyph edge A single line without advances now has its background from the nearest to the furthest edge its glyphs' advances reach, as a line of several does, instead of from the nearest edge on by the sum of the advances. --- crates/metafile/src/import/picture.rs | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/crates/metafile/src/import/picture.rs b/crates/metafile/src/import/picture.rs index 226ad0380e..1cfb3038cd 100644 --- a/crates/metafile/src/import/picture.rs +++ b/crates/metafile/src/import/picture.rs @@ -689,23 +689,28 @@ impl Mapper { text.xf = base * Affine::translate((0.0, drop)); text.cached_bounds = Some(laid.bounds); if background.is_some() { - // Where one line's glyphs start, and the sum of their advances, its trailing - // blanks included. - let along = laid - .glyphs - .iter() - .fold((f64::INFINITY, 0.0), |(from, width), g| (from.min(g.origin.x.min(g.origin.x + g.advance)), width + g.advance)); - let one = laid.lines.len() == 1 && along.0.is_finite() && along.1.is_finite(); - // The cells of one line run across its advances, from where its type starts, or - // for blanks alone, which draw no type, where the alignment puts a line that long. + // How far one line's glyphs reach each way, and the sum of their advances, its + // trailing blanks included. + let along = laid.glyphs.iter().fold((f64::INFINITY, f64::NEG_INFINITY, 0.0), |(from, to, width), g| { + let (a, b) = (g.origin.x, g.origin.x + g.advance); + (from.min(a.min(b)), to.max(a.max(b)), width + g.advance) + }); + let one = laid.lines.len() == 1 && along.0.is_finite() && along.1.is_finite() && along.2.is_finite(); + // The cells of one line run as far as its glyphs' advances reach, or for blanks + // alone, which draw no type, where the alignment puts a line that long. // Those of more than one line run across each line's glyphs. NULs alone span // their advances, where the alignment puts them. let cells = if nuls { let start = aligned(first.by * k, 0.0, &t.h_align) - first.by * k; cell_rect(start + first.reach.0 * k, start + first.reach.1 * k, 0.0, cell) } else if one { - let x0 = if shows { along.0 } else { aligned(0.0, along.1, &t.h_align) }; - cell_rect(x0, x0 + along.1, laid.glyphs.first().map_or(0.0, |g| g.origin.y), cell) + let (x0, x1) = if shows { + (along.0, along.1) + } else { + let x0 = aligned(0.0, along.2, &t.h_align); + (x0, x0 + along.2) + }; + cell_rect(x0, x1, laid.glyphs.first().map_or(0.0, |g| g.origin.y), cell) } else { cells(&laid, &s, cell, &t.h_align, shows && line.decorated) }; From abcb2a40b7adb7f8adc0b6ae742d296864b1ef21 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Thu, 19 Nov 2026 23:36:30 +0700 Subject: [PATCH 9/9] xtask: pdf-deps expects the craft-libs pin main moved to in #8703 --- xtask/src/pdf_deps.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs index e0877302a9..0b9653830a 100644 --- a/xtask/src/pdf_deps.rs +++ b/xtask/src/pdf_deps.rs @@ -5,7 +5,7 @@ use std::process::Command; use serde_json::Value; -const REV: &str = "64b181977a0488e4d1e167bc5cc8cfededc2ed4b"; +const REV: &str = "50b0ee7bf811e363b5f238382b5c77318cf33e46"; const PACKAGES: &[(&str, &str, &str)] = &[ ("craft-pdf", "0.1.0", REV), ("krilla", "0.8.2", REV),