bootloader: drop side borders; even top/bottom rules around wordmark
The side box borders looked crooked: the wordmark's letters end at a different column each row (a naturally ragged right edge), so the gap before the right `|` varied row to row even though the pipe column was constant. Replace the boxed frame with the wordmark block centered by its widest row and bracketed by two horizontal rules of that exact width. A solid repeated rule is always even, and with no side borders the ragged letter edge is never framed. Width is now computed from the wordmark at runtime, so the rules and centering stay self-consistent. Verified: faithful render simulation shows identical top/bottom rules and a centered block; cargo check passes for x86_64-unknown-uefi (--bin) and x86-unknown-none (--lib). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+14
-14
@@ -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!("{}| {:<w$} |", margin, line, w = WORDMARK_W);
|
||||
println!("{}{}", margin, line);
|
||||
}
|
||||
println!("{}", border);
|
||||
println!("{}", rule);
|
||||
} else {
|
||||
// Narrow console: skip the wordmark, just center the name.
|
||||
println!("{}", center_in(w, "RedBear OS"));
|
||||
|
||||
Reference in New Issue
Block a user