Compare commits

...
Author SHA1 Message Date
bflatastic 3a88ad0855 Fix #1529: Linux reads the font folders fontconfig is set up with
The font scan read /usr/share/fonts, /usr/local/share/fonts, ~/.fonts and the
XDG data folders. Packages add folders outside those to fontconfig's
configuration (TeX Gyre under /usr/share/texmf/fonts), so fc-list and other
apps showed fonts VectorCraft didn't have. The scan now also reads the <dir>
folders of /etc/fonts/fonts.conf and the files it includes (conf.d, the user's
own), as the fontconfig documentation describes them. The files are read as
they are: no library is linked and no program is run.
2026-10-13 06:56:37 +07:00
bflatastic 61cc3f6040 Fix #1512: the Smooth tool smooths the stretch of path under the drag
A drag near an anchor refitted the whole segments on either side of it, so a
short drag over a small bump on a long side turned the side into a curve from
end to end. The segments leading into the anchors under the drag are now split
where they enter the tool's reach, and only what is in reach is refitted.
2026-10-13 06:56:37 +07:00
bflatastic a072e29016 Fix #1512: a round corner next to a curved side no longer sticks out of the corner
Live Corners cut a corner between a curve and another side with the handles of
the arc between straight sides. The curve has turned by the time the cut meets
it, so those handles reached past where the tangents at the cut's ends cross,
and from a middling radius on the cut bulged out of the shape or looped. Each
handle is now the share an arc takes of its tangent up to that crossing.
Corners between straight sides are cut as before.
2026-10-13 06:56:37 +07:00
Gert Pellin 3239e8b97e SVG import: <textPath> follows basic shapes (circle, ellipse, rect, line, polyline, polygon)
A <textPath href="#id"> pointing at a basic shape imported as point type
with "textPath has no usable path", as only <path> was followed. SVG 2
allows any basic shape, and Inkscape writes one whenever text is put on
a circle. The shape now becomes its equivalent path as SVG 2 defines
it: circles and ellipses start at 3 o'clock and rounded rects after the
top-left corner, all clockwise; lines, polylines and polygons follow
their points. The shape's transform applies as for a <path>. Shapes
that render nothing (zero radius or size) still fall back to point
type with the warning.

Fixes #1527
2026-10-13 06:56:37 +07:00
EricKuckandClaude Opus 5.5 48d5bd1aee AI import: gradient stops listed upwards aren't reversed, so a midpoint stays on the stop that starts its part of the ramp
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-13 06:56:37 +07:00
bflatastic 5203f4f047 PDF import: the type of a .ai page moved right keeps the stroke drawn on its glyphs
The ink boxes of the page's lines of type move with its art, and art at a
coordinate that isn't a number moves nothing.
2026-10-13 06:56:37 +07:00
fortesnow ba68fcfbfc .ai import: a page's art past its artboard no longer lies over the page before it
A PDF-compatible .ai keeps its art past the artboard edge unclipped (#646),
and its pages are laid out in a row 36 pt apart. Art that a page draws far
to the left of its artboard (notes beside a design, say) then lay over the
page before it. There it was taken for that page's art: the check against
the editing data found art its layers don't have and opened the file as
its PDF part, without the art outside its artboards, and place_pages left
that art behind when it moved the pages.

Such a page now moves right until its art clears the art before it.
Plain PDFs (clipped to the page) keep the 36 pt gap.
2026-10-13 06:56:37 +07:00
15 changed files with 639 additions and 19 deletions

No files matched your search

+54 -6
View File
@@ -3,7 +3,7 @@
use std::sync::Arc;
use kurbo::{ParamCurve, ParamCurveNearest};
use kurbo::{CubicBez, ParamCurve, ParamCurveNearest};
use serde_json::{Value, json};
use vectorcraft_color::{Color, Paint};
use vectorcraft_doc::{Appearance, Document, Node, NodeId, NodeKind, PressureProfile, Selection};
@@ -1048,17 +1048,46 @@ fn smooth_subpath(sp: &SubPath, near: &dyn Fn(Point) -> bool, tol: f64) -> Optio
open.anchors.push(open.anchors[0]);
m.push(false);
open.closed = false;
let mut res = smooth_open(&open.anchors, &m, tol);
let mut res = smooth_open(&open.anchors, &m, near, tol);
let l = res.pop()?;
if let Some(r0) = res.first_mut() {
r0.h_in = l.h_in;
}
return Some(SubPath::new(res, true));
}
Some(SubPath::new(smooth_open(&sp.anchors, &marked, tol), false))
Some(SubPath::new(smooth_open(&sp.anchors, &marked, near, tol), false))
}
fn smooth_open(anchors: &[Anchor], marked: &[bool], tol: f64) -> Vec<Anchor> {
/// The segment `c`, which ends in the drag's reach (`near`) and starts outside it, split where it
/// enters the reach: the part outside, then the part in reach. `None` when no more than a sliver
/// is outside.
fn split_at_reach(c: CubicBez, near: &dyn Fn(Point) -> bool) -> Option<(CubicBez, CubicBez)> {
const STEPS: u32 = 32;
let step = 1.0 / f64::from(STEPS);
// Back from the end in reach to the first sample outside, then halving to the crossing.
let outside = (1..=STEPS).map(|i| 1.0 - f64::from(i) * step).find(|t| !near(c.eval(*t)))?;
let (mut lo, mut hi) = (outside, outside + step);
for _ in 0..20 {
let mid = (lo + hi) / 2.0;
if near(c.eval(mid)) {
hi = mid;
} else {
lo = mid;
}
}
// A straight segment's parts stay straight, their handles on their ends.
let straight = c.p1 == c.p0 && c.p2 == c.p3;
let part = |range| {
let s = c.subsegment(range);
if straight { CubicBez::new(s.p0, s.p0, s.p3, s.p3) } else { s }
};
(hi > 0.02).then(|| (part(0.0..hi), part(hi..1.0)))
}
/// `anchors` with each run of `marked` ones refitted, together with the stretch of the segments
/// leading into the run that is in the drag's reach (`near`): a short drag smooths what is under
/// it, and the rest of a long segment next to it stays as it was (#1512).
fn smooth_open(anchors: &[Anchor], marked: &[bool], near: &dyn Fn(Point) -> bool, tol: f64) -> Vec<Anchor> {
let n = anchors.len();
let mut runs = vec![];
let mut i = 0;
@@ -1079,8 +1108,27 @@ fn smooth_open(anchors: &[Anchor], marked: &[bool], tol: f64) -> Vec<Anchor> {
if hi - lo < 2 {
continue;
}
let new = refit_run(&out[lo..=hi], tol);
out.splice(lo..=hi, new);
let mut piece = out[lo..=hi].to_vec();
// The anchors outside the reach, kept with the part of their segment that is outside.
let (mut head, mut tail) = (None, None);
if hi > b
&& let [.., inner, outer] = piece.as_mut_slice()
&& let Some((far, reach)) = split_at_reach(CubicBez::new(outer.p, outer.h_in, inner.h_out, inner.p), near)
{
inner.h_out = reach.p2;
tail = Some(Anchor { h_in: far.p1, ..*outer });
*outer = Anchor::with_handles(far.p3, reach.p1, far.p2);
}
if lo < a
&& let [outer, inner, ..] = piece.as_mut_slice()
&& let Some((far, reach)) = split_at_reach(CubicBez::new(outer.p, outer.h_out, inner.h_in, inner.p), near)
{
inner.h_in = reach.p2;
head = Some(Anchor { h_out: far.p1, ..*outer });
*outer = Anchor::with_handles(far.p3, far.p2, reach.p1);
}
let new = refit_run(&piece, tol);
out.splice(lo..=hi, head.into_iter().chain(new).chain(tail));
}
out
}
+23
View File
@@ -412,6 +412,29 @@ fn smooth_tool_reduces_jagged_path() {
assert_eq!(p.subpaths[0].anchors[0].p, Point::new(100.0, 200.0));
}
/// #1512: a short drag over a small bump smooths the stretch of path under it. The long straight
/// sides next to the bump stay straight lines from their far ends, which keep their place.
#[test]
fn a_short_smooth_drag_leaves_the_rest_of_long_segments_alone() {
let mut s = session();
let anchors: Vec<_> =
[(50.0, 200.0), (190.0, 200.0), (200.0, 192.0), (210.0, 200.0), (350.0, 200.0)].map(|(x, y)| json!({"x": x, "y": y})).to_vec();
let r = s.execute("path.create", &json!({"anchors": anchors})).unwrap();
let id = NodeId(r["id"].as_u64().unwrap());
let before = path(&s, id);
drag(&mut s, "smooth", &[(195.0, 194.0), (205.0, 194.0)], Mods::default());
let p = path(&s, id);
assert_ne!(p, before, "the bump is smoothed");
let a = &p.subpaths[0].anchors;
let (first, second, last) = (a[0], a[1], a[a.len() - 1]);
assert!(first.p == Point::new(50.0, 200.0) && !first.has_out() && !second.has_in(), "the left side is a line still: {first:?} {second:?}");
assert!(last.p == Point::new(350.0, 200.0) && !last.has_in() && !a[a.len() - 2].has_out(), "and the right one: {last:?}");
// Every other anchor is within the tool's reach of the drag (12 px either way).
for x in &a[1..a.len() - 1] {
assert!((182.0..=218.0).contains(&x.p.x) && (190.0..=201.0).contains(&x.p.y), "{x:?}");
}
}
#[test]
fn join_tool_joins_two_lines() {
let mut s = session();
+5 -2
View File
@@ -158,8 +158,11 @@ impl GradientDef {
if self.gradient.stops.is_empty() {
return None;
}
// Stops come last first: reversed, stops sharing a ramp point keep their order.
self.gradient.stops.reverse();
// Stops are listed along the ramp from either end: listed downwards they're reversed, so
// stops sharing a ramp point keep their order (and each its midpoint, to the next stop).
if self.gradient.stops.first().zip(self.gradient.stops.last()).is_some_and(|(first, last)| first.offset > last.offset) {
self.gradient.stops.reverse();
}
self.gradient.stops.sort_by(|a, b| a.offset.total_cmp(&b.offset));
Some((self.name, self.gradient))
}
+13
View File
@@ -410,6 +410,19 @@ fn stops_sharing_a_ramp_point_keep_their_order() {
assert_eq!(colors, [Color::rgb(0.0, 0.0, 1.0), Color::rgb(0.0, 1.0, 0.0), Color::rgb(1.0, 0.0, 0.0)]);
}
#[test]
fn stops_listed_upwards_keep_the_midpoint_of_the_one_that_starts_the_ramp() {
// GUARDS: reversing a list that runs upwards swaps two stops at 0, and the ramp to 100 takes the
// midpoint of the zero-length part between them.
let defs = "%AI5_BeginGradient: (U)\n(U) 0 3 Bd\n[\n<00FF>\n0\n%_0 0 0 0 1 1 1 2 1 6 50 0 Bs\n\
%_0 0 0 0 1 1 1 2 1 6 87 0 Bs\n%_0 0 0 0 0 0 0 2 1 6 50 100 Bs\nBD\n%AI5_EndGradient\n";
let art_ = format!("{}Bb\n1 (U) 0 0 0 1 1 0 0 1 0 0 1 Bg\n10 0 0 10 100 50 Xm\nf\n0 BB\n", rect_path(0.0, 0.0, 200.0, 100.0));
let doc = read_ok(&format!("{defs}{}", layer(&art_))).doc;
let Paint::Gradient(g) = fill(&art(&doc)[0]) else { panic!() };
let midpoints: Vec<_> = g.gradient.stops.iter().map(|s| s.midpoint).collect();
assert_eq!(midpoints, [0.5, 0.87, 0.5]);
}
#[test]
fn per_anchor_data_reads() {
let art_ = format!("{RED}{}f\n(00800080) Xt 0 XD\n%_(00004000) Xt 1 XD\n", rect_path(0.0, 0.0, 10.0, 10.0));
+53 -2
View File
@@ -155,8 +155,8 @@ impl Corner {
let (h_out, h_in) = match kind {
// An arc tangent to both sides, turning by 180° less the angle between them there.
CornerKind::Round => {
let h = radius * arc_handle(-cos);
(start - du * h, end - dv * h)
let (hu, hv) = self.round_handles(radius, (start, du), (end, dv));
(start - du * hu, end - dv * hv)
}
// An arc centred on the corner through both ends, spanning the angle.
CornerKind::InvertedRound => {
@@ -169,6 +169,33 @@ impl Corner {
}
}
impl Corner {
/// The handle lengths of a round cut of `radius` between `start` and `end` (each a point and
/// the direction its side runs on in there). Between straight sides they are the arc's. A
/// curved side has turned by the time the cut meets it, so the arc's handles would reach past
/// where the tangents at the cut's ends cross and the cut would stick out of the corner
/// (#1512): there each handle is the share an arc takes of its tangent, up to that crossing
/// (a third of the way to the other end where the tangents don't cross between them).
fn round_handles(&self, radius: f64, (start, du): (Point, Vec2), (end, dv): (Point, Vec2)) -> (f64, f64) {
let cos = du.dot(dv);
let arc = arc_handle(-cos);
if self.side_u.straight() && self.side_v.straight() {
return (radius * arc, radius * arc);
}
// start − du·a = end − dv·b is where the tangents cross.
let (cross, w) = (du.cross(dv), start - end);
let (a, b) = (w.cross(dv) / cross, w.cross(du) / cross);
if cross.abs() > MIN_SINE && a > EPS && b > EPS && a.is_finite() && b.is_finite() {
// An arc's handle over its tangent's length, radius · tan(turn / 2).
let share = arc * (1.0 - cos) / cross.abs();
(a * share, b * share)
} else {
let third = start.distance(end) / 3.0;
(third, third)
}
}
}
/// A corner cut: the parameters where it meets its sides (from the corner), its two new anchors
/// and the handles between them.
#[derive(Clone, Copy, Debug)]
@@ -401,6 +428,30 @@ mod tests {
}
}
/// A round cut next to a curve stays inside its corner, however large (#1512): its handles
/// stop short of where the tangents at its ends cross, so it doesn't stick out past the sides.
#[test]
fn a_round_cut_next_to_a_curve_stays_inside_its_corner() {
// A square whose top side arches up, meeting the upright sides at an angle.
let mut sp =
SubPath::polyline(&[Point::new(100.0, 150.0), Point::new(300.0, 150.0), Point::new(300.0, 300.0), Point::new(100.0, 300.0)], true);
sp.anchors[0].h_out = Point::new(120.0, 20.0);
sp.anchors[1].h_in = Point::new(280.0, 20.0);
let path = PathData::single(sp);
let bounds = path.bounds().unwrap().inflate(1e-6, 1e-6);
for radius in [10.0, 60.0, 200.0, 1e6] {
let (cut, _) = cut_corners(&path, &[radius, radius], &[]);
let b = cut.bounds().unwrap();
assert!(bounds.union(b) == bounds, "radius {radius}: {b:?} is outside {bounds:?}");
// Each cut's handles end before its tangents cross: the cut turns one way only.
let a = &cut.subpaths[0].anchors;
for (from, to) in [(a[a.len() - 1], a[0]), (a[1], a[2])] {
let (t0, t1, chord) = (from.h_out - from.p, to.p - to.h_in, to.p - from.p);
assert!(t0.cross(chord) * chord.cross(t1) > 0.0 && t0.cross(t1) * t0.cross(chord) > 0.0, "radius {radius}: {from:?} {to:?}");
}
}
}
/// Inverted round and chamfer cuts end where the round one does, at any angle.
#[test]
fn kinds_share_their_ends() {
+32
View File
@@ -197,6 +197,8 @@ pub fn import_with_report(bytes: &[u8], opts: &ImportOptions) -> Result<ImportRe
b.colors.uncalibrated_rgb = opts.uncalibrated_rgb && picked.iter().filter_map(|&n| pages.get(n)).any(crate::pages::has_private_data);
let cache = InterpreterCache::new();
let mut x = 0.0;
// Where the next page's art may begin (a `.ai` page's art reaches past its artboard).
let mut clear = f64::NEG_INFINITY;
// Every page only text over private data: a file saved without its PDF part shows a notice
// there, not its art. A page that states where its art is isn't that notice.
let (mut only_text, mut art_boxes) = (true, false);
@@ -220,6 +222,8 @@ pub fn import_with_report(bytes: &[u8], opts: &ImportOptions) -> Result<ImportRe
let xf = Affine::translate((x - frame.x0, -frame.y0)) * init;
let mut ctx = Context::new(xf, ab, &cache, pdf.xref(), settings.clone());
b.page = ab;
// The first id of this page's art.
let first_id = b.next;
let scan = scan_page(page, &mut ocgs, all_on, &mut b.fonts);
if route {
let mut seen = HashSet::new();
@@ -267,6 +271,33 @@ pub fn import_with_report(bytes: &[u8], opts: &ImportOptions) -> Result<ImportRe
if clipped {
b.warn(PAST_PAGE_NOTE);
}
// A `.ai` page keeps its art past the artboard edge, unclipped (#646), so a page whose art
// reaches far to the left would lay it over the page before it in the row: there it would
// be taken for that page's art (by the check against the editing data, which then finds
// art its layers don't have there, and by `place_pages`). Such a page moves right until its
// art clears the art before it.
let mut art_right = f64::NEG_INFINITY;
if ai && let Some(art) = parts.iter().flat_map(|(_, v)| v.iter()).filter_map(|n| n.visual_bounds()).reduce(|a, b| a.union(b)) {
// Art at a coordinate that isn't a number (a damaged file) moves nothing.
let dx = Some((clear - art.x0).max(0.0)).filter(|dx| dx.is_finite()).unwrap_or(0.0);
if dx > 0.0 {
let shift = Affine::translate((dx, 0.0));
for (_, v) in &mut parts {
for n in v.iter_mut() {
Arc::make_mut(n).transform(shift, false);
}
}
// What the page's lines of type were is told where their glyphs are (the outlines
// stroked on them are looked for there), so that moves with them.
for facts in b.lines.iter_mut().filter(|(id, _)| id.0 >= first_id).map(|(_, facts)| facts) {
for ink in &mut facts.ink {
*ink = *ink + kurbo::Vec2::new(dx, 0.0);
}
}
ab = Rect::new(ab.x0 + dx, ab.y0, ab.x1 + dx, ab.y1);
}
art_right = art.x1 + dx;
}
let children: Vec<Arc<Node>> = parts.iter().flat_map(|(_, v)| v.iter().cloned()).collect();
only_text &= ai && is_only_text(&children);
art_boxes |= crate::pages::states_art(page);
@@ -278,6 +309,7 @@ pub fn import_with_report(bytes: &[u8], opts: &ImportOptions) -> Result<ImportRe
ab = art;
}
x = right + opts.artboard_gap;
clear = right.max(art_right) + opts.artboard_gap;
doc.artboards.push(Artboard {
id: i as u32 + 1,
name: format!("Artboard {}", i + 1),
+22
View File
@@ -131,6 +131,28 @@ fn a_stroke_written_as_stroked_glyph_outlines_is_the_types_stroke() {
assert_eq!(d.layers[0].children().unwrap().len(), 2);
}
/// A `.ai` page moved right in the row, so its art past the artboard clears the page before it
/// (#1528), still has the stroke drawn on its type's glyphs read as the type's stroke.
#[test]
fn a_stroke_on_the_type_of_a_moved_ai_page_is_still_the_types_stroke() {
let ai = "/PieceInfo << /Illustrator << /Private << /AIPrivateData1 7 /NumBlock 1 >> >> >>";
let content = format!(
"0 g -70 10 80 20 re f BT 1 0 0 rg /F1 24 Tf 10 50 Td (Hi) Tj ET 0 0 1 RG 0.5 w {}{}",
outline('H', 10.0),
outline('i', 10.0 + 0.722 * 24.0)
);
let pages = [("0 g 10 10 20 20 re f", String::new()), (content.as_str(), HELVETICA.to_string())].map(|(c, resources)| PdfPage {
entries: ai.into(),
resources,
..PdfPage::new(100.0, 100.0, c)
});
let d = import(&vectorcraft_testkit::pdf::pdf(&pages, None)).unwrap();
assert!(d.artboards[1].rect.x0 > d.artboards[0].rect.x1 + 36.0 + 1.0, "page 2 moved: {:?}", d.artboards);
let art = d.layers[1].children().unwrap();
assert_eq!(art.len(), 2, "the note and the type: {art:?}");
assert!(matches!(art[1].appearance.items.as_slice(), [AppearanceItem::Stroke(_)]), "{:?}", art[1].appearance);
}
/// A 300 × 200 pt page with `lines` of (x, y from the top, size, text) in Source Sans 3.
fn source_sans(lines: &[(f32, f32, f32, &str)]) -> Vec<u8> {
crate::tests_live_text::text_pdf(lines, false)
+21
View File
@@ -158,6 +158,27 @@ fn art_of_neighbouring_artboards_off_a_page_is_left_to_its_own_page() {
assert_eq!(d.layers[0].children().map_or(0, |c| c.len()), 2);
}
/// A `.ai` keeps its art past the artboard edge (#646): a note mostly left of artboard 2 (as notes
/// for a design are put beside it) doesn't lie over artboard 1 in the row, where it would be taken
/// for that page's art: page 2 moves right until its art clears page 1's.
#[test]
fn art_of_an_ai_page_reaching_left_does_not_lie_over_the_page_before() {
let ai = "/PieceInfo << /Illustrator << /Private << /AIPrivateData1 7 /NumBlock 1 >> >> >>";
let page = |content: &str| PdfPage { entries: ai.into(), ..PdfPage::new(100.0, 100.0, content) };
// Page 2's note runs from 70 points left of its box to 10 points into it.
let pages = [page("0 g 10 10 20 20 re f"), page("1 1 1 rg 1 0 0 RG -70 10 80 60 re B")];
let d = open(&pdf(&pages, None), ImportOptions::default());
let (a, b) = (d.artboards[0].rect, d.artboards[1].rect);
let note = d.layers[1].children().unwrap()[0].visual_bounds().unwrap();
assert!(note.x0 >= a.x1 + 36.0, "the note clears artboard 1: {note:?} {a:?}");
assert!((b.x0 - note.x0 - 70.0).abs() < 1.0, "and keeps its place by artboard 2: {note:?} {b:?}");
assert_eq!((b.width(), b.height()), (100.0, 100.0));
// A plain PDF clips its art to the page: its pages stay 36 points apart.
let plain = [PdfPage::new(100.0, 100.0, "0 g 10 10 20 20 re f"), PdfPage::new(100.0, 100.0, "1 0 0 RG -70 10 80 60 re S")];
let d = open(&pdf(&plain, None), ImportOptions::default());
assert_eq!(d.artboards[1].rect.x0, d.artboards[0].rect.x1 + 36.0);
}
#[test]
fn an_encrypted_pdf_opens_with_its_password_only() {
let bytes = pdf(&[PdfPage::new(200.0, 100.0, "1 0 0 rg 10 10 50 50 re f")], Some("secret"));
+81 -4
View File
@@ -468,10 +468,11 @@ impl Ctx {
None => {
let id = href(tp)?.trim().strip_prefix('#')?;
let el = xml.descendants().find(|n| n.is_element() && n.attribute("id") == Some(id))?;
if el.tag_name().name() != "path" {
return None;
}
let mut bp = BezPath::from_svg(el.attribute("d")?).ok()?;
let d = match el.tag_name().name() {
"path" => el.attribute("d")?.to_string(),
_ => self.shape_path(el)?,
};
let mut bp = BezPath::from_svg(&d).ok()?;
bp.apply_affine(parse_transform(el.attribute("transform")));
bp
}
@@ -483,6 +484,82 @@ impl Ctx {
usable.then_some(bp)
}
/// The equivalent path of a basic shape (SVG 2 › Basic Shapes), as path data: what a
/// `<textPath>` that points at it follows. Circles and ellipses start at 3 o'clock and rounded
/// rects at the end of the top-left corner, all running clockwise; lines and polylines follow
/// their points. `None` for other elements and for shapes that render nothing.
fn shape_path(&self, el: XNode) -> Option<String> {
let (vw, vh) = self.viewport;
let len = |a: &str, pct: f64| el.attribute(a).and_then(|v| self.length(v, DEFAULT_FONT_SIZE, pct));
let x = |a: &str| len(a, vw).unwrap_or(0.0);
let y = |a: &str| len(a, vh).unwrap_or(0.0);
let points = || -> Vec<f64> { el.attribute("points").map(|v| list(v).map_while(|t| t.parse().ok()).collect()).unwrap_or_default() };
let ellipse = |cx: f64, cy: f64, rx: f64, ry: f64| {
(rx > 0.0 && ry > 0.0).then(|| {
format!(
"M{} {} A{rx} {ry} 0 0 1 {cx} {} A{rx} {ry} 0 0 1 {} {cy} A{rx} {ry} 0 0 1 {cx} {} A{rx} {ry} 0 0 1 {} {cy}Z",
cx + rx,
cy,
cy + ry,
cx - rx,
cy - ry,
cx + rx
)
})
};
match el.tag_name().name() {
"circle" => {
let r = len("r", ((vw * vw + vh * vh) / 2.0).sqrt())?;
ellipse(x("cx"), y("cy"), r, r)
}
"ellipse" => {
let (rx, ry) = (len("rx", vw), len("ry", vh));
let (rx, ry) = (rx.or(ry)?, ry.or(rx)?);
ellipse(x("cx"), y("cy"), rx, ry)
}
"rect" => {
let (x0, y0, w, h) = (x("x"), y("y"), len("width", vw)?, len("height", vh)?);
if w <= 0.0 || h <= 0.0 {
return None;
}
let (rx, ry) = (len("rx", vw).filter(|v| *v > 0.0), len("ry", vh).filter(|v| *v > 0.0));
let (rx, ry) = (rx.or(ry).unwrap_or(0.0).min(w / 2.0), ry.or(rx).unwrap_or(0.0).min(h / 2.0));
if rx <= 0.0 || ry <= 0.0 {
return Some(format!("M{x0} {y0} H{} V{} H{x0}Z", x0 + w, y0 + h));
}
let (x1, y1) = (x0 + w, y0 + h);
Some(format!(
"M{} {y0} H{} A{rx} {ry} 0 0 1 {x1} {} V{} A{rx} {ry} 0 0 1 {} {y1} H{} A{rx} {ry} 0 0 1 {x0} {} V{} A{rx} {ry} 0 0 1 {} {y0}Z",
x0 + rx,
x1 - rx,
y0 + ry,
y1 - ry,
x1 - rx,
x0 + rx,
y1 - ry,
y0 + ry,
x0 + rx
))
}
"line" => Some(format!("M{} {} L{} {}", x("x1"), y("y1"), x("x2"), y("y2"))),
tag @ ("polyline" | "polygon") => {
let pts = points();
let mut d = String::new();
for (i, [x, y]) in pts.as_chunks::<2>().0.iter().enumerate() {
let _ = write!(d, "{}{x} {y} ", if i == 0 { 'M' } else { 'L' });
}
if d.is_empty() {
return None;
}
if tag == "polygon" {
d.push('Z');
}
Some(d)
}
_ => None,
}
}
/// Read one `<text>`: the pending text and its `url(#…)` paints.
fn build(&self, xml: &roxmltree::Document, t: XNode, label: &str, warnings: &mut Vec<String>) -> Option<(PendingText, Vec<String>)> {
let preserve = t.ancestors().filter(|a| a.is_element()).find_map(|a| a.attribute((roxmltree::NS_XML_URI, "space"))) == Some("preserve");
+65
View File
@@ -518,3 +518,68 @@ fn gradients_on_scaled_text_stay_in_place() {
let (start, end) = (t.xf * geom.start, t.xf * geom.end);
assert!(start.distance(Point::new(40.0, 0.0)) < 1e-6 && end.distance(Point::new(240.0, 0.0)) < 1e-6, "{start:?} {end:?}");
}
/// The start of a type-on-a-path object's path and a point a little way along it, in document
/// space.
fn path_start(t: &TextObject) -> (Point, Point) {
use vectorcraft_geom::kurbo::{ParamCurve, PathEl};
let TextKind::OnPath { path, .. } = &t.kind else { panic!("{:?}", t.kind) };
let mut bp = path.to_bezpath();
bp.apply_affine(t.xf);
let PathEl::MoveTo(p0) = bp.elements()[0] else { panic!("{bp:?}") };
let next = bp.segments().next().unwrap().eval(0.05);
(p0, next)
}
#[test]
fn text_path_follows_basic_shapes_as_their_equivalent_paths() {
let (d, w) = import_with_report(&svg(r##"<circle id="c" cx="150" cy="150" r="100"/>
<ellipse id="e" cx="150" cy="150" rx="80" ry="40" transform="translate(10 0)"/>
<rect id="r" x="20" y="30" width="100" height="60" rx="10"/>
<rect id="s" x="20" y="30" width="100" height="60"/>
<line id="l" x1="10" y1="200" x2="210" y2="200"/>
<polyline id="pl" points="10,10 110,10 110,60"/>
<polygon id="pg" points="10 10, 60 10, 35 50"/>
<text font-size="10"><textPath xlink:href="#c">TEXT ON A CIRCLE</textPath></text>
<text font-size="10"><textPath href="#e">Ellipse</textPath></text>
<text font-size="10"><textPath href="#r">Rounded</textPath></text>
<text font-size="10"><textPath href="#s">Square</textPath></text>
<text font-size="10"><textPath href="#l">Line</textPath></text>
<text font-size="10"><textPath href="#pl">Polyline</textPath></text>
<text font-size="10"><textPath href="#pg">Polygon</textPath></text>"##))
.unwrap();
assert!(!w.iter().any(|w| w.contains("textPath")), "{w:?}");
let t = texts(&d);
assert_eq!(t.len(), 7);
assert!(t.iter().all(|t| matches!(t.kind, TextKind::OnPath { .. })), "{:?}", t.iter().map(|t| &t.kind).collect::<Vec<_>>());
let near = |a: Point, b: Point| (a - b).hypot() < 1e-6;
// Circle: starts at 3 o'clock and runs clockwise (down first, y pointing down), around the circle.
let (p0, next) = path_start(t[0]);
assert!(near(p0, Point::new(250.0, 150.0)) && next.y > p0.y && next.x < p0.x, "{p0:?} {next:?}");
let TextKind::OnPath { path, .. } = &t[0].kind else { panic!("not on a path") };
let b = t[0].xf.transform_rect_bbox(path.bounds().unwrap());
assert!(close(b.x0, 50.0, 1e-6) && close(b.y0, 50.0, 1e-6) && close(b.x1, 250.0, 1e-6) && close(b.y1, 250.0, 1e-6), "{b:?}");
assert!(path.is_closed());
// Ellipse, with the shape's own transform.
let (p0, next) = path_start(t[1]);
assert!(near(p0, Point::new(240.0, 150.0)) && next.y > p0.y, "{p0:?} {next:?}");
// Rounded rect: after the top-left corner, along the top edge to the right.
let (p0, next) = path_start(t[2]);
assert!(near(p0, Point::new(30.0, 30.0)) && next.x > p0.x && close(next.y, 30.0, 1e-9), "{p0:?} {next:?}");
let (p0, next) = path_start(t[3]);
assert!(near(p0, Point::new(20.0, 30.0)) && next.x > p0.x, "{p0:?} {next:?}");
// Line, polyline and polygon follow their points.
assert!(near(path_start(t[4]).0, Point::new(10.0, 200.0)));
assert!(near(path_start(t[5]).0, Point::new(10.0, 10.0)));
let TextKind::OnPath { path, .. } = &t[6].kind else { panic!("not on a path") };
assert!(path.is_closed() && near(path_start(t[6]).0, Point::new(10.0, 10.0)));
assert_eq!(t[0].plain_text(), "TEXT ON A CIRCLE");
}
#[test]
fn text_path_to_an_empty_shape_still_falls_back_to_point_type() {
let (d, w) =
import_with_report(&svg(r##"<circle id="c" cx="5" cy="5" r="0"/><text x="5" y="10"><textPath href="#c">Zero</textPath></text>"##)).unwrap();
assert!(matches!(only_text(&d).kind, TextKind::Point));
assert!(w.iter().any(|w| w.contains("textPath")), "{w:?}");
}
+253
View File
@@ -0,0 +1,253 @@
//! The font folders fontconfig is set up with (Linux and the other Unix desktops): the `<dir>`
//! entries of its configuration, `/etc/fonts/fonts.conf` and what that includes (`conf.d`, the
//! user's own files). Distributions and packages add folders outside the usual ones there: TeX
//! fonts under `/usr/share/texmf/fonts`, say, which `fc-list` and other apps then show (#1529).
//!
//! The format is fontconfig's documented one
//! (<https://www.freedesktop.org/software/fontconfig/fontconfig-user.html>, "Configuration file
//! format"): `<dir prefix="…">` and `<include prefix="…">` are all that is read here. The files are
//! read as they are: fontconfig itself (a library, or `fc-list`) isn't asked.
use std::collections::HashSet;
use std::path::{Path, PathBuf};
/// The most configuration files read, and the largest one (they are a few kilobytes each).
const MAX_FILES: usize = 512;
const MAX_FILE_BYTES: u64 = 1 << 20;
/// The most folders taken, and how deep files may include files.
const MAX_DIRS: usize = 256;
const MAX_DEPTH: usize = 8;
/// A `<dir>` (a font folder) or an `<include>` (another configuration file, or a folder of them)
/// with its `prefix` attribute and its text.
#[derive(Debug, PartialEq)]
struct Entry {
include: bool,
prefix: String,
path: String,
}
/// The `<dir>` and `<include>` elements of a configuration file, in order. Anything that isn't
/// one of them, comments included, is skipped; a file that isn't well formed gives what was read
/// before the damage.
fn entries(xml: &str) -> Vec<Entry> {
let mut out = vec![];
let mut rest = xml;
while let Some(at) = rest.find('<') {
rest = rest.get(at + 1..).unwrap_or_default();
if let Some(comment) = rest.strip_prefix("!--") {
rest = comment.split_once("-->").map_or("", |(_, after)| after);
continue;
}
let Some((tag, after)) = rest.split_once('>') else { break };
let name = tag.split_whitespace().next().unwrap_or_default();
if !matches!(name, "dir" | "include") || tag.ends_with('/') {
continue;
}
let Some((text, after)) = after.split_once("</") else { break };
rest = after;
// No element is inside these: text with a tag in it isn't a path.
if text.contains('<') {
continue;
}
let path = text.trim().replace("&amp;", "&").replace("&lt;", "<").replace("&gt;", ">").replace("&quot;", "\"").replace("&apos;", "'");
if !path.is_empty() {
out.push(Entry { include: name == "include", prefix: attribute(tag, "prefix").unwrap_or_default().to_string(), path });
}
}
out
}
/// The value of attribute `name` in a start tag's text.
fn attribute<'a>(tag: &'a str, name: &str) -> Option<&'a str> {
let mut rest = tag;
while let Some(at) = rest.find(name) {
let before_ok = rest.get(..at).is_some_and(|b| b.ends_with(char::is_whitespace));
rest = rest.get(at + name.len()..)?;
let Some(value) = rest.trim_start().strip_prefix('=') else { continue };
let value = value.trim_start();
let quote = value.chars().next().filter(|q| matches!(q, '"' | '\''))?;
let (value, _) = value.get(1..)?.split_once(quote)?;
if before_ok {
return Some(value);
}
}
None
}
/// Where the user's files are: the home folder and the XDG data and configuration folders.
#[derive(Clone, Debug, Default)]
pub(crate) struct Places {
pub home: Option<PathBuf>,
pub data_home: Option<PathBuf>,
pub config_home: Option<PathBuf>,
}
impl Places {
/// The path an entry of the file `from` names: `~` is the home folder, `prefix="xdg"` the XDG
/// data folder (a `<dir>`) or configuration folder (an `<include>`), `prefix="relative"` the
/// file's own folder, as is an `<include>` that isn't a full path. A `<dir>` relative to the
/// folder the app was started in is none.
fn resolve(&self, e: &Entry, from: &Path) -> Option<PathBuf> {
// `~` alone or before a `/`: another user's home (`~name`) isn't looked up.
if let Some(rest) = e.path.strip_prefix('~').filter(|rest| rest.is_empty() || rest.starts_with('/')) {
return Some(self.home.as_ref()?.join(rest.trim_start_matches('/')));
}
let path = Path::new(&e.path);
let base = match e.prefix.as_str() {
"xdg" if e.include => self.config_home.as_deref(),
"xdg" => self.data_home.as_deref(),
_ if path.is_absolute() => return Some(path.to_path_buf()),
"relative" => from.parent(),
_ if e.include => from.parent(),
_ => None,
};
Some(base?.join(path)).filter(|p| p.is_absolute())
}
}
/// The font folders the configuration file `root` and the files it includes list, in order, each
/// once. Files that are missing or can't be read list none.
pub(crate) fn font_dirs(root: &Path, places: &Places) -> Vec<PathBuf> {
let mut read = Reader { places, files: HashSet::new(), dirs: vec![] };
read.file(root, 0);
read.dirs
}
struct Reader<'a> {
places: &'a Places,
/// The files read so far (a file including itself is read once).
files: HashSet<PathBuf>,
dirs: Vec<PathBuf>,
}
impl Reader<'_> {
fn file(&mut self, path: &Path, depth: usize) {
if depth > MAX_DEPTH || self.files.len() >= MAX_FILES || !self.files.insert(path.to_path_buf()) {
return;
}
// A folder of configuration files: those named as fontconfig reads them (a digit first,
// `.conf` last), in name order.
if let Ok(list) = std::fs::read_dir(path) {
let mut files: Vec<PathBuf> = list
.flatten()
.take(MAX_FILES)
.filter(|e| {
let name = e.file_name();
let name = name.to_string_lossy();
name.starts_with(|c: char| c.is_ascii_digit()) && name.ends_with(".conf")
})
.map(|e| e.path())
.collect();
files.sort();
for f in files {
self.file(&f, depth + 1);
}
return;
}
// A file that is missing, too large or not text lists nothing.
if !std::fs::metadata(path).is_ok_and(|m| m.is_file() && m.len() <= MAX_FILE_BYTES) {
return;
}
let Ok(text) = std::fs::read_to_string(path) else { return };
for e in entries(&text) {
let Some(to) = self.places.resolve(&e, path) else { continue };
if e.include {
self.file(&to, depth + 1);
} else if self.dirs.len() < MAX_DIRS && !self.dirs.contains(&to) {
self.dirs.push(to);
}
}
}
}
/// The configuration file fontconfig starts from: `FONTCONFIG_FILE`, else `fonts.conf` in
/// `FONTCONFIG_PATH`, else `/etc/fonts/fonts.conf`.
pub(crate) fn root() -> PathBuf {
let var = |name| std::env::var_os(name).map(PathBuf::from).filter(|p| p.is_absolute());
var("FONTCONFIG_FILE").or_else(|| var("FONTCONFIG_PATH").map(|d| d.join("fonts.conf"))).unwrap_or_else(|| "/etc/fonts/fonts.conf".into())
}
#[cfg(test)]
mod tests {
use super::*;
fn entry(include: bool, prefix: &str, path: &str) -> Entry {
Entry { include, prefix: prefix.into(), path: path.into() }
}
#[test]
fn dirs_and_includes_are_read_and_the_rest_is_skipped() {
let xml = r#"<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
<description>Default configuration file</description>
<!-- <dir>/commented/out</dir> -->
<dir>/usr/share/fonts</dir>
<dir prefix="xdg">fonts</dir>
<dir prefix = 'relative' salt="x"> more &amp; more </dir>
<dir>~/.fonts</dir>
<dir></dir>
<cachedir>/var/cache/fontconfig</cachedir>
<match target="pattern"><test qual="any" name="family"><string>mono</string></test></match>
<include ignore_missing="yes">conf.d</include>
<include ignore_missing="yes" prefix="xdg">fontconfig/fonts.conf</include>
<dir>/cut/off"#;
assert_eq!(
entries(xml),
[
entry(false, "", "/usr/share/fonts"),
entry(false, "xdg", "fonts"),
entry(false, "relative", "more & more"),
entry(false, "", "~/.fonts"),
entry(true, "", "conf.d"),
entry(true, "xdg", "fontconfig/fonts.conf"),
]
);
// Damaged files and files that aren't XML read as nothing, without a panic.
for junk in
["", "<", "<dir", "<dir>", "<dir><dir></dir>", "</dir>", "<!--", "<dir prefix=>x</dir", "\u{0}<dir prefix=\"", "<dir prefix='é>ü</dir>"]
{
let _ = entries(junk);
}
assert_eq!(attribute("dir notprefix=\"a\" prefix=\"b\"", "prefix"), Some("b"));
}
/// A configuration as distributions lay it out: the main file lists the usual folders and
/// includes `conf.d`, where a package's file adds its own folder (TeX fonts, #1529) and
/// another includes the user's files.
#[test]
fn folders_of_included_files_are_listed_once_in_order() {
let tmp = std::env::temp_dir().join(format!("vc-fontconfig-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&tmp);
let (etc, home) = (tmp.join("etc/fonts"), tmp.join("home"));
let write = |path: PathBuf, body: &str| {
std::fs::create_dir_all(path.parent().unwrap()).unwrap();
std::fs::write(path, format!("<fontconfig>{body}</fontconfig>")).unwrap();
};
let texmf = tmp.join("usr/share/texmf/fonts/opentype");
write(
etc.join("fonts.conf"),
&format!(
"<dir>{}</dir><dir prefix=\"xdg\">fonts</dir><dir>~/.fonts</dir><dir>fonts-of-the-working-folder</dir>\
<include ignore_missing=\"yes\">conf.d</include><include>{}</include><include>fonts.conf</include>",
tmp.join("usr/share/fonts").display(),
etc.join("missing.conf").display()
),
);
write(etc.join("conf.d/09-texlive.conf"), &format!("<dir>{}</dir>", texmf.display()));
write(etc.join("conf.d/50-user.conf"), "<include ignore_missing=\"yes\" prefix=\"xdg\">fontconfig/fonts.conf</include>");
write(etc.join("conf.d/README"), "<dir>/not/a/conf/file</dir>");
write(etc.join("conf.d/user.conf"), "<dir>/no/digit/first</dir>");
write(home.join(".config/fontconfig/fonts.conf"), &format!("<dir prefix=\"relative\">mine</dir><dir>{}</dir>", texmf.display()));
let places = Places { home: Some(home.clone()), data_home: Some(home.join(".local/share")), config_home: Some(home.join(".config")) };
assert_eq!(
font_dirs(&etc.join("fonts.conf"), &places),
[tmp.join("usr/share/fonts"), home.join(".local/share/fonts"), home.join(".fonts"), texmf, home.join(".config/fontconfig/mine")]
);
// Without a home folder, what needs one is left out; a missing file lists nothing.
assert_eq!(font_dirs(&etc.join("fonts.conf"), &Places::default()).len(), 2);
assert!(font_dirs(&tmp.join("none.conf"), &places).is_empty());
let _ = std::fs::remove_dir_all(&tmp);
}
}
+10 -1
View File
@@ -1269,12 +1269,21 @@ pub fn system_font_dirs() -> Vec<PathBuf> {
// list their own data folders), relative paths ignored as the XDG spec says.
let xdg = |var| std::env::var_os(var).map(|v| std::env::split_paths(&v).filter(|p| p.is_absolute()).collect::<Vec<_>>()).unwrap_or_default();
let data_home = xdg("XDG_DATA_HOME").into_iter().next().or_else(|| home.as_ref().map(|h| h.join(".local/share")));
dirs.extend(data_home.into_iter().chain(xdg("XDG_DATA_DIRS")).map(|d| d.join("fonts")));
dirs.extend(data_home.iter().cloned().chain(xdg("XDG_DATA_DIRS")).map(|d| d.join("fonts")));
if let Some(h) = &home {
dirs.push(h.join(".fonts"));
}
// In a Flatpak sandbox, the host's fonts (system, local and the user's).
dirs.extend(["/run/host/fonts", "/run/host/local-fonts", "/run/host/user-fonts"].map(Into::into));
// The folders fontconfig is set up with outside those: packages add their own (TeX fonts
// under `/usr/share/texmf/fonts`, #1529), and `fc-list` and other apps show their fonts.
let config_home = xdg("XDG_CONFIG_HOME").into_iter().next().or_else(|| home.as_ref().map(|h| h.join(".config")));
let places = crate::fontconfig::Places { home: home.clone(), data_home, config_home };
for dir in crate::fontconfig::font_dirs(&crate::fontconfig::root(), &places) {
if !dirs.iter().any(|known| dir.starts_with(known)) {
dirs.push(dir);
}
}
}
dirs.extend(app_font_dir().map(Path::to_path_buf));
#[cfg(not(target_arch = "wasm32"))]
+1
View File
@@ -14,6 +14,7 @@ pub mod craft_fonts;
pub mod edit;
pub mod embed;
mod features;
mod fontconfig;
mod fontdb;
pub mod hyphen;
mod layout;
+3 -2
View File
@@ -1,6 +1,6 @@
# File format parity
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (grayscale TIFFs with an alpha channel or extra channels place and open, #1466 in part; a faded or masked fill keeps its stroke apart on PDF and `.ai` import, #1434; SVG knockout groups without masks, #1435; Affinity import: a text frame too short for its first line is made taller, #1423; `.ai` editing data: a compound path takes its last path's paint and keeps paths grouped inside it, #1410; a `.ai` whose PDF part is only text opens from it, #1387; PDF and `.ai` import keep overprint, #1388; `.ai` editing data: gradients with middle stops, #1390; type of objects with an appearance, hidden layers and later artboards, #1391; area type in a frame too short for the fallback font, #1392; `.ai` editing data: placed (linked) files read, #1264; gradient-filled shapes import as paths, #1304; white constant alpha soft masks, #1286 in part; DXF control-point SPLINE closure read, #1299 follow-up; `.ai` and PDF trim and bleed boxes as artboard and bleed, #1266; `.ai` gradient matrices, meshes and artboard names from the editing data; `.ai` art styles, clipping fills and compound looks from the editing data; `editingData: "always"` opens a `.ai` from its editing data; a `.ai` whose PDF part is only text opens from it, #1387; PDF and `.ai` import keep overprint, #1388; `.ai` editing data: gradients with middle stops, #1390; type of objects with an appearance, hidden layers and later artboards, #1391; area type in a frame too short for the fallback font, #1392; `.ai` editing data: placed (linked) files read, #1264; gradient-filled shapes import as paths, #1304; white constant alpha soft masks, #1286 in part; DXF control-point SPLINE closure read, #1299 follow-up; `.ai` and PDF trim and bleed boxes as artboard and bleed, #1266; `.ai` gradient matrices, meshes and artboard names from the editing data; `.ai` art styles, clipping fills and compound looks from the editing data; a `.ai` whose PDF part is only text opens from it, #1387; PDF and `.ai` import keep overprint, #1388; `.ai` editing data: gradients with middle stops, #1390; type of objects with an appearance, hidden layers and later artboards, #1391; area type in a frame too short for the fallback font, #1392; `.ai` editing data: placed (linked) files read, #1264; gradient-filled shapes import as paths, #1304; white constant alpha soft masks, #1286 in part; DXF control-point SPLINE closure read, #1299 follow-up; `.ai` and PDF trim and bleed boxes as artboard and bleed, #1266; `.ai` gradient matrices, meshes and artboard names from the editing data; a `.ai` whose PDF part is only text opens from it, #1387; PDF and `.ai` import keep overprint, #1388; `.ai` editing data: gradients with middle stops, #1390; type of objects with an appearance, hidden layers and later artboards, #1391; area type in a frame too short for the fallback font, #1392; `.ai` editing data: placed (linked) files read, #1264; gradient-filled shapes import as paths, #1304; white constant alpha soft masks, #1286 in part; DXF control-point SPLINE closure read, #1299 follow-up; `.ai` and PDF trim and bleed boxes as artboard and bleed, #1266; SVG knockout groups of opaque art without masks; a `.ai` whose PDF part is only text opens from it, #1387; PDF and `.ai` import keep overprint, #1388; `.ai` editing data: gradients with middle stops, #1390; type of objects with an appearance, hidden layers and later artboards, #1391; area type in a frame too short for the fallback font, #1392; `.ai` editing data: placed (linked) files read, #1264; gradient-filled shapes import as paths, #1304; white constant alpha soft masks, #1286 in part; DXF control-point SPLINE closure read, #1299 follow-up; `.ai` and PDF trim and bleed boxes as artboard and bleed, #1266; `.ai` keeps its RGB numbers; PDF import keeps a stroke apart from a fill masked or faded by its group) · **Target:** Adobe Illustrator 2026 (30.x)
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (a `.ai` page's art past its artboard no longer lies over the page before it when read as its PDF part; grayscale TIFFs with an alpha channel or extra channels place and open, #1466 in part; a faded or masked fill keeps its stroke apart on PDF and `.ai` import, #1434; SVG knockout groups without masks, #1435; Affinity import: a text frame too short for its first line is made taller, #1423; `.ai` editing data: a compound path takes its last path's paint and keeps paths grouped inside it, #1410; a `.ai` whose PDF part is only text opens from it, #1387; PDF and `.ai` import keep overprint, #1388; `.ai` editing data: gradients with middle stops, #1390; type of objects with an appearance, hidden layers and later artboards, #1391; area type in a frame too short for the fallback font, #1392; `.ai` editing data: placed (linked) files read, #1264; gradient-filled shapes import as paths, #1304; white constant alpha soft masks, #1286 in part; DXF control-point SPLINE closure read, #1299 follow-up; `.ai` and PDF trim and bleed boxes as artboard and bleed, #1266; `.ai` gradient matrices, meshes and artboard names from the editing data; `.ai` art styles, clipping fills and compound looks from the editing data; `editingData: "always"` opens a `.ai` from its editing data; a `.ai` whose PDF part is only text opens from it, #1387; PDF and `.ai` import keep overprint, #1388; `.ai` editing data: gradients with middle stops, #1390; type of objects with an appearance, hidden layers and later artboards, #1391; area type in a frame too short for the fallback font, #1392; `.ai` editing data: placed (linked) files read, #1264; gradient-filled shapes import as paths, #1304; white constant alpha soft masks, #1286 in part; DXF control-point SPLINE closure read, #1299 follow-up; `.ai` and PDF trim and bleed boxes as artboard and bleed, #1266; `.ai` gradient matrices, meshes and artboard names from the editing data; `.ai` art styles, clipping fills and compound looks from the editing data; a `.ai` whose PDF part is only text opens from it, #1387; PDF and `.ai` import keep overprint, #1388; `.ai` editing data: gradients with middle stops, #1390; type of objects with an appearance, hidden layers and later artboards, #1391; area type in a frame too short for the fallback font, #1392; `.ai` editing data: placed (linked) files read, #1264; gradient-filled shapes import as paths, #1304; white constant alpha soft masks, #1286 in part; DXF control-point SPLINE closure read, #1299 follow-up; `.ai` and PDF trim and bleed boxes as artboard and bleed, #1266; `.ai` gradient matrices, meshes and artboard names from the editing data; a `.ai` whose PDF part is only text opens from it, #1387; PDF and `.ai` import keep overprint, #1388; `.ai` editing data: gradients with middle stops, #1390; type of objects with an appearance, hidden layers and later artboards, #1391; area type in a frame too short for the fallback font, #1392; `.ai` editing data: placed (linked) files read, #1264; gradient-filled shapes import as paths, #1304; white constant alpha soft masks, #1286 in part; DXF control-point SPLINE closure read, #1299 follow-up; `.ai` and PDF trim and bleed boxes as artboard and bleed, #1266; SVG knockout groups of opaque art without masks; a `.ai` whose PDF part is only text opens from it, #1387; PDF and `.ai` import keep overprint, #1388; `.ai` editing data: gradients with middle stops, #1390; type of objects with an appearance, hidden layers and later artboards, #1391; area type in a frame too short for the fallback font, #1392; `.ai` editing data: placed (linked) files read, #1264; gradient-filled shapes import as paths, #1304; white constant alpha soft masks, #1286 in part; DXF control-point SPLINE closure read, #1299 follow-up; `.ai` and PDF trim and bleed boxes as artboard and bleed, #1266; `.ai` keeps its RGB numbers; PDF import keeps a stroke apart from a fill masked or faded by its group) · **Target:** Adobe Illustrator 2026 (30.x)
Every format Illustrator opens, places, saves or exports, against VectorCraft's format table (`FORMATS`,
`OPEN_EXTS`, `PLACE_EXTS` in `crates/engine/src/cmd/fileio/mod.rs`). Illustrator's list comes from its public
@@ -50,7 +50,7 @@ private editing data. VectorCraft:
### Illustrator's private editing data
the app's own editing copy of a file (an EPS after its `%%EOF`, a `.ai`'s `AIPrivateData` streams, a PDF's `AIPDFPrivateData` streams when it was saved with the editing data (#868), Zstandard or zlib, the EPS's in ASCII85) is not documented as a whole. VectorCraft reads its structure: layers and sublayers (names, order, visibility, lock, printing, preview, dimming, colour), groups as they were nested, compound paths (painted by their last path, or the last painted one, with the paths of groups inside them kept as their paths: #1410), clipping groups and layer clipping, object names, hidden and locked objects, fills and strokes (grey, CMYK, RGB, named and spot colours, spot colours defined in Lab with their Lab values (#1032), global process colours as global swatches at their tint), linear and radial gradients, pattern fills with their patterns as pattern swatches (#1025), opacity, blend modes, isolation and knockout, embedded images with their alpha channel, placed (linked) files as linked images in their place, each showing the low-resolution preview the file keeps of it until its file is found or relinked in the Links panel (#1264), guides, and every artboard where it is. A gradient with stops in the middle runs its whole ramp across its shape, and a gradient object does not pass its fill to the next path (#1390). An object whose art style is one fill and one stroke at most (solid colours, its own gradient, a variable-width profile) with an Outer Glow or Drop Shadow comes in as itself with them; one with more, other effects, a brush or dashes aligned to corners comes in as its drawn look (a group named after it). Gradients take their matrix (`Xm`, radials and skewed ones too), focal point and the order of stops sharing a ramp point; gradient meshes, a clipping path's own fill and the artboards' names are read too. `editingData: "always"` (`convert --editing-data`) opens a `.ai` from its editing data even where it draws differently from its page, which can be older, with a note. Type is made from the file's text document, whole and editable, shown or not: point type, area type (a story in several frames as threaded type) and type on a path, with its characters, fonts, size, leading, tracking, scaling, baseline shift, fill and stroke (grey, RGB or CMYK), alignment, indents and paragraph spacing; the page's drawing of it (often in pieces) is left out. Where the text document can't say (a frame of another kind, or a document that doesn't agree with the page), type that shows comes from the page into its text object's place (no group around it), and hidden type is left out with a note. Kerning, underline and the other character and paragraph options aren't read yet. A `.ai` saved without PDF compatibility (a placeholder page) opens from its editing data alone, its point type, area type and type on a path made from the text document. A `.ai` whose PDF part shows only text isn't taken for that placeholder when its page states an art, trim or bleed box: it opens from its editing data alone where that reads, else from its PDF part (#1387). Text objects with an appearance keep their own text and frame, type of hidden layers stays hidden, and type on later artboards lands on its text objects (#1391); area type whose frame is too short for a line of the fallback font shows its first line (the frame is made taller, with a warning in the open result) (#1392). Symbols, pattern fills whose pattern it can't read, placed files the data keeps no preview of and anything else it doesn't read make the file come in as its page (on a layer that doesn't show, they are left out of that layer), with a warning saying what. The layers' art is also compared with the page (by lightness, so colours written as their CMYK equivalents compare alike, and by whether a pixel is inked at all); the page is used when they differ by more than 5%, where one draws an object the other doesn't (away from type, whose lines may be laid out afresh), and when an EPS whose page is its art's box has art printed outside it (#735). An EPS whose page is its art's box keeps that page when it comes in through its layers, not the editing data's artboard, and a text object counts as drawn by the page by its colours, not only its lightness, so a red stroke stacked over a dark red one stays (#1102). `textAs: "outlines"` opens a `.ai` whose type shows from its PDF part, which has the outlines; `editingData: false` opens any of them as its page or PDF part only, for print pipelines (#735). A file whose import left something out (hidden text, art or layers) is never written over by an export or Save As to its own path unless `acknowledgeLoss: true` (`convert --replace-lossy`), so the original keeps what the document lacks. Where a `.ai` can't be read that way (or its layers are turned off in the import options), we read its PDF-compatible part, so Illustrator-only live objects arrive as appearance, and plain groups arrive ungrouped: that part draws each object on itLine truncated
the app's own editing copy of a file (an EPS after its `%%EOF`, a `.ai`'s `AIPrivateData` streams, a PDF's `AIPDFPrivateData` streams when it was saved with the editing data (#868), Zstandard or zlib, the EPS's in ASCII85) is not documented as a whole. VectorCraft reads its structure: layers and sublayers (names, order, visibility, lock, printing, preview, dimming, colour), groups as they were nested, compound paths (painted by their last path, or the last painted one, with the paths of groups inside them kept as their paths: #1410), clipping groups and layer clipping, object names, hidden and locked objects, fills and strokes (grey, CMYK, RGB, named and spot colours, spot colours defined in Lab with their Lab values (#1032), global process colours as global swatches at their tint), linear and radial gradients, pattern fills with their patterns as pattern swatches (#1025), opacity, blend modes, isolation and knockout, embedded images with their alpha channel, placed (linked) files as linked images in their place, each showing the low-resolution preview the file keeps of it until its file is found or relinked in the Links panel (#1264), guides, and every artboard where it is. A gradient with stops in the middle runs its whole ramp across its shape, and a gradient object does not pass its fill to the next path (#1390). An object whose art style is one fill and one stroke at most (solid colours, its own gradient, a variable-width profile) with an Outer Glow or Drop Shadow comes in as itself with them; one with more, other effects, a brush or dashes aligned to corners comes in as its drawn look (a group named after it). Gradients take their matrix (`Xm`, radials and skewed ones too), focal point and the order of stops sharing a ramp point; gradient meshes, a clipping path's own fill and the artboards' names are read too. `editingData: "always"` (`convert --editing-data`) opens a `.ai` from its editing data even where it draws differently from its page, which can be older, with a note. Type is made from the file's text document, whole and editable, shown or not: point type, area type (a story in several frames as threaded type) and type on a path, with its characters, fonts, size, leading, tracking, scaling, baseline shift, fill and stroke (grey, RGB or CMYK), alignment, indents and paragraph spacing; the page's drawing of it (often in pieces) is left out. Where the text document can't say (a frame of another kind, or a document that doesn't agree with the page), type that shows comes from the page into its text object's place (no group around it), and hidden type is left out with a note. Kerning, underline and the other character and paragraph options aren't read yet. A `.ai` saved without PDF compatibility (a placeholder page) opens from its editing data alone, its point type, area type and type on a path made from the text document. A `.ai` whose PDF part shows only text isn't taken for that placeholder when its page states an art, trim or bleed box: it opens from its editing data alone where that reads, else from its PDF part (#1387). Text objects with an appearance keep their own text and frame, type of hidden layers stays hidden, and type on later artboards lands on its text objects (#1391); area type whose frame is too short for a line of the fallback font shows its first line (the frame is made taller, with a warning in the open result) (#1392). Symbols, pattern fills whose pattern it can't read, placed files the data keeps no preview of and anything else it doesn't read make the file come in as its page (on a layer that doesn't show, they are left out of that layer), with a warning saying what. The layers' art is also compared with the page (by lightness, so colours written as their CMYK equivalents compare alike, and by whether a pixel is inked at all); the page is used when they differ by more than 5%, where one draws an object the other doesn't (away from type, whose lines may be laid out afresh), and when an EPS whose page is its art's box has art printed outside it (#735). An EPS whose page is its art's box keeps that page when it comes in through its layers, not the editing data's artboard, and a text object counts as drawn by the page by its colours, not only its lightness, so a red stroke stacked over a dark red one stays (#1102). `textAs: "outlines"` opens a `.ai` whose type shows from its PDF part, which has the outlines; `editingData: false` opens any of them as its page or PDF part only, for print pipelines (#735). A file whose import left something out (hidden text, art or layers) is never written over by an export or Save As to its own path unless `acknowledgeLoss: true` (`convert --replace-lossy`), so the original keeps what the document lacks. Where a `.ai` can't be read that way (or its layers are turned off in the import options), we read its PDF-compatible part, so Illustrator-only live objects arrive as appearance, and plain groups arrive ungrouped: that part draws each object on itLine truncated
## Format by format
@@ -86,6 +86,7 @@ the app's own editing copy of a file (an EPS after its `%%EOF`, a `.ai`'s `AIPri
| Date | Change | Summary |
|---|---|---|
| 2026-10-13 | minor | `.ai` read as its PDF part: a page whose art reaches past its artboard to the left (notes beside a design) moves right in the row until that art clears the page before it, so it is no longer taken for that page's art; a multi-artboard `.ai` with such notes opened as its PDF part ("the art on them differs from the page's"), without the art outside its artboards, and now opens from its editing data |
| 2026-10-13 | minor | TIFF: grayscale files with an alpha channel or other extra channels place, relink and open, read as CMYK files with alpha already were (8 and 16 bits, either polarity; #1489, part of #1466); the rows for #1434 (strokes kept apart from a faded or masked fill, a `.ai`'s RGB numbers) and #1435 (SVG knockout groups without masks, `--decimals`) were written by those PRs; scores unchanged (estimated) |
| 2026-10-12 | minor | Affinity import: a text frame too short for its first line (a 64 pt title in a 54 pt frame) is made taller from its top, with a warning in the open result, instead of showing nothing (#1423), as `.ai` area type is (#1392); the spacing Affinity itself fits the line with isn't read; scores unchanged |
| 2026-10-12 | minor | `.ai` editing data: a compound path takes the paint, opacity, blend mode and fill rule of its last path (the last painted one when that has none), so gradient-filled compound paths no longer come in black, and paths grouped inside a compound path stay its paths (#1426, fixes #1410); hand-written editing data test; scores unchanged |
+3 -2
View File
@@ -2977,8 +2977,9 @@ included) the fonts in DirectWrite's system font collection, such as those Adobe
`/Network/Library/Fonts`, `~/Library/Fonts` and downloaded system fonts, plus in the desktop app and `vectorcraft-cli`
the fonts CoreText's font manager lists outside them, such as those apps and font managers register from their own
folders; Linux and BSD: `/usr/share/fonts`,
`/usr/local/share/fonts`, `~/.fonts` and the XDG data folders' `fonts`, `~/.local/share/fonts` among them, and in a
Flatpak sandbox the host's fonts). Faces without outlines VectorCraft draws (no `glyf`, `CFF`, `CFF2` or `VARC` table, such
`/usr/local/share/fonts`, `~/.fonts` and the XDG data folders' `fonts`, `~/.local/share/fonts` among them, in a
Flatpak sandbox the host's fonts, and the folders fontconfig's configuration lists (`<dir>` in `/etc/fonts/fonts.conf`
and the files it includes: where packages add theirs, such as TeX fonts under `/usr/share/texmf/fonts`)). Faces without outlines VectorCraft draws (no `glyf`, `CFF`, `CFF2` or `VARC` table, such
as bitmap-only fonts) are left out. The scan also reads the folder the `fontsFolder` preference names (Preferences › Type ›
Additional Fonts Folder) with its subfolders and, in the desktop app and `vectorcraft-cli`, VectorCraft's own `Fonts` folder
next to the preferences: `~/Library/Application Support/VectorCraft/Fonts` on macOS, `%APPDATA%\VectorCraft\Fonts` on