add iso216 card sheets
This commit is contained in:
parent
821358ac1a
commit
a1bdaa2785
9
cards_a6_a4sheet.typ
Normal file
9
cards_a6_a4sheet.typ
Normal file
|
@ -0,0 +1,9 @@
|
|||
#{
|
||||
import "common.typ"
|
||||
|
||||
let options = json("cache/options.json")
|
||||
let cards = options.cards
|
||||
let args = options.args
|
||||
|
||||
common.iso216_a_card_sheets(4, 6, args, cards)
|
||||
}
|
65
common.typ
65
common.typ
|
@ -114,13 +114,17 @@
|
|||
)
|
||||
}
|
||||
|
||||
#let card_sheets(width, height, margin, args, cards) = {
|
||||
let content_fn = if args.no_content {
|
||||
#let get_content_fn(args) = {
|
||||
if args.no_content {
|
||||
_ => []
|
||||
} else {
|
||||
import "cache/content/content.typ"
|
||||
content.content
|
||||
}
|
||||
}
|
||||
|
||||
#let card_sheets(width, height, margin, args, cards) = {
|
||||
let content_fn = get_content_fn()
|
||||
|
||||
for (idx, card) in cards.enumerate() {
|
||||
let row = calc.rem(idx + args.skip, 2)
|
||||
|
@ -136,3 +140,60 @@
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
// It would be nice to calculate this but the rounding makes no sense,
|
||||
// hardcode it.
|
||||
#let iso216_lengths = (
|
||||
1189mm,
|
||||
841mm,
|
||||
594mm,
|
||||
420mm,
|
||||
297mm,
|
||||
210mm,
|
||||
148mm,
|
||||
105mm,
|
||||
74mm,
|
||||
52mm,
|
||||
37mm,
|
||||
26mm
|
||||
)
|
||||
|
||||
#let iso216_a_size(format) = {
|
||||
(iso216_lengths.at(format), iso216_lengths.at(format + 1))
|
||||
}
|
||||
|
||||
// Pack together smaller ISO 216 A-series cards to make a full-size card.
|
||||
// Useful to print on a large printer or plotter then use a paper cutter
|
||||
#let iso216_a_card_sheets(page_format, card_format, args, cards) = {
|
||||
let is_landscape = calc.even(card_format - page_format)
|
||||
let (num_rows, num_cols) = if is_landscape {
|
||||
let num = calc.pow(2, (card_format - page_format) / 2)
|
||||
(num, num)
|
||||
} else {
|
||||
let cols = calc.pow(2, (card_format - 1 - page_format) / 2)
|
||||
(cols * 2, cols)
|
||||
}
|
||||
|
||||
let (page_long, page_short) = iso216_a_size(page_format)
|
||||
set page(margin: 0mm, width: page_short, height: page_long, flipped: is_landscape)
|
||||
|
||||
let (card_long, card_short) = iso216_a_size(card_format)
|
||||
let content_fn = get_content_fn(args)
|
||||
|
||||
for (idx, card) in cards.enumerate() {
|
||||
if idx != 0 and calc.rem(idx + args.skip, num_rows * num_cols) == 0 {
|
||||
pagebreak()
|
||||
}
|
||||
|
||||
let offset_idx = idx + args.skip
|
||||
let col = calc.rem(offset_idx, num_cols)
|
||||
let row = calc.rem(calc.floor(offset_idx / num_cols), num_rows)
|
||||
|
||||
place(
|
||||
top + left,
|
||||
dx: col * card_long,
|
||||
dy: row * card_short,
|
||||
postcard_block(card_long, card_short, content_fn, args, card)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue