Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions crates/engine/src/cmd/layout/publication/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1905,8 +1905,7 @@ pub(in crate::cmd::layout) fn publication(s: &mut Session, p: &Value) -> CmdResu
// What a scale bar or a grid asked for in other than its default look loses or has to say.
let asked = |key: &str| p.get(key).is_some_and(Value::is_object);
if let Some(bar) = bar_id.filter(|_| asked("scaleBar")) {
let losses: Vec<_> = text_fit_loss(s, i, bar).into_iter().collect();
warnings.extend(rustgis_render::layout::scale_bar_fit_notices(&losses));
say_text_fit(s, i, bar, true);
}
if let Some(crs) = p.get("grid").and_then(|g| g.get("crs")).and_then(Value::as_str) {
crate::cmd::say_crs_note(s, crs);
Expand Down
12 changes: 8 additions & 4 deletions crates/engine/src/tests/layout_publication_parts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,12 @@ fn a_publication_scale_bar_takes_its_options_and_its_box_is_sized_for_it() {
#[test]
fn a_publication_scale_bar_given_a_larger_text_gets_the_height_for_it() {
let (default, _) = sheet(json!({}));
let (s, r) = sheet(json!({"scaleBar": {"textSize": 14}}));
let (s, _) = sheet(json!({"scaleBar": {"textSize": 14}}));
let bar = find(&s, "Scale Bar").unwrap();
assert!(matches!(bar.kind, ElementKind::ScaleBar { text_size, .. } if text_size == 14.0), "{:?}", bar.kind);
assert!(bar.h > find(&default, "Scale Bar").unwrap().h);
assert!(!r["warnings"].to_string().contains("scale bar"), "{}", r["warnings"]);
let said = s.notices_since(0);
assert!(!said.iter().any(|n| n.text.starts_with("Scale bar")), "{said:?}");
}

#[test]
Expand Down Expand Up @@ -235,8 +236,11 @@ fn the_publication_parts_fixture_opens_and_keeps_its_requirement() {

#[test]
fn a_publication_scale_bar_too_large_for_the_sheet_says_it_does_not_fit() {
let (_, r) = sheet(json!({"scaleBar": {"textSize": 100}}));
assert!(r["warnings"].to_string().contains("Scale bar \\\"Scale Bar\\\""), "{}", r["warnings"]);
let mut s = world();
let mark = s.notice_mark();
publish(&mut s, json!({"scaleBar": {"textSize": 100}})).unwrap();
let said = s.notices_since(mark);
assert_eq!(said.iter().filter(|n| n.text.starts_with("Scale bar \"Scale Bar\": its box is too small")).count(), 1, "{said:?}");
}

#[test]
Expand Down
Loading