mirror of
https://github.com/storytold/wordcraft.git
synced 2026-12-03 22:40:27 +00:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7d79967c4 | ||
|
|
97daa4b3ed | ||
|
|
7b03696d8c | ||
|
|
0ee236e6a4 | ||
|
|
f94aecace7 | ||
|
|
366b89341d | ||
|
|
0c7f425e91 |
@@ -1,6 +1,6 @@
|
||||
use super::ctx::{Ctx, Joining, page_anchored};
|
||||
use super::floats::{
|
||||
ObjFrame, ObjectPlacement, WrapArea, align_in, float_rect, floating, left_out_objects, place_objects, rel_exclusions, wrap_area,
|
||||
AreaKind, ObjFrame, ObjectPlacement, WrapArea, align_in, float_rect, floating, left_out_objects, place_objects, rel_exclusions, wrap_area,
|
||||
};
|
||||
use super::flow::again;
|
||||
use super::page::PageFrame;
|
||||
@@ -162,11 +162,11 @@ fn layout_table_block(input: TableBlockContext<'_, '_, '_>) -> bool {
|
||||
Some(float) => {
|
||||
let legacy = (ctx.doc.settings.compat_mode < 15).then(|| table::first_cell_left_margin(ctx, t));
|
||||
let (rect, area) = box_float_table_rect(frame, width, *y, &layout, &float, legacy, float_tables);
|
||||
exclusions.push((area, false, None, WrapText::BothSides, true));
|
||||
exclusions.push((area, false, None, WrapText::BothSides, AreaKind::Table));
|
||||
float_tables.push(area);
|
||||
table_areas.push(area);
|
||||
if float.v_rel == Anchor::Page {
|
||||
page_table_wraps.push((area, false, None, WrapText::BothSides, true));
|
||||
page_table_wraps.push((area, false, None, WrapText::BothSides, AreaKind::Table));
|
||||
}
|
||||
(rect.x, rect.y)
|
||||
}
|
||||
@@ -804,7 +804,7 @@ impl Joint {
|
||||
let probe = again(ctx, eq, |ctx| ctx.para_labelled(q, width, table, &[], 0.0, None));
|
||||
let (gap, height) = probe.lines.first().map_or((0.0, self.height), |l| ((self.baseline - (l.baseline - l.top)).max(0.0), l.height));
|
||||
let rect = Rect::new(self.left, self.top, (self.end - self.left).max(0.0), (gap + height - 0.01).max(0.01));
|
||||
let mut areas = vec![(rect, false, None, WrapText::Right, false)];
|
||||
let mut areas = vec![(rect, false, None, WrapText::Right, AreaKind::Object)];
|
||||
// Just below the first row as the line breaker tests it: the breaker tests every row at
|
||||
// its estimate (`row_est`), not at the line's height, so the first row never meets this
|
||||
// area and every later row, starting lower, does and moves below it. The probe's own first
|
||||
@@ -812,7 +812,7 @@ impl Joint {
|
||||
// line), so its height can't be used here.
|
||||
let below = self.top + gap + probe.row_est + 0.01;
|
||||
if self.bottom() > below {
|
||||
areas.push((Rect::new(self.left, below, width.max(0.01), self.bottom() - below), true, None, WrapText::BothSides, false));
|
||||
areas.push((Rect::new(self.left, below, width.max(0.01), self.bottom() - below), true, None, WrapText::BothSides, AreaKind::Object));
|
||||
}
|
||||
(gap, areas)
|
||||
}
|
||||
|
||||
@@ -117,8 +117,20 @@ pub(crate) fn align_in((start, extent): (f32, f32), offset: f32, size: f32, alig
|
||||
|
||||
/// An area text keeps clear of: its bounds, whether text may only go above and below it, and
|
||||
/// (Tight and Through wrapping) the outline text follows inside it, the sides text may go on,
|
||||
/// and whether it comes from a floating table (inclusive line-bottom contact, #3977).
|
||||
pub(crate) type WrapArea = (Rect, bool, Option<Arc<contour::Contour>>, WrapText, bool);
|
||||
/// and what it comes from (a floating table: inclusive line-bottom contact, #3977; Tight and
|
||||
/// Through wrapping: a narrower gap beside it before Word 2013 layout, #6316).
|
||||
pub(crate) type WrapArea = (Rect, bool, Option<Arc<contour::Contour>>, WrapText, AreaKind);
|
||||
|
||||
/// What a [`WrapArea`] keeps text clear of.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum AreaKind {
|
||||
/// A floating picture, shape, text box or chart wrapped Square or Top and Bottom.
|
||||
Object,
|
||||
/// A floating object wrapped Tight or Through, with or without an outline.
|
||||
Tight,
|
||||
/// A floating table.
|
||||
Table,
|
||||
}
|
||||
|
||||
/// Wrap areas a page starts with (#2048): by page index, the floating objects (block, object
|
||||
/// index) placed above the top of their anchor paragraph, with text before it on the page, and
|
||||
@@ -210,19 +222,20 @@ pub(crate) fn wrap_area(r: Rect, float: &Float, outline: Option<&[(f32, f32)]>)
|
||||
if matches!(float.wrap, Wrap::Tight | Wrap::Through)
|
||||
&& let Some((area, c)) = outline.and_then(|o| contour::contour_area(r, float, o))
|
||||
{
|
||||
return Some((area, false, Some(Arc::new(c)), float.wrap_text, false));
|
||||
return Some((area, false, Some(Arc::new(c)), float.wrap_text, AreaKind::Tight));
|
||||
}
|
||||
let d = |v: f32| if v.is_finite() { v.clamp(0.0, 1584.0) } else { 0.0 };
|
||||
let (side, top, bottom) = (d(float.dist), d(float.dist_top), d(float.dist_bottom));
|
||||
// A rotated object keeps text clear of its rotated bounds.
|
||||
let r = float.spin().bounds(r);
|
||||
Some((Rect::new(r.x - side, r.y - top, r.w + side * 2.0, r.h + top + bottom), float.wrap == Wrap::TopAndBottom, None, float.wrap_text, false))
|
||||
let kind = if matches!(float.wrap, Wrap::Tight | Wrap::Through) { AreaKind::Tight } else { AreaKind::Object };
|
||||
Some((Rect::new(r.x - side, r.y - top, r.w + side * 2.0, r.h + top + bottom), float.wrap == Wrap::TopAndBottom, None, float.wrap_text, kind))
|
||||
}
|
||||
|
||||
/// Wrap areas relative to a paragraph whose column starts at `x0` and whose top is `y0`.
|
||||
pub(crate) fn rel_exclusions(excl: &[WrapArea], x0: f32, y0: f32) -> Vec<para::Exclusion> {
|
||||
excl.iter()
|
||||
.map(|(r, tb, c, side, table)| para::Exclusion {
|
||||
.map(|(r, tb, c, side, kind)| para::Exclusion {
|
||||
top: r.y - y0,
|
||||
bottom: r.bottom() - y0,
|
||||
left: r.x - x0,
|
||||
@@ -230,7 +243,8 @@ pub(crate) fn rel_exclusions(excl: &[WrapArea], x0: f32, y0: f32) -> Vec<para::E
|
||||
top_bottom: *tb,
|
||||
contour: c.clone(),
|
||||
side: *side,
|
||||
table: *table,
|
||||
table: *kind == AreaKind::Table,
|
||||
tight: *kind == AreaKind::Tight,
|
||||
})
|
||||
// Top-and-Bottom areas above the first line can still take room: they sit in the
|
||||
// paragraph's space before, which Word lays out again below them (#7143). Side-wrapping
|
||||
|
||||
@@ -1331,7 +1331,7 @@ mod tests {
|
||||
pb.cap_columns();
|
||||
// A preceding floating object leaves a narrow strip of the first column, but does
|
||||
// not occupy the second column. The same kept paragraph fits there in one line.
|
||||
pb.excl.push((Rect::new(pb.col_x(), top, pb.col_w() - 26.0, 100.0), false, None, WrapText::BothSides, false));
|
||||
pb.excl.push((Rect::new(pb.col_x(), top, pb.col_w() - 26.0, 100.0), false, None, WrapText::BothSides, crate::floats::AreaKind::Object));
|
||||
place_para_in_flow(ctx, pb, p, 0, top);
|
||||
|
||||
assert_eq!(pb.pages.len(), 1, "a fitting candidate kept the balance attempt on its page");
|
||||
|
||||
@@ -163,6 +163,9 @@ pub struct Exclusion {
|
||||
pub side: WrapText,
|
||||
/// A floating table counts a line touching its top as overlapping; shapes do not (#3977).
|
||||
pub table: bool,
|
||||
/// Tight and Through wrapping: before Word 2013 layout text goes in a narrower gap beside
|
||||
/// it (#6316).
|
||||
pub tight: bool,
|
||||
}
|
||||
|
||||
impl Exclusion {
|
||||
|
||||
@@ -30,6 +30,9 @@ struct Breaker<'e> {
|
||||
/// Word 2013+ (compatibility mode 15) fits more text on a justified line by shrinking its
|
||||
/// spaces (`space_room`); on a line with tabs, only the spaces after a final left/default tab.
|
||||
shrink_spaces: bool,
|
||||
/// Word 2013+ layout (compatibility mode 15): the narrowest span beside a Tight or Through
|
||||
/// object is the same as beside any other ([`min_span`]).
|
||||
layout_2013: bool,
|
||||
/// Word 2003's indent rules (`w:doNotSuppressIndentation`) before Word 2013's layout, for an
|
||||
/// unnumbered paragraph: a row starts right after a floating object before the indent.
|
||||
tight_indent: bool,
|
||||
@@ -205,6 +208,7 @@ impl<'e> Breaker<'e> {
|
||||
hanging_at: if rp.indent_first < 0.0 { Some(rp.indent_left) } else { None },
|
||||
tab_origin: if settings.odf.is_some_and(|o| o.tabs_from_indent) { rp.indent_left } else { 0.0 },
|
||||
shrink_spaces: rp.align == Align::Justify && settings.compat_mode >= wordcraft_doc::COMPAT_MODE_CURRENT,
|
||||
layout_2013: settings.compat_mode >= wordcraft_doc::COMPAT_MODE_CURRENT,
|
||||
tight_indent: settings.do_not_suppress_indentation
|
||||
&& settings.compat_mode < wordcraft_doc::COMPAT_MODE_CURRENT
|
||||
&& level.is_none()
|
||||
@@ -287,7 +291,9 @@ impl<'e> Breaker<'e> {
|
||||
}
|
||||
}
|
||||
let row = (self.top, self.est_h, self.table_h);
|
||||
match row_spans(self.exclusions, row, (lo, self.base_right), self.tight_indent).map(|mut spans| (spans.pop_front(), spans)) {
|
||||
match row_spans(self.exclusions, row, (lo, self.base_right), self.tight_indent, self.layout_2013)
|
||||
.map(|mut spans| (spans.pop_front(), spans))
|
||||
{
|
||||
Ok((Some((a, b)), rest)) => {
|
||||
// Under Word 2003's indent rules a row can start left of the indent too.
|
||||
let moved = if self.tight_indent { (a - lo).abs() > 0.01 } else { a > lo };
|
||||
@@ -1166,10 +1172,28 @@ fn line_end_kern(pl: &ParaLayout, j: usize) -> f32 {
|
||||
}
|
||||
}
|
||||
|
||||
/// Narrowest span text flows into beside a floating object, points. Word puts an empty
|
||||
/// Narrowest span text flows into beside a floating table, points. Word puts an empty
|
||||
/// paragraph beside a floating table in a 21.3pt gap but not in an 18.6pt one.
|
||||
const MIN_SPAN: f32 = 20.0;
|
||||
|
||||
/// Narrowest span text flows into beside a floating picture or shape, points: Word puts a line
|
||||
/// in an 18pt gap to its wrap area but not in a 17.95pt one, for square, tight and through
|
||||
/// wrapping alike, whatever the text (#6316).
|
||||
const MIN_SPAN_OBJECT: f32 = 18.0;
|
||||
|
||||
/// Tight and Through wrapping before Word 2013 layout (compatibility mode 14 and below) need
|
||||
/// only half that: 9pt fits, 8.95pt doesn't.
|
||||
const MIN_SPAN_CONTOUR_OLD: f32 = 9.0;
|
||||
|
||||
/// The narrowest span text goes into beside `e`, with Word 2013 layout or later (`current`).
|
||||
fn min_span(e: &Exclusion, current: bool) -> f32 {
|
||||
match (e.table, e.tight) {
|
||||
(true, _) => MIN_SPAN,
|
||||
(false, true) if !current => MIN_SPAN_CONTOUR_OLD,
|
||||
_ => MIN_SPAN_OBJECT,
|
||||
}
|
||||
}
|
||||
|
||||
/// Where a row starts under Word 2003's indent rules: right after the floating objects that end
|
||||
/// at or before the indent `lo` on this row and let text past their right side (their outline's
|
||||
/// right edge for Tight and Through wrapping), never left of the paragraph's own left edge (0) or
|
||||
@@ -1200,16 +1224,18 @@ fn baseline_offset(spacing: LineSpacing, asc: f32, height: f32, desc: f32) -> f3
|
||||
}
|
||||
|
||||
/// The spans of a row at `top` (about `h` tall) between `lo` and `hi` that text can use around
|
||||
/// the exclusions, left to right (Square wrapping uses both sides of an object). `Err(y)`: none
|
||||
/// here, try again at `y` (below what's in the way). With `tight_indent` (Word 2003's indent
|
||||
/// rules, `w:doNotSuppressIndentation`) a row starts right after a floating object that ends
|
||||
/// before `lo`, the indent ignored (ECMA-376 Part 4 §14.8.3.12: a paragraph indented 1" tightly
|
||||
/// wraps an object at 0.25").
|
||||
/// the exclusions, left to right (Square wrapping uses both sides of an object); a span must be
|
||||
/// as wide as the minimum of each object it borders (`current`: Word 2013 layout or later).
|
||||
/// `Err(y)`: none here, try again at `y` (below what's in the way). With `tight_indent` (Word
|
||||
/// 2003's indent rules, `w:doNotSuppressIndentation`) a row starts right after a floating object
|
||||
/// that ends before `lo`, the indent ignored (ECMA-376 Part 4 §14.8.3.12: a paragraph indented
|
||||
/// 1" tightly wraps an object at 0.25").
|
||||
fn row_spans(
|
||||
exclusions: &[Exclusion],
|
||||
(top, h, table_h): (f32, f32, f32),
|
||||
(lo, hi): (f32, f32),
|
||||
tight_indent: bool,
|
||||
current: bool,
|
||||
) -> Result<VecDeque<(f32, f32)>, f32> {
|
||||
let lo = if tight_indent { tight_row_start(exclusions, (top, h, table_h), lo) } else { lo };
|
||||
let here: Vec<&Exclusion> = exclusions.iter().filter(|e| e.intersects_row(top, h, table_h, lo, hi)).collect();
|
||||
@@ -1217,13 +1243,14 @@ fn row_spans(
|
||||
return Err(below);
|
||||
}
|
||||
// What each object takes of the row: its whole area, or (Tight, Through) the stretches its
|
||||
// outline takes, as (left, right, bottom of the object's area).
|
||||
let mut taken: Vec<(f32, f32, f32)> = Vec::new();
|
||||
// outline takes, as (left, right, bottom of the object's area, the narrowest span beside it).
|
||||
let mut taken: Vec<(f32, f32, f32, f32)> = Vec::new();
|
||||
for e in &here {
|
||||
let first = taken.len();
|
||||
let min = min_span(e, current);
|
||||
match &e.contour {
|
||||
None => taken.push((e.left, e.right, e.bottom)),
|
||||
Some(c) => taken.extend(c.occupied(top - e.top, top + h - e.top).into_iter().map(|(a, b)| (a + e.left, b + e.left, e.bottom))),
|
||||
None => taken.push((e.left, e.right, e.bottom, min)),
|
||||
Some(c) => taken.extend(c.occupied(top - e.top, top + h - e.top).into_iter().map(|(a, b)| (a + e.left, b + e.left, e.bottom, min))),
|
||||
}
|
||||
// Text on one side only: the object's other side of the row is taken too.
|
||||
let Some(mine) = taken.get(first..).filter(|t| !t.is_empty() && !e.side.is_both()) else { continue };
|
||||
@@ -1236,23 +1263,72 @@ fn row_spans(
|
||||
_ => left - lo >= hi - right,
|
||||
};
|
||||
taken.truncate(first);
|
||||
taken.push(if text_left { (left, hi.max(right), e.bottom) } else { (lo.min(left), right, e.bottom) });
|
||||
taken.push(if text_left { (left, hi.max(right), e.bottom, min) } else { (lo.min(left), right, e.bottom, min) });
|
||||
}
|
||||
taken.retain(|(l, r, _)| *r > lo && *l < hi);
|
||||
taken.retain(|(l, r, _, _)| *r > lo && *l < hi);
|
||||
if taken.is_empty() {
|
||||
return Ok(VecDeque::from([(lo, hi)]));
|
||||
}
|
||||
let mut spans = vec![(lo, hi)];
|
||||
for &(left, right, _) in &taken {
|
||||
// Each span with the minimum of what borders it on the left and on the right (nothing at the
|
||||
// row's ends): an object cutting a span becomes the new edge of both pieces.
|
||||
let mut spans = vec![(lo, hi, 0.0_f32, 0.0_f32)];
|
||||
for &(left, right, _, min) in &taken {
|
||||
spans = spans
|
||||
.into_iter()
|
||||
.flat_map(|(a, b)| if right <= a || left >= b { vec![(a, b)] } else { vec![(a, left.min(b)), (right.max(a), b)] })
|
||||
.flat_map(
|
||||
|(a, b, ml, mr)| {
|
||||
if right <= a || left >= b { vec![(a, b, ml, mr)] } else { vec![(a, left.min(b), ml, min), (right.max(a), b, min, mr)] }
|
||||
},
|
||||
)
|
||||
.collect();
|
||||
}
|
||||
spans.retain(|(a, b)| b - a >= MIN_SPAN);
|
||||
let spans: VecDeque<(f32, f32)> = spans.into_iter().filter(|(a, b, ml, mr)| b - a >= ml.max(*mr)).map(|(a, b, ..)| (a, b)).collect();
|
||||
if spans.is_empty() {
|
||||
// Nothing wide enough: the line goes below the first object that ends.
|
||||
return Err(taken.iter().map(|t| t.2).reduce(f32::min).unwrap_or(top));
|
||||
}
|
||||
Ok(spans.into())
|
||||
Ok(spans)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// An exclusion from the row's left edge to `right`, 100pt tall.
|
||||
fn area(right: f32, table: bool, tight: bool) -> Exclusion {
|
||||
Exclusion { top: 0.0, bottom: 100.0, left: 0.0, right, top_bottom: false, contour: None, side: WrapText::BothSides, table, tight }
|
||||
}
|
||||
|
||||
/// Whether a line at the top of a 100pt row finds a span `gap` points wide beside `e`.
|
||||
fn fits(e: Exclusion, gap: f32, current: bool) -> bool {
|
||||
let hi = e.right + gap;
|
||||
row_spans(&[e], (0.0, 12.0, 12.0), (0.0, hi), false, current).is_ok()
|
||||
}
|
||||
|
||||
/// #6316: 18pt beside pictures and shapes; Tight and Through 9pt before Word 2013 layout;
|
||||
/// floating tables keep 20.
|
||||
#[test]
|
||||
fn the_narrowest_span_depends_on_the_object() {
|
||||
for current in [true, false] {
|
||||
assert!(fits(area(50.0, false, false), 18.0, current) && !fits(area(50.0, false, false), 17.9, current));
|
||||
assert!(fits(area(50.0, true, false), 20.0, current) && !fits(area(50.0, true, false), 19.9, current));
|
||||
}
|
||||
assert!(fits(area(50.0, false, true), 18.0, true) && !fits(area(50.0, false, true), 17.9, true));
|
||||
assert!(fits(area(50.0, false, true), 9.0, false) && !fits(area(50.0, false, true), 8.9, false));
|
||||
// A span between a picture and a table needs the table's 20.
|
||||
let both = |gap: f32| {
|
||||
let table = Exclusion { left: 50.0 + gap, right: 300.0, ..area(0.0, true, false) };
|
||||
row_spans(&[area(50.0, false, false), table], (0.0, 12.0, 12.0), (0.0, 300.0), false, true).is_ok()
|
||||
};
|
||||
assert!(both(20.0) && !both(19.9));
|
||||
// A span bordered only by a picture needs 18, whichever order the objects come in, also
|
||||
// when a table cut the span first (a table at 0..70, a picture at 80..100, a 19pt span
|
||||
// right of the picture).
|
||||
let table = area(70.0, true, false);
|
||||
let picture = Exclusion { left: 80.0, right: 100.0, ..area(0.0, false, false) };
|
||||
for order in [[table.clone(), picture.clone()], [picture.clone(), table.clone()]] {
|
||||
let spans = row_spans(&order, (0.0, 12.0, 12.0), (0.0, 119.0), false, true);
|
||||
assert_eq!(spans, Ok(VecDeque::from([(100.0, 119.0)])), "{order:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::boxes::{BoxInput, clear_of_float_tables, layout_box};
|
||||
use super::ctx::{Ctx, with_pct_base};
|
||||
use super::floats::{WrapArea, align_in, body_wraps};
|
||||
use super::floats::{AreaKind, WrapArea, align_in, body_wraps};
|
||||
use super::flow::again;
|
||||
use super::headers::{begins_section, header_items_cap, header_table_areas, placed_cost};
|
||||
use super::notes::table_notes;
|
||||
@@ -433,7 +433,7 @@ fn place_floating_table(ctx: &mut Ctx, pb: &mut PageBuilder, tl: &table::TableLa
|
||||
pg.float_tables.push(Path::top(block));
|
||||
}
|
||||
let area = r.inset(-dl, -dt, -dr, -db);
|
||||
pb.excl.push((area, false, None, WrapText::BothSides, true));
|
||||
pb.excl.push((area, false, None, WrapText::BothSides, AreaKind::Table));
|
||||
pb.float_tables.push(area);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -12253,6 +12253,68 @@ fn tight_wrap_follows_an_ellipse() {
|
||||
assert_eq!(through, tight);
|
||||
}
|
||||
|
||||
/// #6316: how many of seven empty paragraphs (the first anchoring a 200pt-tall rectangle at the
|
||||
/// column's left with `wrap`) go in the `free` points it leaves on its right (column edge to its
|
||||
/// wrap area, 9pt from text included), in compatibility mode `mode`.
|
||||
fn empty_lines_beside(wrap: wordcraft_doc::para::Wrap, free: f32, mode: u32) -> usize {
|
||||
use wordcraft_doc::para::{Anchor, Float, ShapeKind};
|
||||
let w = 468.0 - 9.0 - free;
|
||||
let mut d = Document::from_text("");
|
||||
d.settings.compat_mode = mode;
|
||||
let float = Float { wrap, h_rel: Anchor::Column, v_rel: Anchor::Paragraph, dist: 9.0, ..Default::default() };
|
||||
let shape = InlineObject::Shape {
|
||||
kind: ShapeKind::Rectangle,
|
||||
w,
|
||||
h: 200.0,
|
||||
fill: None,
|
||||
stroke: None,
|
||||
stroke_width: 1.0,
|
||||
float,
|
||||
story: None,
|
||||
effects: Default::default(),
|
||||
freeform: None,
|
||||
extra: Default::default(),
|
||||
};
|
||||
d.insert_object(&Pos::body(0, 0), shape, &Default::default()).unwrap();
|
||||
for i in 1..7 {
|
||||
d.insert_block(StoryRef::Body, &Path::top(i), wordcraft_doc::Block::Para(Default::default())).unwrap();
|
||||
}
|
||||
let l = lay(&d);
|
||||
let lines: Vec<(f32, f32)> =
|
||||
l.pages[0].items.iter().filter_map(|i| if let Placed::Lines { y, para, .. } = i { Some((para.lines[0].left, *y)) } else { None }).collect();
|
||||
let Some(top) = lines.iter().map(|l| l.1).reduce(f32::min) else { return 0 };
|
||||
lines.iter().filter(|(left, y)| *left >= w + 9.0 - 0.01 && *y < top + 200.0).count()
|
||||
}
|
||||
|
||||
/// #6316: Word puts a line beside a floating picture or shape when the gap between the column
|
||||
/// edge and the object's wrap area is at least 18pt, for square, tight and through wrapping; a
|
||||
/// tight-wrapped cover with 17.55 and 19.15pt gaps was pushed onto three pages by a 20pt minimum.
|
||||
#[test]
|
||||
fn text_goes_beside_a_float_in_an_18pt_gap() {
|
||||
crate::test_fonts();
|
||||
use wordcraft_doc::para::Wrap;
|
||||
let current = wordcraft_doc::COMPAT_MODE_CURRENT;
|
||||
for wrap in [Wrap::Square, Wrap::Tight, Wrap::Through] {
|
||||
assert_eq!(empty_lines_beside(wrap, 18.1, current), 7, "{wrap:?} 18.1");
|
||||
assert_eq!(empty_lines_beside(wrap, 17.9, current), 0, "{wrap:?} 17.9");
|
||||
}
|
||||
}
|
||||
|
||||
/// Before Word 2013 layout (mode 14 and below) a line goes beside a tight or through object in
|
||||
/// a 9pt gap; square wrapping still needs 18.
|
||||
#[test]
|
||||
fn tight_wrap_needs_only_9pt_beside_it_before_word_2013_layout() {
|
||||
crate::test_fonts();
|
||||
use wordcraft_doc::para::Wrap;
|
||||
for wrap in [Wrap::Tight, Wrap::Through] {
|
||||
assert_eq!(empty_lines_beside(wrap, 9.1, 14), 7, "{wrap:?} 9.1");
|
||||
assert_eq!(empty_lines_beside(wrap, 8.9, 14), 0, "{wrap:?} 8.9");
|
||||
assert_eq!(empty_lines_beside(wrap, 9.1, wordcraft_doc::COMPAT_MODE_CURRENT), 0, "{wrap:?} 9.1 in mode 15");
|
||||
}
|
||||
assert_eq!(empty_lines_beside(Wrap::Square, 17.9, 14), 0);
|
||||
assert_eq!(empty_lines_beside(Wrap::Square, 18.1, 14), 7);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn contour_wrap_turns_with_the_object() {
|
||||
crate::test_fonts();
|
||||
|
||||
@@ -84,7 +84,7 @@ Exact line spacing keeps the run font baseline around tall equations; automatic
|
||||
| Shape fills: gradients and transparency | 🟡 | #1500: linear (angle, `scaled`) and circular gradients and transparent fills drawn on screen, PNG and PDF (axial/radial shadings), soft edges fading the real fill; rectangular and shape-following path gradients drawn circular, `tileRect`/`flip` not drawn, outline gradients drawn in their middle colour, `rotWithShape="0"` drawn as turning with the shape | 2–4 |
|
||||
| Text wrap: square, top-and-bottom, behind, in front | ✅ | 2026-10-06; beside an object, a line's first word that doesn't fit the strip goes on whole to the row's next strip or the next row, instead of being split (#1376, `layout::tests::a_word_too_wide_for_the_strip_beside_a_float_moves_on_whole`; inferred from a reporter's comparison, not yet measured in Word) a paragraph running on into the next column or page is broken again there around that column's shapes, its own floating objects left where they are (#1374). Text in an earlier column doesn't yet wrap around a shape anchored in a later one (#1158) | #884: an object dragged on a multi-column page anchors to a paragraph in the column it lands in, so that column's text wraps around it. Text laid out before the anchor (an earlier column) doesn't yet wrap around an object anchored later on the page, nor do lines a paragraph continues into the next column (broken once, in the column it starts in) |
|
||||
| Text wrap: square, top-and-bottom, behind, in front | ✅ | 2026-10-06; beside an object, a line's first word that doesn't fit the strip goes on whole to the row's next strip or the next row, instead of being split (#1376, `layout::tests::a_word_too_wide_for_the_strip_beside_a_float_moves_on_whole`; inferred from a reporter's comparison, not yet measured in Word) a paragraph running on into the next column or page is broken again there around that column's shapes, its own floating objects left where they are (#1374). Text in an earlier column doesn't yet wrap around a shape anchored in a later one (#1158) | #884: an object dragged on a multi-column page anchors to a paragraph in the column it lands in, so that column's text wraps around it. Paragraphs above an object's anchor wrap around it when it is placed higher up the page (the page is laid out again with it known from the start, #2048; when that wrap pushes the anchor onto the next page, the first page keeps the room and the object goes with its anchor, and a layout that still hasn't settled moves the object down to its paragraph rather than over text); text in an earlier column beside it doesn't yet, nor do lines a paragraph continues into the next column (broken once, in the column it starts in) |
|
||||
| Text wrap: tight, through (contour, wrap polygon) | 🟡 | #354: lines follow the wrap polygon, or the outline worked out from the object (shape geometry; a picture's opaque pixels as a convex hull; otherwise the rectangle), turned and flipped with it, kept the left/right distance from text; Through also uses gaps inside the outline. Wrap side (`wrapText`: both sides, left only, right only, largest side per line) applies to square, tight and through wraps, turned objects included; picture outlines are convex; a picture is decoded once for all its crops, pictures whose header says they are opaque are not decoded, and at most 2^28 pixels per layout are decoded (later pictures wrap as rectangles in that layout, #3692); not compared page-for-page with Word | 1–2 |
|
||||
| Text wrap: tight, through (contour, wrap polygon) | 🟡 | #354: lines follow the wrap polygon, or the outline worked out from the object (shape geometry; a picture's opaque pixels as a convex hull; otherwise the rectangle), turned and flipped with it, kept the left/right distance from text; Through also uses gaps inside the outline. Wrap side (`wrapText`: both sides, left only, right only, largest side per line) applies to square, tight and through wraps, turned objects included; picture outlines are convex; a picture is decoded once for all its crops, pictures whose header says they are opaque are not decoded, and at most 2^28 pixels per layout are decoded (later pictures wrap as rectangles in that layout, #3692); a line goes beside a floating picture or shape (square, tight or through) when the gap from the column edge to its wrap area is at least 18pt, beside a tight or through one before Word 2013 layout at least 9pt, beside a floating table at least 20pt (measured in Word 16, 0.05pt steps, #6316, `layout::tests::text_goes_beside_a_float_in_an_18pt_gap`); not yet: square wrapping's effect extent (#6352), the gap measured from the column edge rather than the indent (#6353), floating tables' 18.55pt (#6356); not compared page-for-page with Word | 1–2 |
|
||||
| Text boxes, overflow, linked text boxes | ✅ | #46; linked text boxes (#369): the text runs on through each box in turn at that box's line length, overflow past the last box hidden; Align Text top / middle / bottom; the box's own internal margins, and a box set to Resize shape to fit text shows all its text (#743); a chain's story is laid out at no more than 16 box widths (told apart to a twip), later boxes needing another taking the nearest one in their text direction (#3692) | — |
|
||||
| Rotated objects and text | 🟡 | #332: pictures, shapes, charts and groups drawn turned and flipped about their centre (screen and PDF); square wrap and inline lines keep clear of the rotated bounds — unless the file keeps no room for the turn (no or a zero `wp:effectExtent`): then an inline one's line keeps to its frame, exchanged in width and height from 45° to 135° and 225° to 315° in Word 2013+ layout, and the picture overhangs it, cut at the line's top and bottom, as in Word; hit testing on the turned shape. Text in a rotated text box turns with it (on screen, PNG and PDF; upside down when the box is flipped across, never mirrored, as Word draws it); clicks and the caret in it still go by its upright text | 1–2 |
|
||||
| Connector lookup cost | 🟡 | One temporary layout-object index per reroute replaces repeated page scans. Repeated positions retain page-hint preference, first-match order and first-page fallback; same-page glue and free/unresolved endpoints are unchanged. Synthetic lookup equivalence, geometry and 8,000-page scaling regressions; model object access and obstacle routing remain separate, no new native Word comparison | #3631 |
|
||||
@@ -345,6 +345,7 @@ The front-of-text opt-out is retained from the earlier implementation; this patc
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-11 | trivial | A line goes beside a floating picture or shape when the gap between the column edge and its wrap area is at least 18pt (square, tight and through; was 20pt), and beside a tight or through one at least 9pt before Word 2013 layout (compatibility mode 14 and below), as measured in Word; floating tables keep 20pt. A tight-wrapped cover whose empty paragraphs fit in a 19.15pt gap is one page again, not three (#6316, `layout::tests::text_goes_beside_a_float_in_an_18pt_gap`, `layout::tests::tight_wrap_needs_only_9pt_beside_it_before_word_2013_layout`) |
|
||||
| 2026-11-09 | trivial | A footnote continuing on the next page ends on the bottom margin (footnotes at the page bottom) of the page it starts on, the room left going above the separator, and widow/orphan control in its paragraph keeps two of its lines on either side of the split where one fits; a page's first note otherwise splits anyway (the line with the reference goes on to the next page rather than leave the note's first line alone under it), as measured in Word for Mac 16.114.4 (`layout::tests::a_footnote_continuing_on_the_next_page_ends_on_the_bottom_margin`, `widow_control_leaves_two_lines_of_a_split_footnote_on_the_next_page`, `orphan_control_keeps_two_lines_of_a_split_footnote_with_its_reference`) |
|
||||
| 2026-11-14 | trivial | A left tab past the right indent that wraps into a span beside a floating object goes on to the first line clear of the object, its text at the indent (#6577), as the issue reports for Word; not yet checked in Word here. After 50 consecutive skipped narrowed spans the tab stops skipping and its text starts in the narrowed span. A stop inside the right indent keeps its old zero-width path. `layout::tests::left_tab_past_the_right_indent_beside_a_float_moves_clear_of_it`, `a_left_tab_inside_the_right_indent_beside_a_float_keeps_its_line` |
|
||||
| 2026-11-26 | trivial | A combining mark the font of its character can't draw (∞ with U+0338 in a font without the overlay) is drawn with that character in a face that has both (CSS Fonts 4 §5.3, cluster matching), instead of as a missing-glyph box; with no such face, the mark comes on its own from a face that has it, except in right-to-left and complex-script text, where it stays with its letter. Marks the font draws and pairs it composes (= with U+0338 as ≠) stay with their character in its font. In small capitals a mark is set at the size of the letter it belongs to, in one shaping run with it (`layout::tests::combining_marks`, #7865) |
|
||||
|
||||
Reference in New Issue
Block a user