Seal dedicated float pages in the route-D builder
This commit is contained in:
1 parent
dc14761af7
commit
5c0946f990
2 files changed
+58
-2
No files matched your search
@@ -684,6 +684,21 @@ impl Engine {
|
|||||||
page_floats: current.floats.clone(),
|
page_floats: current.floats.clone(),
|
||||||
});
|
});
|
||||||
for item in &unit.items {
|
for item in &unit.items {
|
||||||
|
if !matches!(
|
||||||
|
item,
|
||||||
|
VerticalItem::Float(_)
|
||||||
|
| VerticalItem::Penalty(_)
|
||||||
|
| VerticalItem::Mark(_)
|
||||||
|
| VerticalItem::Insertion(_)
|
||||||
|
) && current.items.is_empty()
|
||||||
|
&& !current.floats.is_empty()
|
||||||
|
&& document.page_goal - used
|
||||||
|
< document.text_fraction_percent as i64 * document.page_goal / 100
|
||||||
|
{
|
||||||
|
pages.push(std::mem::replace(&mut current, Page::empty()));
|
||||||
|
used = document.top_skip;
|
||||||
|
insertion_height = 0;
|
||||||
|
}
|
||||||
match item {
|
match item {
|
||||||
VerticalItem::Rule { height, .. } => {
|
VerticalItem::Rule { height, .. } => {
|
||||||
if current.items.is_empty() {
|
if current.items.is_empty() {
|
||||||
@@ -949,6 +964,21 @@ impl Engine {
|
|||||||
page_floats: current.floats.clone(),
|
page_floats: current.floats.clone(),
|
||||||
});
|
});
|
||||||
for item in &unit.items {
|
for item in &unit.items {
|
||||||
|
if !matches!(
|
||||||
|
item,
|
||||||
|
VerticalItem::Float(_)
|
||||||
|
| VerticalItem::Penalty(_)
|
||||||
|
| VerticalItem::Mark(_)
|
||||||
|
| VerticalItem::Insertion(_)
|
||||||
|
) && current.items.is_empty()
|
||||||
|
&& !current.floats.is_empty()
|
||||||
|
&& document.page_goal - used
|
||||||
|
< document.text_fraction_percent as i64 * document.page_goal / 100
|
||||||
|
{
|
||||||
|
pages.push(std::mem::replace(&mut current, Page::empty()));
|
||||||
|
used = document.top_skip;
|
||||||
|
insertion_height = 0;
|
||||||
|
}
|
||||||
match item {
|
match item {
|
||||||
VerticalItem::Rule { height, .. } => {
|
VerticalItem::Rule { height, .. } => {
|
||||||
if current.items.is_empty() {
|
if current.items.is_empty() {
|
||||||
@@ -1330,6 +1360,32 @@ mod tests {
|
|||||||
assert_eq!(engine.layout.pages[1].items.len(), 1);
|
assert_eq!(engine.layout.pages[1].items.len(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_large_top_float_gets_a_float_page() {
|
||||||
|
let mut document = Document::new(100, Vec::new());
|
||||||
|
document.top_skip = 0;
|
||||||
|
document.units.push(Unit::float_with_content(
|
||||||
|
1,
|
||||||
|
FloatPlacement::Top,
|
||||||
|
50,
|
||||||
|
60,
|
||||||
|
vec![VerticalItem::Rule {
|
||||||
|
width: 50,
|
||||||
|
height: 60,
|
||||||
|
}],
|
||||||
|
));
|
||||||
|
document.units.push(Unit::vertical(
|
||||||
|
2,
|
||||||
|
vec![VerticalItem::Box(VerticalBox {
|
||||||
|
width: 10,
|
||||||
|
height: 10,
|
||||||
|
})],
|
||||||
|
));
|
||||||
|
let engine = Engine::layout(&document);
|
||||||
|
assert_eq!(engine.pages().len(), 2);
|
||||||
|
assert!(engine.pages()[0].items.is_empty());
|
||||||
|
assert_eq!(engine.pages()[0].floats.len(), 1);
|
||||||
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn text_fraction_keeps_a_bottom_float_off_a_mostly_empty_page() {
|
fn text_fraction_keeps_a_bottom_float_off_a_mostly_empty_page() {
|
||||||
let mut document = Document::new(
|
let mut document = Document::new(
|
||||||
|
|||||||
+2
-2
@@ -175,8 +175,8 @@ a single cost function.
|
|||||||
an interpreted token list, and cannot yet change page goals. Top `Float`
|
an interpreted token list, and cannot yet change page goals. Top `Float`
|
||||||
material is deferred to the next page when it arrives late; bottom
|
material is deferred to the next page when it arrives late; bottom
|
||||||
floats reserve height on the current page and must satisfy
|
floats reserve height on the current page and must satisfy
|
||||||
`Document.text_fraction_percent` (default 50%). Dedicated float pages are
|
`Document.text_fraction_percent` (default 50%); a page holding only floats
|
||||||
not implemented yet.
|
is sealed once it leaves less than that fraction for text.
|
||||||
- No macro state, output routine, math, fonts or PDF output in the new core yet.
|
- No macro state, output routine, math, fonts or PDF output in the new core yet.
|
||||||
- The v1 server and project API still use `src/rust_typeset` and are unchanged.
|
- The v1 server and project API still use `src/rust_typeset` and are unchanged.
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user