Type: new type keeps a style's look and transparency in another document

A graphic style picked in one document and used for new type in another
lost its look when the style was one plain fill and stroke, and lost its
opacity and blend mode in every case, because both checks read the style
name that is dropped outside the style's document. New type now checks
whether its look came from a graphic style separately from the link: the
link is still left out in another document, the look and transparency
are not.

The docs say that area type made with `text.create` and `area` takes the
template, and only Type on a Path and `text.createInPath` area type keep
the default appearance.
This commit is contained in:
dotCooCoo committed 2026-12-05 00:52:29 -08:00
1 parent 949b344784
commit 5f49ebf6e5
4 files changed
+39 -13

No files matched your search

+18 -9
View File
@@ -280,6 +280,8 @@ pub(crate) struct NewArt {
opacity: f32,
blend: BlendMode,
style: Option<String>,
/// Taken from a graphic style, linked to it or not (a style from another document is not).
styled: bool,
/// From the template: placed gradients are relative to the unit box.
unit_box: bool,
}
@@ -287,7 +289,7 @@ pub(crate) struct NewArt {
impl NewArt {
/// A plain look: `appearance`, full opacity, no link.
pub(crate) fn plain(appearance: Appearance) -> Self {
Self { appearance, opacity: 1.0, blend: BlendMode::Normal, style: None, unit_box: false }
Self { appearance, opacity: 1.0, blend: BlendMode::Normal, style: None, styled: false, unit_box: false }
}
/// Give new object `n` (in `d`) this look: its placed gradients land relative to its bounds, and
@@ -295,7 +297,7 @@ impl NewArt {
/// unless the look is a graphic style's).
pub(crate) fn apply(&self, d: &mut vectorcraft_doc::Document, n: &mut Node) {
self.place(n);
if matches!(n.kind, NodeKind::Text(_)) && self.style.is_none() {
if matches!(n.kind, NodeKind::Text(_)) && !self.styled {
return;
}
(n.opacity, n.blend) = (self.opacity, self.blend);
@@ -346,21 +348,28 @@ impl Session {
st.width = width;
}
let (opacity, blend, style) = self.new_art_transparency();
NewArt { appearance, opacity, blend, style: style.map(str::to_string), unit_box: true }
NewArt { appearance, opacity, blend, style: style.map(str::to_string), styled: self.new_art_styled(), unit_box: true }
}
/// The look of new type (`text.create`): the template's fills, strokes and effects when it is
/// more than one plain fill and stroke or comes from a graphic style, else none of its own, so
/// the characters' fill and stroke show. The template is not repainted with the fill and
/// stroke proxies.
/// 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 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 (opacity, blend, style) = self.new_art_transparency();
if t.is_basic() && style.is_none() {
let styled = self.new_art_styled();
if t.is_basic() && !styled {
return plain();
}
NewArt { appearance: t.into_owned(), opacity, blend, style: style.map(str::to_string), unit_box: true }
let (opacity, blend, style) = self.new_art_transparency();
NewArt { appearance: t.into_owned(), opacity, blend, style: style.map(str::to_string), styled, unit_box: true }
}
/// Does the next object drawn take its look from a graphic style, in this document or the one
/// the style was taken from?
fn new_art_styled(&self) -> bool {
!self.basic_only() && self.paint.style.is_some()
}
/// The appearance of the next object drawn (the Appearance panel shows it with nothing
+16
View File
@@ -649,3 +649,19 @@ fn new_art_in_another_document_is_not_linked_to_a_style_of_the_same_name() {
run(&mut s, "text.create", json!({"x": 200, "y": 200, "text": "k"}));
assert_eq!(s.selection_graphic_style().map(|(g, linked)| (g.name.clone(), linked)), Some(("Shared".to_string(), true)));
}
#[test]
fn new_type_in_another_document_takes_a_basic_styles_look_and_transparency() {
let mut s = session();
let src = painted(&mut s, 20.0, "#ff0000", "#0000ff", 2.0);
let red = node(&s, src).appearance.fill_paint();
run(&mut s, "transparency.set", json!({"opacity": 50, "blend": "multiply"}));
run(&mut s, "graphicStyle.new", json!({"name": "Red"}));
run(&mut s, "select.none", json!({}));
run(&mut s, "graphicStyle.apply", json!({"name": "Red"}));
run(&mut s, "file.new", json!({"width": 400, "height": 300}));
let n = new_type(&mut s, json!({"x": 200, "y": 200, "text": "k"}));
assert_eq!(n.appearance.fill_paint(), red, "the style's fill");
assert_eq!((n.opacity, n.blend), (0.5, BlendMode::Multiply), "the style's transparency");
assert_eq!(n.extras().graphic_style, None, "no link to a style of another document");
}
+4 -3
View File
@@ -11574,9 +11574,10 @@ color. With Override Character Color on, its characters lose the fill and stroke
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
it was taken from was in; in another document they take the look without the link. When text wrap moves new area
type as it is made (an Auto Size frame below a wrap object grows), the template's placed gradients fit the frame the
type ends with. Type on a Path and Area Type (`text.createInPath`) keep the default appearance.
it was taken from was in; in another document they take the look, with the style's opacity and blend mode, without
the link. When text wrap moves new area type as it is made (an Auto Size frame below a wrap object grows), the
template's placed gradients fit the frame the type ends with. Area type made with `text.create` and `area` takes the
template too; Type on a Path and area type made with `text.createInPath` keep the default appearance.
`appearance.setNewArtBasic` rejects an `on` value that is not a boolean. Omitting `on` toggles the current preference.
`appearance.setNewArt {fill?, stroke?, weight?, cap?, join?, miterLimit?, dash?, dashOffset?, fillOverprint?,
strokeOverprint?}` sets new art's fill, stroke and stroke options whatever is selected, and leaves the selection, its
+1 -1
View File
@@ -783,7 +783,7 @@ since 2026-10-01.
- **PDF editable import:** Place from bytes or a path with `link: false`, and `clipboard.importPdf` followed by Paste, preserve live type on the selected page. Place still honors `textAs: "outlines"`. Synthetic two-page regressions: `crates/engine/src/cmd/fileio/tests_pdffidelity.rs`. No change to the PDF reader's existing fallback rules.
- **Tab stops in `.ai`/EPS type and right-aligned lines with tabs (#6147):** type from the text document keeps its paragraphs' tab stops (key 30: positions and left, center, right and decimal alignments; leaders aren't read), at most 1,024 a paragraph and 2^20 a story, past which the default stops apply with a warning. In right-aligned area type, the text before a line's last tab sits at its stops, measured from the left edge, and the text after it (none when the tab ends the line, with its hyphen when the line is hyphenated) against the right edge; centred and justified lines, point type and right-to-left paragraphs are aligned as a whole as before. Evidence: `ate::tests::a_paragraph_keeps_its_tab_stops`, `ate::tests::a_story_s_tab_stops_are_bounded`, `tests::right_aligned_area_type_sets_the_text_after_its_last_tab_against_the_edge`, `import_fuzz::text_frames_with_hostile_paragraph_attributes_never_panic`. Scores unchanged.
- **`.ai`/EPS graphic styles that paint with a named gradient:** a graphic style library's style (or a file's listed style) whose fill, or the fill or stroke of a style of one paint, paints with one of the file's gradients by name loads with that gradient at the style's angle, fitted to the bounds of each object it is applied to (VectorCraft's own placement; the style stores only the gradient's name and angle). A style naming a gradient the file doesn't define, or painting with a pattern, is still left out. Evidence: `fileio::tests_aiimport::graphic_styles_in_a_ai_library_that_paint_with_a_named_gradient_load_with_it`, `style::tests::a_style_of_one_paint_reads_as_the_fill_and_stroke_its_xd_turns_on`. Scores unchanged.
- **New type takes new art's appearance:** with New Art Has Basic Appearance off, new objects take every appearance attribute of the current appearance ([Edit appearance attributes](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/apply-graphic-styles/edit-appearance-attributes.html)). Type made with `text.create` (the Type and Vertical Type tools) now 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 picked with nothing selected, and with Override Character Color on its characters lose the fill and stroke those paint, except that a `color` given to `text.create` keeps the characters' fill. Its placed gradients fit the frame the type has once text wrap has moved it. Type made with a style's look is linked to the style, in the document the style was picked in; in another document it takes the look without the link. Type on a Path and Area Type (`text.createInPath`) keep the default appearance. With the option on and no style picked, new type is unchanged. Evidence: `tests::newart::with_basic_appearance_off_new_type_takes_the_last_selections_fills_and_effects`, `tests::newart::new_type_keeps_plain_characters_without_a_template_beyond_a_basic_fill_and_stroke`, `tests::newart::a_graphic_style_clicked_with_nothing_selected_styles_the_next_type`, `tests::newart::a_basic_graphic_style_picked_with_basic_appearance_off_styles_each_new_type`, `tests::newart::new_type_that_text_wrap_moves_takes_the_styles_gradient_on_the_frame_it_ends_with`, `tests::newart::new_art_in_another_document_is_not_linked_to_a_style_of_the_same_name`. Scores unchanged.
- **New type takes new art's appearance:** with New Art Has Basic Appearance off, new objects take every appearance attribute of the current appearance ([Edit appearance attributes](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/apply-graphic-styles/edit-appearance-attributes.html)). Type made with `text.create` (the Type and Vertical Type tools) now 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 picked with nothing selected, and with Override Character Color on its characters lose the fill and stroke those paint, except that a `color` given to `text.create` keeps the characters' fill. Its placed gradients fit the frame the type has once text wrap has moved it. Type made with a style's look is linked to the style, in the document the style was picked in; in another document it takes the look, with the style's opacity and blend mode, without the link. Area type dragged with the Type tool (`text.create` with `area`) takes the template too; Type on a Path and area type made with `text.createInPath` keep the default appearance. With the option on and no style picked, new type is unchanged. Evidence: `tests::newart::with_basic_appearance_off_new_type_takes_the_last_selections_fills_and_effects`, `tests::newart::new_type_keeps_plain_characters_without_a_template_beyond_a_basic_fill_and_stroke`, `tests::newart::a_graphic_style_clicked_with_nothing_selected_styles_the_next_type`, `tests::newart::a_basic_graphic_style_picked_with_basic_appearance_off_styles_each_new_type`, `tests::newart::new_type_that_text_wrap_moves_takes_the_styles_gradient_on_the_frame_it_ends_with`, `tests::newart::new_art_in_another_document_is_not_linked_to_a_style_of_the_same_name`, `tests::newart::new_type_in_another_document_takes_a_basic_styles_look_and_transparency`. Scores unchanged.
- **`.ai`/EPS type laid out closer to the file's page (#6137):** type from the text document keeps auto leading as auto, each line taking the paragraph's Auto Leading share (key 7) of the largest type on it ([Line and character spacing](https://helpx.adobe.com/illustrator/using/line-character-spacing.html)); the paragraph's hyphenation options (keys 10 to 15) are read; area type of one frame whose last lines the file sets, but which don't fit here, may get a frame taller from its bottom, by its lines' deepest descent plus 0.05 pt and only when that shows more of those lines and no more than the file has (`vectorcraft_text::fit_source_lines`), with a warning when it does: the frame can stay as it is, or show only some of them; and a line a soft return ends is justified as a wrapped line is, a paragraph's last line keeping its alignment. Evidence: `ate::tests::auto_leading_follows_the_size_of_each_line`, `ate::tests::a_paragraph_keeps_its_auto_leading`, `ate::tests::a_paragraph_keeps_its_hyphenation_options`, `ate::tests::the_last_lines_the_file_sets_in_its_frame_show`, `tests::fit_source_lines_keeps_the_last_lines_the_source_sets`, `tests::typo::soft_return_in_justified_text_spreads_like_a_wrapped_line`. Limits: frames grow only for area type of one frame, horizontal, by its lines' deepest descent plus 0.05 pt; type in a font that isn't installed, and hyphenation in a language that isn't imported, still lay out differently. Scores unchanged.
- **Graphs saved to `.ai` keep their data and settings:** a grouped column, stacked column, line or area graph is written to a `.ai` file, in either form, with the records the `.ai` reader reads (`crates/eps/src/import/ai/read/graph.rs`, #7311): `%_Gs`, its plot, type, settings, axes and table, its series' groups each tagged `Go`, and `%_GS` ([the specification](https://13thmonkey.org/documentation/fonts/AI7FileFormat.pdf), §17 and appendix A). The file opens again with the same live graph. A graph with settings the reader doesn't keep, graph designs, label formatting, more than 10,000 categories or 256 series, or art the reader doesn't attach a graph to is written as its art, with a warning. `crates/eps/src/legacy_ai/tests.rs` and `crates/eps/src/ai_editing/tests.rs` write and read back each kind of graph; `a_drawn_graph_saved_as_ai_opens_as_a_graph_unless_the_save_warns` checks every graph type the graph tools draw. Scores unchanged.
- **Graph legend swatches have their series' stroke:** a default legend swatch of a stacked column, stacked bar, area or pie series has the thin white stroke of the series' marks (VectorCraft's own rule), beside the plot or across the top, and a stroke kept on the series is on the swatch too. Each series' group then paints with one stroke, so a stacked column or area graph the graph tools draw is saved to `.ai` with its data and settings and opens again as a live graph; a stacked bar graph is still written as its art, as the reader has no type for it. Evidence: `cmd::graph::tests::a_legend_swatch_has_the_stroke_of_its_series_marks`, `cmd::graph::tests::a_drawn_stacked_column_graph_saved_as_ai_opens_as_a_graph_that_takes_new_data`, `cmd::graph::tests::a_drawn_graph_saved_as_ai_opens_as_a_graph_unless_the_save_warns`. Scores unchanged.