typstcard/common.typ

104 lines
1.9 KiB
Plaintext

#let address_text(card) = {
text(font: ("OCR-B", "Noto Emoji"), size: 8pt, card.address)
}
#let place_avatar(text_height, card) = {
style(styles => {
let text_offset = (text_height - measure(address_text(card), styles).height) / 2
place(
top + left,
dx: 0.1in,
dy: calc.max(text_offset + 4pt - 0.15in, 0pt),
image(card.avatar, width: 0.3in)
)
})
}
#let address_content(width, height, card) = {
set par(leading: 0.5em)
let text_height = if card.imb == "" {
height
} else {
height - 1in/8
}
place(
top + left,
dx: 0.5in,
block(
width: width - 0.5in,
height: text_height,
align(
start + horizon,
address_text(card)
)
)
)
if card.imb != "" {
place(
top + left,
dy: height - 1in/8,
block(
width: 100%,
height: 1in/8,
align(
top + center,
text(font: "USPSIMBCompact", size: 12pt, card.imb)
)
)
)
}
if card.avatar != "" {
place_avatar(text_height, card)
}
}
#let address_block(width, height, card) = {
block(
width: width,
height: height,
breakable: false,
address_content(width, height, card)
)
}
#let postcard_content(width, height, content_fn, card) = {
// Content block
place(
top + left,
dx: 1in/8,
dy: 1in/8,
block(
width - 2.75in,
height - 0.25in,
breakable: false,
content_fn(card)
)
)
// Stamp placement guide
place(
top + right,
dx: -0.75in,
dy: 0.25in,
image("nixowos.png", width: 0.5in)
)
// Address block
place(
horizon + right,
dx: -2in - 5in/8,
address_block(2.5in, 1in, card)
)
}
#let postcard_block(width, height, content_fn, card) = {
block(
width: width,
height: height,
breakable: false,
postcard_content(width, height, content_fn, card)
)
}