diff --git a/src/main.rs b/src/main.rs index 2daf96cf9f..8206a3371f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -591,8 +591,9 @@ fn elf_entry(data: &[u8]) -> (u64, bool) { // ASCII wordmark (figlet "banner" — bold solid blocks, which read far better in // a low-res boot font than thin line-art). Pure ASCII so it renders identically // on the UEFI Unicode console and the VGA CP437 text console (which truncates -// each char to a byte). Keep this ASCII-only. center_in() normalizes each line -// to WORDMARK_W, so exact trailing spaces here do not matter. +// each char to a byte). Keep this ASCII-only. Rows may differ in length; the +// header centers the block by its widest row and uses no side borders, so the +// ragged right edge of the letters is never framed. const WORDMARK: &[&str] = &[ "###### ###### ####### #####", "# # ###### ##### # # ###### ## ##### # # # #", @@ -602,7 +603,6 @@ const WORDMARK: &[&str] = &[ "# # # # # # # # # # # # # # # #", "# # ###### ##### ###### ###### # # # # ####### #####", ]; -const WORDMARK_W: usize = 69; /// Return `text` centered within `width` columns, padded with spaces on both /// sides to exactly `width` characters (truncated if it does not fit). @@ -657,20 +657,20 @@ fn draw_header(os: &impl Os) { os.set_text_position(0, 0); println!(); + // Width of the widest wordmark row; the whole block is centered by this and + // bracketed by two even horizontal rules of the same width. No side borders, + // so the letters' naturally ragged right edge is never framed (which read as + // a crooked border). + let wm_w = WORDMARK.iter().map(|l| l.chars().count()).max().unwrap_or(0); os.set_text_color(TextColor::Red); - if w >= WORDMARK_W + 6 { - // A tight box hugging the wordmark, centered on screen. A full-width - // frame left the wordmark tiny inside a huge box on wide consoles. - let box_inner = WORDMARK_W + 2; // one space of padding each side - let margin = " ".repeat((w - (box_inner + 2)) / 2); - let border = format!("{}+{}+", margin, "=".repeat(box_inner)); - println!("{}", border); + if wm_w > 0 && w >= wm_w { + let margin = " ".repeat((w - wm_w) / 2); + let rule = format!("{}{}", margin, "=".repeat(wm_w)); + println!("{}", rule); for line in WORDMARK { - // Left-justify (the art is column-0 aligned); centering each line - // individually would break the letters' vertical alignment. - println!("{}| {: