Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
robust image size
Browse files Browse the repository at this point in the history
  • Loading branch information
cu1ch3n committed Apr 3, 2024
1 parent bfe63b1 commit 6174987
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions lib/menu.typ
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,27 @@
#set align(center)
#let title_content = [
#title
#if title_image != none [
#v(3em)
#set image(width: column_width - 2 * frame.dx - 6em)
#title_image
]
#if update_time != none [
#v(5em)
#zh_text(10pt)[
更新于:#update_time.display("[year]年[month padding:none]月[day padding:none]日") ] \
#en_text(8pt)[
#if title_image != none {
v(3em)
let img_width = measure(title_image).width
let max_img_width = column_width - 2 * frame.dx - 6em
if img_width.pt() > max_img_width.abs.pt() {
set image(width: column_width - 2 * frame.dx - 6em)
title_image
} else {
title_image
}
}
#if update_time != none {
v(5em)
zh_text(10pt)[
更新于:#update_time.display("[year]年[month padding:none]月[day padding:none]日") ]
linebreak()
en_text(8pt)[
Updated on #update_time.display("[month repr:long] [day], [year]")]
]
}
]
#let text_dy = (page_height - measure(title_content).height) / 2 - frame.dy
#let text_dy = (page_height - measure(title_content).height) / 2 - frame.dy - 2em
#v(text_dy)
#title_content
]
Expand Down

0 comments on commit 6174987

Please sign in to comment.