Try to align images to text

This commit is contained in:
Artemis Tosini 2023-09-24 02:55:24 +00:00
parent e569afec17
commit 08266a2b91
Signed by: artemist
GPG key ID: EE5227935FE3FF18

View file

@ -1,3 +1,34 @@
#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,
block(
width: 1in,
height: text_offset,
fill: luma(180),
)
)
place(top + left,
dy: text_offset,
block(
width: 1in,
height: 4pt,
fill: luma(160),
)
)
place(
top + left,
dx: 0.1in,
dy: text_offset + 4pt - 0.15in,
image(card.avatar, width: 0.3in)
)
})
}
#let address_content(width, height, card) = { #let address_content(width, height, card) = {
set par(leading: 0.5em) set par(leading: 0.5em)
let text_height = if card.imb == "" { let text_height = if card.imb == "" {
@ -5,6 +36,7 @@
} else { } else {
height - 1in/8 height - 1in/8
} }
place( place(
top + left, top + left,
dx: 0.5in, dx: 0.5in,
@ -14,7 +46,7 @@
fill: luma(230), fill: luma(230),
align( align(
start + horizon, start + horizon,
text(font: ("OCR-B", "Noto Emoji"), size: 8pt, card.address) address_text(card)
) )
) )
) )
@ -34,12 +66,7 @@
) )
} }
if card.avatar != "" { if card.avatar != "" {
place( place_avatar(text_height, card)
top + left,
dx: 0.1in,
dy: 0.1in,
image(card.avatar, width: 0.3in)
)
} }
} }