From 1d1c0d61391fa722926b0be289792148c7232b1c Mon Sep 17 00:00:00 2001 From: Artemis Tosini Date: Sat, 30 Sep 2023 22:34:36 +0000 Subject: [PATCH] Add postcard and postcard small templates --- cards_lettersheet.typ | 12 +++++++++++ cards_small_lettersheet.typ | 12 +++++++++++ common.typ | 40 +++++++++++++++++++++++++++++++++---- format.py | 7 +++++++ 4 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 cards_lettersheet.typ create mode 100644 cards_small_lettersheet.typ diff --git a/cards_lettersheet.typ b/cards_lettersheet.typ new file mode 100644 index 0000000..3010280 --- /dev/null +++ b/cards_lettersheet.typ @@ -0,0 +1,12 @@ +#{ + set page("us-letter", margin: 0em) + + import "common.typ" + + let options = json("options.json") + let cards = options.cards + let args = options.args + + common.card_sheets(6in, 4in, 1in/16, args, cards) + +} diff --git a/cards_small_lettersheet.typ b/cards_small_lettersheet.typ new file mode 100644 index 0000000..8ff3e18 --- /dev/null +++ b/cards_small_lettersheet.typ @@ -0,0 +1,12 @@ +#{ + set page("us-letter", margin: 0em) + + import "common.typ" + + let options = json("options.json") + let cards = options.cards + let args = options.args + + common.card_sheets(149mm, 99mm, 1in/16, args, cards) + +} diff --git a/common.typ b/common.typ index 611133c..b1ab389 100644 --- a/common.typ +++ b/common.typ @@ -70,8 +70,8 @@ dx: 1in/8, dy: 1in/8, block( - width - 2.75in, - height - 0.25in, + width: width - 2in - 7in/8, + height: height - 0.25in, breakable: false, content_fn(card) ) @@ -80,7 +80,7 @@ // Stamp placement guide place( top + right, - dx: -0.75in, + dx: -0.25in, dy: 0.25in, image("nixowos.png", width: 0.5in) ) @@ -88,7 +88,7 @@ // Address block place( horizon + right, - dx: -2in - 5in/8, + dx: -1in/8, address_block(2.5in, 1in, card) ) } @@ -101,3 +101,35 @@ postcard_content(width, height, content_fn, card) ) } + +#let postcard_square(width, height, margin, content_fn, card) = { + rect( + width: width + margin * 2, + height: height + margin * 2, + inset: margin, + postcard_block(width, height, content_fn, card) + ) +} + +#let card_sheets(width, height, margin, args, cards) = { + let content_fn = if args.no_content { + _ => [] + } else { + import "content/content.typ" + content.content + } + + for (idx, card) in cards.enumerate() { + let row = calc.rem(idx + args.skip, 2) + if idx != 0 and row == 0 { + pagebreak() + } + + place( + top + left, + dx: 50% - width / 2 - margin, + dy: 25% - height / 2 - margin + 50% * row, + postcard_square(width, height, margin, content_fn, card) + ) + } +} diff --git a/format.py b/format.py index 20c14dd..7da2d72 100755 --- a/format.py +++ b/format.py @@ -107,6 +107,13 @@ parser.add_argument( help="CSV file containing addresses", ) +parser.add_argument( + "-n", + "--no-content", + action="store_true", + help="Skip content, e.g. to make postcard back labels" +) + args = parser.parse_args() root = ET.parse(