diff --git a/crates/eps/src/import/ate.rs b/crates/eps/src/import/ate.rs index bc04bb104f..a444f593b6 100644 --- a/crates/eps/src/import/ate.rs +++ b/crates/eps/src/import/ate.rs @@ -1349,8 +1349,13 @@ impl Story { let (scale, turn) = turn_of(m)?; (scale, turn, TextKind::Area { frame: path_of(s, template, to_doc).transformed(turn.inverse()) }) } + // The glyphs follow the path's tangent and grow by one scale: a frame matrix that also + // stretches or slants them isn't made from the text document (the page draws that type). FrameKind::OnPath { segments, start, end, options, matrix } => { - let (scale, _) = turn_of(matrix)?; + let (scale, _) = turn_of(matrix).filter(|(_, turn)| { + let [a, b, c, d, ..] = turn.as_coeffs(); + (a - d).abs() < 1e-6 && (b + c).abs() < 1e-6 + })?; let n = segments.len() as f64; // A closed path keeps its end bracket wherever it is (the same place as the start: a // full turn, see `TextKind::path_span`); an open one's end at its end is none, unless @@ -3192,6 +3197,23 @@ mod tests { assert!(turned.width() < 1e-6 && (turned.height() - plain.width()).abs() < 1e-6, "{turned:?}"); } + #[test] + fn type_on_a_stretched_path_is_left_to_the_page() { + // GUARDS: a frame matrix that stretched the path four times and the type not at all came + // in with glyphs twice as wide and twice as tall. + let open = [[0.0, 0.0, 30.0, 0.0, 70.0, 0.0, 100.0, 0.0], [100.0, 0.0, 130.0, 0.0, 170.0, 0.0, 200.0, 0.0]]; + let made = |options: &str| { + let mut st = story("type", &[0.0], &Para::default()); + st.frames = vec![on_path_frame_with(&open, [0.0, 2.0], options).unwrap()]; + st.node(NodeId(1), 0, (0.0, 0.0), Affine::IDENTITY) + }; + assert!(made("/2 [ 4 0 0 1 0 0 ]").is_none()); + assert!(made("/2 [ 1 0.5 0 1 0 0 ]").is_none()); + // A uniform scale and a turn are still made. + assert!(made("/2 [ 2 0 0 2 0 0 ]").is_some()); + assert!(made("/2 [ 0 2 -2 0 0 0 ]").is_some()); + } + #[test] fn area_frame_options_are_read() { // GUARDS: area type came in with one row, one column and the 18 pt gutter whatever its frame kept.