diff --git a/crates/engine/src/cmd/newart.rs b/crates/engine/src/cmd/newart.rs index b3b1a95afa..54eb05b312 100644 --- a/crates/engine/src/cmd/newart.rs +++ b/crates/engine/src/cmd/newart.rs @@ -370,13 +370,14 @@ impl Session { /// more than one plain fill and stroke or comes from a graphic style (of this document or /// another), else none of its own, so the characters' fill and stroke show. The document's own /// default look (its redefined Default Graphic Style, which [`reset`] gives new art) leaves type - /// plain as the shipped default does. The template is not repainted with the fill and stroke - /// proxies. + /// plain as the shipped default does; the same look taken from the selection does not. The + /// template is not repainted with the fill and stroke proxies. pub(crate) fn new_type_look(&self) -> NewArt { let plain = || NewArt::plain(Appearance::default()); let Some(t) = self.template() else { return plain() }; let styled = self.new_art_styled(); - let default_look = || self.active().and_then(|st| redefined_default_style(&st.doc)).is_some_and(|g| style_look(g).approx_eq(&t)); + let default_look = + || !self.paint.inherited && self.active().and_then(|st| redefined_default_style(&st.doc)).is_some_and(|g| style_look(g).approx_eq(&t)); if !styled && (t.is_basic() || default_look()) { return plain(); } diff --git a/crates/engine/src/tests/newart.rs b/crates/engine/src/tests/newart.rs index 7f69ea2b99..3d9bd36473 100644 --- a/crates/engine/src/tests/newart.rs +++ b/crates/engine/src/tests/newart.rs @@ -700,3 +700,23 @@ fn new_art_and_type_from_a_style_redefined_after_it_was_picked_keep_the_picked_l assert_eq!((n.appearance.effects.len(), n.appearance.fill_paint()), (1, picked.fill_paint()), "{cmd}: the picked look"); } } + +#[test] +fn new_type_takes_a_selected_look_that_matches_the_redefined_default_style() { + let mut s = session(); + let src = fancy(&mut s); + run(&mut s, "graphicStyle.redefine", json!({"name": "Default Graphic Style", "id": src.0})); + run(&mut s, "graphicStyle.breakLink", json!({"ids": [src.0]})); + run(&mut s, "appearance.setNewArtBasic", json!({"on": false})); + run(&mut s, "select.set", json!({"ids": [src.0]})); + run(&mut s, "select.none", json!({})); + let n = new_type(&mut s, json!({"x": 200, "y": 200, "text": "in"})); + assert_eq!(n.appearance.items.iter().filter(|i| i.is_fill()).count(), 2, "both fills from the selection"); + assert_eq!(n.appearance.effects.len(), 1, "the drop shadow from the selection"); + // The same look from paint.default is the document's default, so new type stays plain. + run(&mut s, "select.none", json!({})); + run(&mut s, "paint.default", json!({})); + let d = new_type(&mut s, json!({"x": 200, "y": 260, "text": "df"})); + assert!(d.appearance.items.is_empty() && d.appearance.effects.is_empty(), "plain type"); + assert_ne!(char_fill(&d), Paint::None); +} diff --git a/docs/mcp.md b/docs/mcp.md index 4fb9b9d513..3598d401dc 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -11571,7 +11571,8 @@ resets it. New type (`text.create`) takes the template's fills, strokes and effects when the template is more than one plain fill and stroke or comes from a graphic style; otherwise it has no fills or strokes of its own and its characters keep their color. The look `paint.default` gives in a document whose Default Graphic Style was redefined is the document's default, -and new type made with it keeps its characters' color too. With Override Character Color on, its characters lose the fill and stroke the template paints, as when a +and new type made with it keeps its characters' color too. The same look taken from a selection (New Art Has Basic +Appearance off) gives new type its fills, strokes and effects. With Override Character Color on, its characters lose the fill and stroke the template paints, as when a graphic style is applied to type; a `color` given to `text.create` keeps the characters' fill. Type made with a graphic style's look takes the style's opacity and blend mode and is linked to it; otherwise the type keeps its own opacity and blend mode. New art and type are linked to the style only in the document the style was picked in, or the selection