Merge pull request #9796 from jmverges/fix/ai-save-type-spot-ink

.ai save: type in a spot ink keeps its swatch link
This commit is contained in:
BFlat authored and GitHub committed 2026-11-28 11:12:55 +07:00
commit 1bc87afc7b
10 files changed
+265 -26

No files matched your search

+2 -1
View File
@@ -306,7 +306,8 @@ fn export_held(source: &Document, o: &AiEditingOptions, max_objects: usize, keep
// Artboards that don't fit on the canvas are written on a large canvas, at 1/scale.
let scale = canvas_scale(doc);
// The objects that may keep their effects in an art style, as they are before baking (not on
// a large canvas, whose scale the styles' strokes and effects would need).
// a large canvas, whose scale the styles' strokes and effects would need; there only the styles
// that link type's colors to their swatches are written, which hold no lengths).
let styled = writer::styled_objects(doc);
let (symbol_styled, pattern_styled) = writer::styled_definitions(doc);
let own_styles = doc.graphic_styles != Document::new(1.0, 1.0).graphic_styles;
+115 -4
View File
@@ -5088,6 +5088,89 @@ fn kinsoku_settings_come_back_on_each_paragraph() {
assert_eq!(export_ai_editing(&lossy, &opts()).unwrap().warnings, [writer::TYPE_ATTRIBUTES]);
}
/// Type in spot inks (CMYK, RGB and Lab) and a global process color, as its fill and as its
/// stroke, at full strength and at a tint: each color reads back linked to its swatch at its tint, with no warning, as key 5
/// of the run's paint names an art style of one paint that holds the link. A link to a process
/// swatch that isn't global still warns: the editing data can't hold it.
#[test]
fn type_in_spot_and_global_colors_reads_back_linked_at_its_tint() {
use vectorcraft_doc::{CharStyle, TextObject, TextRun};
use vectorcraft_geom::Point;
let white = Color::cmyk(0.0, 0.0, 0.0, 0.0);
let red = Color::cmyk(0.0, 1.0, 1.0, 0.0);
let mut doc = Document::new(300.0, 200.0);
doc.swatches = vec![
Swatch { name: "[None]".into(), paint: Paint::None, global: false, spot: false },
Swatch { name: "White Ink".into(), paint: solid(white), global: true, spot: true },
Swatch { name: "Red Ink".into(), paint: solid(red), global: true, spot: true },
Swatch { name: "Sky".into(), paint: solid(SKY), global: true, spot: true },
Swatch { name: "Mint".into(), paint: solid(MINT), global: true, spot: true },
Swatch { name: "Brand".into(), paint: solid(BRAND), global: true, spot: false },
Swatch { name: "Ink".into(), paint: solid(GOLD), global: false, spot: false },
]
.into();
doc.swatch_groups = vec![].into();
let layer = doc.layers[0].id;
let stroked = |fill: Paint, stroke: Paint| CharStyle { size: 24.0, fill, stroke, stroke_width: 1.0, ..CharStyle::default() };
let mut t = TextObject::point(Point::new(20.0, 60.0), "", style(24.0, Color::BLACK));
t.runs = vec![
TextRun::new("WHITE ", stroked(linked("White Ink", white, 1.0), Paint::None)),
TextRun::new("RED ", stroked(linked("Red Ink", red, 0.4), linked("Brand", BRAND, 0.6))),
TextRun::new("SKY ", stroked(linked("Sky", SKY, 0.75), linked("Red Ink", red, 1.0))),
TextRun::new("MINT ", stroked(linked("Mint", MINT, 0.3), Paint::None)),
TextRun::new("BRAND", stroked(linked("Brand", BRAND, 1.0), linked("White Ink", white, 0.5))),
];
let n = text_node(&mut doc, t);
doc.insert(Some(layer), usize::MAX, n).unwrap();
let out = export_ai_editing(&doc, &opts()).unwrap();
assert!(out.warnings.is_empty(), "{:?}", out.warnings);
let runs = |d: &Document| {
let mut all = vec![];
paths(&d.layers, &mut all);
all.iter()
.filter_map(|n| match &n.kind {
NodeKind::Text(t) => Some(t.runs.iter().map(|r| (r.text.clone(), paint(&r.style.fill), paint(&r.style.stroke))).collect::<Vec<_>>()),
_ => None,
})
.collect::<Vec<_>>()
};
assert_eq!(runs(&read_back(&doc)), runs(&doc));
let mut process = doc.clone();
let id = process.layers[0].children().unwrap()[0].id;
if let Some(NodeKind::Text(t)) = process.node_mut(id).map(|n| &mut n.kind) {
t.runs[0].style.fill = linked("Ink", GOLD, 1.0);
}
assert_eq!(export_ai_editing(&process, &opts()).unwrap().warnings, [writer::TYPE_ATTRIBUTES]);
}
/// Type whose story isn't written (a thread the text document can't hold, written as outlines)
/// leaves no art style for its colors behind.
#[test]
fn type_written_as_outlines_leaves_no_style_for_its_colors() {
use vectorcraft_doc::{CharStyle, TextKind, TextObject, TextRun};
use vectorcraft_geom::Point;
let red = Color::cmyk(0.0, 1.0, 1.0, 0.0);
let mut doc = Document::new(300.0, 200.0);
let mut swatches: Vec<Swatch> = doc.swatches.iter().cloned().collect();
swatches.push(Swatch { name: "Red Ink".into(), paint: solid(red), global: true, spot: true });
doc.swatches = swatches.into();
let inked = CharStyle { size: 12.0, fill: linked("Red Ink", red, 1.0), ..CharStyle::default() };
let mut first = TextObject::point(Point::ZERO, "A story in a spot ink that runs on.", inked.clone());
first.kind = TextKind::Area { frame: shapes::rectangle(Rect::new(20.0, 20.0, 120.0, 60.0)) };
first.xf = Affine::IDENTITY;
// Point type can't be a frame of a thread: the text document doesn't hold the thread.
let mut second = TextObject::point(Point::new(20.0, 120.0), "", inked.clone());
second.runs = vec![TextRun::new("", inked)];
let (first, second) = (text_node(&mut doc, first), text_node(&mut doc, second));
doc.text_threads.push(vec![first.id, second.id]);
let layer = doc.layers[0].id;
doc.insert(Some(layer), usize::MAX, first).unwrap();
doc.insert(Some(layer), usize::MAX, second).unwrap();
let text = program(&doc);
assert!(!text.contains("%AI11_BeginTextDocument"), "the thread was written as type");
assert!(!text.contains("/SimpleStyle"), "{text}");
}
#[test]
fn type_is_written_again_as_the_same_bytes() {
let doc = typed();
@@ -8122,11 +8205,12 @@ fn a_masks_art_with_an_effect_no_style_holds_is_written_as_it_draws() {
assert!(apart <= 4, "{apart} pixels differ");
}
/// On a large canvas no art style is written (the reader scales the styles of a large canvas):
/// objects with effects are written as their vector art with their geometry effects applied, with a
/// warning.
/// On a large canvas no art style of an object is written (the reader scales the styles of a large
/// canvas): objects with effects are written as their vector art with their geometry effects
/// applied, with a warning. Type's colors keep their swatch links there: their styles hold no
/// lengths.
#[test]
fn a_large_canvas_writes_no_art_styles() {
fn a_large_canvas_writes_only_the_art_styles_of_type_colors() {
let mut doc = Document::new(20000.0, 100.0);
let n = styled_rect(
&mut doc,
@@ -8141,6 +8225,33 @@ fn a_large_canvas_writes_no_art_styles() {
let out = export_ai_editing(&doc, &opts()).unwrap();
assert!(out.warnings.iter().any(|w| w == writer::LARGE_CANVAS_STYLES), "{:?}", out.warnings);
assert!(!String::from_utf8(out.program).unwrap().contains("ArtStyle"));
let mut typed = Document::new(20000.0, 100.0);
let red = Color::cmyk(0.0, 1.0, 1.0, 0.0);
let mut swatches: Vec<Swatch> = typed.swatches.iter().cloned().collect();
swatches.push(Swatch { name: "Red Ink".into(), paint: solid(red), global: true, spot: true });
typed.swatches = swatches.into();
let fill = linked("Red Ink", red, 0.4);
let t = vectorcraft_doc::TextObject::point(
vectorcraft_geom::Point::new(20.0, 60.0),
"FAR",
vectorcraft_doc::CharStyle { size: 24.0, fill: fill.clone(), ..vectorcraft_doc::CharStyle::default() },
);
let n = text_node(&mut typed, t);
let layer = typed.layers[0].id;
typed.insert(Some(layer), usize::MAX, n).unwrap();
let out = export_ai_editing(&typed, &opts()).unwrap();
assert!(out.warnings.is_empty(), "{:?}", out.warnings);
let mut all = vec![];
paths(&read_back(&typed).layers, &mut all);
let fills: Vec<String> = all
.iter()
.filter_map(|n| match &n.kind {
NodeKind::Text(t) => Some(paint(&t.runs[0].style.fill)),
_ => None,
})
.collect();
assert_eq!(fills, [paint(&fill)]);
}
#[test]
+12
View File
@@ -1623,6 +1623,18 @@ impl<'a> Writer<'a> {
if !self.take_objects(stub) {
return;
}
// The art styles that hold the swatch links of its colors, its thread's too.
let members: Vec<&vectorcraft_doc::TextObject> = match thread {
Some(thread) => thread
.iter()
.filter_map(|id| match &doc.node(*id)?.kind {
NodeKind::Text(t) => Some(t.as_ref()),
_ => None,
})
.collect(),
None => vec![t],
};
self.link_type_colors(&members);
let placed = if let Some(thread) = thread {
// A thread is checked for what it loses, in every frame, when its story is written.
let placed = self.texts.thread(doc, thread, n.id, self.canvas, &|id| !cut_to_clipping_object(doc, id), &self.wraps_held);
+38 -3
View File
@@ -20,7 +20,7 @@ use super::{Writer, Xy, blend_code, compound_path, hide};
use crate::ai_ops;
use crate::ps;
pub(in crate::ai_editing) const LARGE_CANVAS_STYLES: &str = "on a large canvas, no art styles or graphic styles are written: objects with live effects are written with their geometry effects applied to the artwork, where they can no longer be edited, and their other effects are left out of the editing data for other apps";
pub(in crate::ai_editing) const LARGE_CANVAS_STYLES: &str = "on a large canvas, no graphic styles and no art styles of objects are written: objects with live effects are written with their geometry effects applied to the artwork, where they can no longer be edited, and their other effects are left out of the editing data for other apps";
pub(in crate::ai_editing) const PANEL_STYLES: &str = "graphic styles with gradient or pattern fills, with fills, strokes or effects the editing data can't hold as a graphic style, with a name another style has, with names over 1,024 bytes, or past 4,096 styles, are left out of the editing data for other apps";
pub(in crate::ai_editing) const PANEL_EMPTY: &str =
"a Graphic Styles panel with no style written opens from the editing data with a new document's styles";
@@ -173,6 +173,9 @@ pub(in crate::ai_editing) struct Styles {
next_anon: u64,
/// How many objects were written with the graphic style they are linked to.
pub(super) links_written: usize,
/// The styles that only link type's colors to their swatches ([`Writer::type_color_style`]):
/// written only when the text document names them.
type_colors: HashSet<String>,
/// The style texts checked so far, as the reader parses them.
pub(super) parsed: Parsed,
}
@@ -335,6 +338,33 @@ impl Writer<'_> {
std::mem::replace(&mut self.body, saved)
}
/// Look at the swatch links of the colors of type `texts` ([`super::texts::TextDoc::set_link`]):
/// each is held by an art style of one paint, its color with its swatch at its tint, which key 5
/// of a run's paint names ([`Self::type_color_style`]), or by none.
pub(super) fn link_type_colors(&mut self, texts: &[&vectorcraft_doc::TextObject]) {
for p in self.texts.unlooked_links(texts) {
let style = self.type_color_style(p);
self.texts.set_link(p, style);
}
}
/// The name of the art style that holds the swatch link of type colored `p`: a style of one
/// paint, its fill alone on (`0 1 Xd`), whose paint is `p` as a path's fill writes it (a spot or
/// global process color by its name and tint, Registration). The reader gives type whose paint
/// names that style the style's color at its tint, linked to its swatch
/// ([`crate::import::parsed_type_color`]); `None`, and no style, when it wouldn't give the same
/// swatch and tint (a swatch that is neither spot nor global, for one).
fn type_color_style(&mut self, p: &Paint) -> Option<String> {
let Paint::Solid { swatch: Some(name), tint, .. } = p else { return None };
let ops = self.color_ops(p, false);
let text = format!("/SimpleStyle :\n0 O\n{ops}0 1 0 0 0 Xy\n{NO_LINE}0 XR\n0 1 Xd\n/Paint ;\n /Def ;\n");
let back = self.styles.parsed.get(&text).and_then(crate::import::parsed_type_color);
let same = matches!(back, Some(Paint::Solid { swatch: Some(n), tint: t, .. }) if n == name && (t - tint).abs() <= 1e-4);
let name = same.then(|| self.styles.object_style(text))?;
self.styles.type_colors.insert(name.clone());
Some(name)
}
/// A fill style holding a color, as an effect's entry `key` or a fill's own.
fn fill_style(&mut self, s: &mut String, color: vectorcraft_color::Color, key: &str) {
let ops = self.color_ops(&Paint::solid(color), false);
@@ -929,12 +959,17 @@ impl Writer<'_> {
/// The art styles written, in a non-printing block: `%AI9_BeginArtStyles`, each style,
/// `%AI9_EndArtStyles`.
/// A style that only links type's colors is written when the text document names it: type
/// whose story isn't written (written as its outlines instead) leaves none behind.
pub(in crate::ai_editing) fn art_styles(&self, s: &mut String) {
if self.styles.known.is_empty() {
let named = self.texts.named_styles();
let written: Vec<&(String, String)> =
self.styles.known.iter().filter(|(name, _)| !self.styles.type_colors.contains(name) || named.contains(name.as_str())).collect();
if written.is_empty() {
return;
}
s.push_str("%AI5_Begin_NonPrinting\nNp\n%AI9_BeginArtStyles\n");
for (name, text) in &self.styles.known {
for (name, text) in written {
s.push_str(&known_style(name, text));
}
s.push_str("%AI9_EndArtStyles\n%AI5_End_NonPrinting--\n");
+85 -14
View File
@@ -31,7 +31,7 @@ use vectorcraft_geom::{Affine, PathData, Point};
use crate::{ai_ops, ps};
/// What the text document holds of type, and what it leaves out.
pub(in crate::ai_editing) const TYPE_ATTRIBUTES: &str = "attributes of type other than its font, size, leading, tracking, baseline shift, horizontal and vertical scale, solid fill, solid stroke and its weight, cap, join and miter limit, capitals, small capitals at the document's size, Tate-chu-yoko, Standard Vertical Roman Alignment, Insert Aki, paragraph alignment, indents, space before and after, hyphenation on or off, right-to-left direction, Kinsoku set, Kinsoku Shori Type, Burasagari and Bunri-Kinshi (for example underline, kerning, OpenType features, swatch links of its colors, character and paragraph styles, tabs, lists, optical margin alignment, area type's inset spacing, vertical alignment and flow, a minimum first baseline with the Ascent first baseline, and type on a path's effect, alignment and spacing and an end bracket at the very end of an open path) are left out of the editing data for other apps";
pub(in crate::ai_editing) const TYPE_ATTRIBUTES: &str = "attributes of type other than its font, size, leading, tracking, baseline shift, horizontal and vertical scale, solid fill, solid stroke and its weight, cap, join and miter limit, capitals, small capitals at the document's size, Tate-chu-yoko, Standard Vertical Roman Alignment, Insert Aki, paragraph alignment, indents, space before and after, hyphenation on or off, right-to-left direction, Kinsoku set, Kinsoku Shori Type, Burasagari and Bunri-Kinshi (for example underline, kerning, OpenType features, swatch links of its colors other than to spot colors, global process colors and Registration, character and paragraph styles, tabs, lists, optical margin alignment, area type's inset spacing, vertical alignment and flow, a minimum first baseline with the Ascent first baseline, and type on a path's effect, alignment and spacing and an end bracket at the very end of an open path) are left out of the editing data for other apps";
/// The version of the text document's form (`/98 << /0 n >>`), as the newest files users sent have it.
const STREAM_VERSION: u32 = 14;
@@ -177,15 +177,32 @@ fn set(resources: Vec<V>, display: bool) -> V {
/// A paint: kind 0 gray (`[alpha, lightness]`), 1 RGB, 2 CMYK, as the reader's `paint` reads them.
/// RGB values are an RGB color's own (in the working RGB space) and a Lab color's converted into
/// the working RGB space ([`ai_ops::rgb_values`]).
fn paint(c: &Color) -> V {
/// the working RGB space ([`ai_ops::rgb_values`]). With `style`, the art style that links the color
/// to its swatch (key 5, [`TextDoc::link`]): the reader takes the style's color, at its tint, in
/// place of these values.
fn paint(c: &Color, style: Option<&str>) -> V {
let (kind, values) = match *c {
Color::Gray { k } => (0, vec![1.0 - f64::from(k.clamp(0.0, 1.0))]),
Color::Cmyk { c, m, y, k } => (2, [c, m, y, k].iter().map(|v| f64::from(v.clamp(0.0, 1.0))).collect()),
Color::Rgb { .. } | Color::Lab { .. } => (1, ai_ops::rgb_values(*c).iter().map(|v| f64::from(*v)).collect()),
};
let values: Vec<f64> = std::iter::once(1.0).chain(values).collect();
dict(vec![(99, V::Name("SimplePaint")), (0, dict(vec![(0, V::Int(kind)), (1, reals(&values))]))])
let color = dict(vec![(0, V::Int(kind)), (1, reals(&values))]);
match style {
Some(name) => dict(vec![(99, V::Name("CAITextPaint")), (5, V::Str(name.to_owned())), (0, color)]),
None => dict(vec![(99, V::Name("SimplePaint")), (0, color)]),
}
}
/// A color linked to a swatch, by the swatch's name and its tint ([`TextDoc::links`]).
pub(in crate::ai_editing) type LinkKey = (String, u32);
/// The swatch and tint paint `p` is linked to, if it is.
pub(in crate::ai_editing) fn link_key(p: &Paint) -> Option<LinkKey> {
match p {
Paint::Solid { swatch: Some(name), tint, .. } => Some((name.clone(), tint.to_bits())),
_ => None,
}
}
/// The color of paint `p` when the text document can hold it (a solid color or none).
@@ -447,14 +464,16 @@ fn held_aki(v: f64) -> f64 {
/// Has type `t` attributes the text document leaves out ([`TYPE_ATTRIBUTES`])? `fonts` holds the
/// fonts already resolved.
fn loses(t: &TextObject, fonts: &mut ResolvedFonts) -> bool {
fn loses(t: &TextObject, fonts: &mut ResolvedFonts, links: &HashMap<LinkKey, Option<String>>) -> bool {
// Small capitals are read back at Document Setup's default size.
let default_small_caps = vectorcraft_doc::DocSetup::default().small_caps_size;
// Is paint `p` held with its swatch link, by an art style ([`TextDoc::link`])?
let linked = |p: &Paint| link_key(p).is_some_and(|k| matches!(links.get(&k), Some(Some(_))));
// A run's style as the text document holds it: every other attribute at its default. A color
// is held without its swatch link.
// is held without its swatch link, unless an art style holds the link.
let held_char = |s: &CharStyle| {
let unlinked = |p: &Paint| match p {
Paint::Solid { color, .. } => Paint::solid(*color),
Paint::Solid { color, .. } if !linked(p) => Paint::solid(*color),
other => other.clone(),
};
let stroked = !s.stroke.is_none();
@@ -500,8 +519,8 @@ fn loses(t: &TextObject, fonts: &mut ResolvedFonts) -> bool {
..s.clone()
}
};
// A Lab color is written as RGB.
let lab = |p: &Paint| matches!(p, Paint::Solid { color: Color::Lab { .. }, .. });
// A Lab color is written as RGB, unless an art style holds it with its link.
let lab = |p: &Paint| matches!(p, Paint::Solid { color: Color::Lab { .. }, .. }) && !linked(p);
s != held_char(&s) || lab(&s.fill) || lab(&s.stroke) || !fonts.kept(&s)
};
// A paragraph's style as the text document holds it, and its text: aligned to the start of
@@ -842,6 +861,10 @@ pub(in crate::ai_editing) struct TextDoc {
doc_values: usize,
/// The fonts of the styles written so far, as they resolve.
resolved: ResolvedFonts,
/// The swatch links of type's colors looked at so far, by swatch and tint: the art style that
/// holds each (a style of one paint, the color with its swatch, which key 5 of a run's paint
/// names), `None` when the editing data can't hold it ([`super::Writer::link_type_colors`]).
links: HashMap<LinkKey, Option<String>>,
}
impl TextDoc {
@@ -851,7 +874,53 @@ impl TextDoc {
/// Has type `t` attributes the text document leaves out ([`loses`])?
pub(in crate::ai_editing) fn loses(&mut self, t: &TextObject) -> bool {
loses(t, &mut self.resolved)
loses(t, &mut self.resolved, &self.links)
}
/// The colors of type whose swatch links are still to be looked at: the fills and strokes of
/// `texts`' runs that are linked to a swatch and not in [`Self::links`] yet, each once.
pub(in crate::ai_editing) fn unlooked_links<'t>(&self, texts: &[&'t TextObject]) -> Vec<&'t Paint> {
let mut seen = HashSet::new();
texts
.iter()
.flat_map(|t| t.runs.iter().flat_map(|r| [&r.style.fill, &r.style.stroke]))
.filter(|p| link_key(p).is_some_and(|k| !self.links.contains_key(&k) && seen.insert(k)))
.collect()
}
/// Record the art style `style` that holds the swatch link of colors linked as `p` is, or
/// `None` when none does ([`Self::links`]).
pub(in crate::ai_editing) fn set_link(&mut self, p: &Paint, style: Option<String>) {
if let Some(k) = link_key(p) {
self.links.insert(k, style);
}
}
/// The art styles the stories written name for their runs' colors (key 5 of a paint).
pub(in crate::ai_editing) fn named_styles(&self) -> HashSet<&str> {
fn walk<'v>(v: &'v V, out: &mut HashSet<&'v str>) {
match v {
V::Dict(d) => {
if d.iter().any(|(k, v)| *k == 99 && matches!(v, V::Name("CAITextPaint"))) {
out.extend(d.iter().filter_map(|(k, v)| match (k, v) {
(5, V::Str(s)) => Some(s.as_str()),
_ => None,
}));
}
d.iter().for_each(|(_, v)| walk(v, out));
}
V::List(l) => l.iter().for_each(|v| walk(v, out)),
_ => {}
}
}
let mut out = HashSet::new();
self.stories.iter().for_each(|v| walk(v, &mut out));
out
}
/// The art style that holds the swatch link of `p`, if one does.
fn link(&self, p: &Paint) -> Option<&str> {
self.links.get(&link_key(p)?)?.as_deref()
}
/// The index of the font of `st` in the font set.
@@ -909,11 +978,13 @@ impl TextDoc {
let fill = solid(&st.fill).flatten();
// A stroke of no width keeps its paint.
let stroke = solid(&st.stroke).flatten();
// A color linked to a swatch names the art style that holds the link, the fill's for a
// stroke too (the reader's `Texts::with_paints`).
if let Some(c) = &fill {
d.push((53, paint(c)));
d.push((53, paint(c, self.link(&st.fill))));
}
if let Some(c) = &stroke {
d.push((54, paint(c)));
d.push((54, paint(c, self.link(&st.stroke))));
}
d.extend([(56, V::Bool(fill.is_some())), (57, V::Bool(stroke.is_some()))]);
if stroke.is_some() {
@@ -1243,7 +1314,7 @@ impl TextDoc {
if !whole.runs.iter().any(|r| r.text.chars().any(|c| !c.is_whitespace())) || !self.room(&whole, texts.len()) {
return None;
}
let lost = split_differs || texts.iter().any(|t| loses(t, &mut self.resolved));
let lost = split_differs || texts.iter().any(|t| loses(t, &mut self.resolved, &self.links));
let frames: Vec<usize> = texts.iter().map(|t| self.frame(t, canvas, scale)).collect();
let story = self.story(&whole, &frames, scale);
if !self.fits(mark) {
@@ -1357,7 +1428,7 @@ impl TextDoc {
(12, V::Int(0)),
// Every run writes its own key 35, so this only sets where new type starts: Standard (1).
(35, V::Int(1)),
(53, paint(&Color::gray(1.0))),
(53, paint(&Color::gray(1.0), None)),
(56, V::Bool(true)),
(57, V::Bool(false)),
(63, real(1.0)),
+1 -1
View File
@@ -98,7 +98,7 @@ pub(crate) use ai::{
BLEND_BUDGET, BLEND_PLUGIN, BRUSH_MANAGER, BrushesRead, DEFORM_PLUGIN, EnvelopeGridPoint, MAX_BLEND_KEYS, MAX_BLEND_OBJECTS,
MAX_CHECKED as ENVELOPE_CHECKS, MAX_EDITING_OBJECTS, MAX_GRADIENT_STOPS, MAX_LISTED, MAX_LISTED_NAME, MAX_MESH_SIDE, MAX_SYMBOLS, ParsedStyle,
blend_reads, brush_plugin_name, brushes_kept, envelope_outline, envelope_upright, mesh_reads, parse_art_style, parsed_moves_with,
read_brush_object, read_parsed_style, read_style_list, symbol_art_member, turn_brush_art_over, warp_number,
parsed_type_color, read_brush_object, read_parsed_style, read_style_list, symbol_art_member, turn_brush_art_over, warp_number,
};
pub(crate) use ate::{MAX_BYTES as MAX_TEXT_DOCUMENT, MAX_FRAMES, MAX_SEGMENTS, MAX_STORY, MAX_VALUES as MAX_TEXT_VALUES, record_version};
pub use native::{AiLayers, ai_alone, ai_alone_on_page, ai_alone_with, ai_layers_alone, ai_opened_artboard, is_loss, layered_ai, layered_ai_from};
+2 -2
View File
@@ -60,8 +60,8 @@ pub use read::read;
#[cfg(test)]
pub(crate) use read::with_image_limits;
pub(crate) use read::{
BLEND_BUDGET, MAX_NODES as MAX_EDITING_OBJECTS, MAX_SYMBOLS, ParsedStyle, join_and, parse_art_style, parsed_moves_with, read_over_page,
read_parsed_style, read_program, read_style_list, slot_frame, slot_of, symbol_art_member,
BLEND_BUDGET, MAX_NODES as MAX_EDITING_OBJECTS, MAX_SYMBOLS, ParsedStyle, join_and, parse_art_style, parsed_moves_with, parsed_type_color,
read_over_page, read_parsed_style, read_program, read_style_list, slot_frame, slot_of, symbol_art_member,
};
pub use read::{
BindingRef, Brushes, PaletteSwatches, PlacedPage, Structure, Symbols, active_artboard, artboards, bindings_note, brushes, graphic_styles,
+1 -1
View File
@@ -155,7 +155,7 @@ pub use document::{
};
pub(crate) use document::{slot_frame, slot_of};
use graph::Graph;
pub(crate) use ops::{ParsedStyle, parse_art_style, parsed_moves_with, read_parsed_style, read_style_list};
pub(crate) use ops::{ParsedStyle, parse_art_style, parsed_moves_with, parsed_type_color, read_parsed_style, read_style_list};
#[cfg(test)]
pub(crate) use raster::with_image_limits;
pub(crate) use types::BLEND_BUDGET;
+8
View File
@@ -1763,6 +1763,14 @@ pub(crate) fn parse_art_style(section: &[u8], name: &str) -> Option<ParsedStyle>
crate::import::ai::style::art_styles(section).remove(name).map(|style| ParsedStyle { style })
}
/// The color type takes from art style `parsed` when a character's fill or stroke names it (key 5
/// of its paint, `ate`): a style of one paint whose paint is a color with a swatch, at its tint and
/// linked to that swatch ([`crate::import::ai::style::ArtStyle::simple_color`]). `None` for any
/// other style.
pub(crate) fn parsed_type_color(parsed: &ParsedStyle) -> Option<&Paint> {
parsed.style.simple_color.as_ref().map(|(paint, _)| paint)
}
/// Art style `parsed` as the reader reads it ([`StyleRead`]): [`appearance_from_art_style`], with a
/// style's one gradient fill as `own_gradient`, the object's own gradient, as [`styled`] reads it on
/// objects other than type. A stroke that names a brush is read with that brush's name, as [`styled`]
+1
View File
@@ -424,6 +424,7 @@ Stop opacity on translated artboards remains outside this regression coverage.
| Date | Change | Summary |
|---|---|---|
| 2026-11-27 | minor | `.ai` save: type in a spot ink, a global process colour or Registration keeps its swatch link and its tint. Its fill and stroke in the text document name (key 5 of the paint) an art style of one paint, `0 1 Xd`, whose paint is the colour as a path's fill writes it (`x`, `Xx`, `Xk`, `Xs`), the form `.ai` import reads since the change below; key 0 still holds the process values at the tint. Each style is read back before it is written and kept only when the reader gives the same swatch and tint, so such type no longer counts among the attributes of type left out; a link to a process swatch that isn't global still does. Test `ai_editing::tests::type_in_spot_and_global_colors_reads_back_linked_at_its_tint` |
| 2026-11-27 | minor | `.ai` and EPS import: type set in a spot ink or a global process colour keeps its ink. In the text document a character's fill or stroke is a colour (key 0: grey, RGB or CMYK) and the name of an art style (key 5). In users' files (used locally, never committed) that style is one paint (`/SimpleStyle`), always its fill's, for a stroke too; for a spot ink or a global process colour it is `c m y k (name) tint x`, `Xx` or `Xk`, and key 0 keeps only the ink's process values at that tint. Such type came in as that process colour, so it separated onto the process plates, and white type in a white ink onto none. It now takes the style's paint: the colour at its tint, linked to the document's swatch of that name, which the style's colour makes when the art doesn't (after the art's colours, before the header's custom colours). A style whose paint is a process colour or a gradient, one that also sets a stroke's colour or pattern (before or after the fill's) or another fill paint after it, one whose `Xd` doesn't turn on its fill alone, and a paint that names no style of the file, keep the colour of key 0 as before; type filled with a gradient still comes in black. Tests `type_set_in_a_spot_ink_takes_it_from_the_art_style_its_paint_names` in `crates/eps/src/import/tests_native.rs`, `a_run_painted_by_a_swatch_colours_art_style_takes_the_swatch` in `crates/eps/src/import/ate.rs` and `only_a_style_of_one_swatch_colour_holds_it_for_type` in `crates/eps/src/import/ai/style/tests.rs`. Scores and estimates unchanged. |
| 2026-11-26 | minor | `.ai` and EPS import: where the text document makes the type of every text object that shows, point type made from it is matched with the page's type where it draws. Made type has no layout when it is matched, and its box was the estimate of type without one (0.55 em a character, running right from its anchor): beside right-aligned type, over half of centered type, across vertical type, and too short for a wide font. The page's type there was counted as type with no text object, with the note "some of the page's type has no text object in the layers, so it is left out" (a loss, so `convert` wouldn't write over the file), and the made type went on to be weighed against the page as type the page may not draw, and could be taken out. The box of made point type that shows now comes from its layout in the fonts the import has; the text object keeps no layout, so the document measures it when it opens, as before. Files where some text object's type isn't made keep the estimate: there the page's pieces where made type draws can belong to text objects stacked on it. The page comparison takes the same box for the layers' type areas (`type_areas` in `compare.rs`): made point type that differs from the page (laid out again, or in another font) counts as type where it draws, whatever its alignment. Counted as art beside the estimate, it could send the file to its PDF part or page, or be noted as art that differs. A file whose layers failed the comparison that way and opened without it now passes it and shows its notes. Tests `right_aligned_and_centered_point_type_takes_the_pages_type_where_it_draws`, `centered_point_type_at_a_heading_s_size_takes_the_pages_type_where_it_draws` and `right_aligned_point_type_that_differs_from_the_page_differs_as_type` in `crates/eps/src/import/tests_native.rs`, and `made_point_type_s_box_is_where_its_alignment_and_orientation_draw_it` in `crates/eps/src/import/native/slots.rs`. Scores and estimates unchanged. |
| 2026-11-22 | minor | EPS import: type in a Type 1 or Type 42 font the file carries, whose family isn't available, is drawn in a TrueType font built from the glyphs the file shows (outlines and advances from the font program), kept with the document as PDF import keeps a PDF's (#4569), and spaced by those glyphs' own advances; once its text is edited it takes the fallback font. A string that draws a character with another glyph than the one kept for it comes in as outlines. The warning names those families with PDF import's words ("show as the file draws them, in the fonts it carries, until their text is edited"). Fonts the file only names, Type 3 fonts and type from an Illustrator editing copy are unchanged. Tests `embedded_type1_type_draws_with_the_files_glyphs`, `a_second_glyph_for_a_character_keeps_its_type_as_outlines`, `kept_type1_glyphs_survive_saving_and_go_when_the_text_is_edited`, `type_in_fonts_that_arent_available_is_named_in_a_warning` in `crates/eps/src/import/tests_type1.rs`, `type_in_a_carried_type42_font_draws_with_the_files_glyphs` in `crates/eps/src/import/tests_type42.rs`; scores unchanged |