mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-05 13:32:45 -05:00
.ai import: stretched type on a path is drawn from the page
Type on a path follows the path's tangent and grows by one scale, so a frame matrix that stretches or slants it (for example 4 0 0 1) cannot be kept: its glyphs came in twice as wide and twice as tall while the path grew four times. Such a frame is now left to the page, as mirrored type is. Turned and uniformly scaled frames are still made as type on a path.
This commit is contained in:
1 parent
64c1dabeb5
commit
122d3d6921
1 file changed
+23
-1
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user