diff --git a/paper/src/graphics/banner.png b/paper/src/graphics/banner.png index 232186e..992202e 100644 Binary files a/paper/src/graphics/banner.png and b/paper/src/graphics/banner.png differ diff --git a/paper/src/graphics/banner.py b/paper/src/graphics/banner.py index 4b77f43..4228362 100644 --- a/paper/src/graphics/banner.py +++ b/paper/src/graphics/banner.py @@ -1,14 +1,24 @@ from PIL import Image, ImageDraw, ImageFont text = open("banner.txt", "r", encoding="utf-8").read() -font = ImageFont.truetype("DejaVuSansMono.ttf", 18) -dummy = Image.new("RGB", (1, 1)) +scale = 4 # 2–6 is typical +pad = 10 +font_px = 18 + +font = ImageFont.truetype("DejaVuSansMono.ttf", font_px * scale) + +# Measure at high res +dummy = Image.new("RGB", (1, 1), "white") d = ImageDraw.Draw(dummy) -bbox = d.multiline_textbbox((0,0), text, font=font) -w, h = bbox[2]-bbox[0], bbox[3]-bbox[1] +bbox = d.multiline_textbbox((0, 0), text, font=font) +w, h = bbox[2] - bbox[0], bbox[3] - bbox[1] -img = Image.new("RGB", (w+20, h+20), "white") -d = ImageDraw.Draw(img) -d.multiline_text((10,10), text, font=font, fill="black") -img.save("banner.png") +# Render at high res +hi = Image.new("RGB", (w + 2*pad*scale, h + 2*pad*scale), "white") +d = ImageDraw.Draw(hi) +d.multiline_text((pad*scale, pad*scale), text, font=font, fill="black") + +# Downscale with a good filter +out = hi.resize((hi.width // scale, hi.height // scale), resample=Image.Resampling.LANCZOS) +out.save("banner.png", dpi=(300, 300))