mirror of
https://github.com/storytold/wordcraft.git
synced 2026-12-04 22:49:54 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e4cb5809f |
Generated
+1
@@ -9358,6 +9358,7 @@ name = "wordcraft-pdf"
|
||||
version = "0.18.1"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"craft",
|
||||
"craft-metafile",
|
||||
"craft-pdf",
|
||||
"hayro-cmap",
|
||||
|
||||
@@ -13,6 +13,7 @@ wordcraft-doc = { workspace = true }
|
||||
wordcraft-geom = { workspace = true, features = ["image"] }
|
||||
wordcraft-fonts = { workspace = true }
|
||||
wordcraft-layout = { workspace = true }
|
||||
craft = { workspace = true, features = ["pages"] }
|
||||
craft-metafile = { workspace = true }
|
||||
craft-pdf = { workspace = true }
|
||||
kurbo = { workspace = true }
|
||||
|
||||
@@ -86,15 +86,12 @@ impl Imposition {
|
||||
};
|
||||
let ordered: Vec<Option<usize>> = match self {
|
||||
Self::Booklet { reverse } => {
|
||||
let padded = pages.len().div_ceil(4) * 4;
|
||||
let mut out = Vec::with_capacity(padded);
|
||||
for side in 0..padded / 2 {
|
||||
let pair = if side % 2 == 0 { [padded - 1 - side, side] } else { [side, padded - 1 - side] };
|
||||
for index in if reverse { [pair[1], pair[0]] } else { pair } {
|
||||
out.push(pages.get(index).copied());
|
||||
}
|
||||
}
|
||||
out
|
||||
use craft::pages::imposition::{Binding, booklet_sheets};
|
||||
let binding = if reverse { Binding::Right } else { Binding::Left };
|
||||
booklet_sheets(pages.len(), binding)
|
||||
.flat_map(|sheet| sheet.front.into_iter().chain(sheet.back))
|
||||
.map(|slot| slot.map(|i| pages[i]))
|
||||
.collect()
|
||||
}
|
||||
_ => pages.iter().copied().map(Some).collect(),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user