diff --git a/iso/builder/config/hooks/normal/9001-wallpaper.hook.chroot b/iso/builder/config/hooks/normal/9001-wallpaper.hook.chroot index 1342dc8..d8afe6b 100755 --- a/iso/builder/config/hooks/normal/9001-wallpaper.hook.chroot +++ b/iso/builder/config/hooks/normal/9001-wallpaper.hook.chroot @@ -10,20 +10,15 @@ import os W, H = 1920, 1080 -GLYPHS = { - 'E': ["11111", "10000", "11110", "10000", "10000", "10000", "11111"], - 'A': ["01110", "10001", "10001", "11111", "10001", "10001", "10001"], - 'S': ["01111", "10000", "10000", "01110", "00001", "00001", "11110"], - 'Y': ["10001", "10001", "01010", "00100", "00100", "00100", "00100"], - 'B': ["11110", "10001", "10001", "11110", "10001", "10001", "11110"], - '-': ["00000", "00000", "11111", "00000", "00000", "00000", "00000"], -} - -TITLE = "EASY-BEE" -SUBTITLE = "Hardware Audit LiveCD" -CELL = 30 -GLYPH_GAP = 18 -ROW_GAP = 6 +ASCII_ART = [ + " ███████╗ █████╗ ███████╗██╗ ██╗ ██████╗ ███████╗███████╗", + " ██╔════╝██╔══██╗██╔════╝╚██╗ ██╔╝ ██╔══██╗██╔════╝██╔════╝", + " █████╗ ███████║███████╗ ╚████╔╝ █████╗██████╔╝█████╗ █████╗", + " ██╔══╝ ██╔══██║╚════██║ ╚██╔╝ ╚════╝██╔══██╗██╔══╝ ██╔══╝", + " ███████╗██║ ██║███████║ ██║ ██████╔╝███████╗███████╗", + " ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═════╝ ╚══════╝╚══════╝", +] +SUBTITLE = " Hardware Audit LiveCD" FG = (0xF6, 0xD0, 0x47) FG_DIM = (0xD4, 0xA9, 0x1C) @@ -31,6 +26,12 @@ SHADOW = (0x5E, 0x47, 0x05) SUB = (0x96, 0x7A, 0x17) BG = (0x05, 0x05, 0x05) +MONO_FONT_CANDIDATES = [ + '/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf', + '/usr/share/fonts/truetype/liberation2/LiberationMono-Bold.ttf', + '/usr/share/fonts/truetype/liberation/LiberationMono-Bold.ttf', + '/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', +] SUB_FONT_CANDIDATES = [ '/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf', '/usr/share/fonts/truetype/liberation2/LiberationSans-Bold.ttf', @@ -39,43 +40,34 @@ SUB_FONT_CANDIDATES = [ ] -def load_font(size): - for path in SUB_FONT_CANDIDATES: +def load_font(candidates, size): + for path in candidates: if os.path.exists(path): return ImageFont.truetype(path, size) return ImageFont.load_default() -def glyph_width(ch): - return len(GLYPHS[ch][0]) +def mono_metrics(font): + probe = Image.new('L', (W, H), 0) + draw = ImageDraw.Draw(probe) + char_w = int(round(draw.textlength("M", font=font))) + bb = draw.textbbox((0, 0), "Mg", font=font) + char_h = bb[3] - bb[1] + return char_w, char_h -def render_logo_mask(): - width_cells = 0 - for idx, ch in enumerate(TITLE): - width_cells += glyph_width(ch) - if idx != len(TITLE) - 1: - width_cells += 1 - mask_w = width_cells * CELL + (len(TITLE) - 1) * GLYPH_GAP - mask_h = 7 * CELL + 6 * ROW_GAP - mask = Image.new('L', (mask_w, mask_h), 0) +def render_ascii_mask(font, lines, char_w, char_h, line_gap): + width = max(len(line) for line in lines) * char_w + height = len(lines) * char_h + line_gap * (len(lines) - 1) + mask = Image.new('L', (width, height), 0) draw = ImageDraw.Draw(mask) - - cx = 0 - for idx, ch in enumerate(TITLE): - glyph = GLYPHS[ch] - for row_idx, row in enumerate(glyph): - for col_idx, cell in enumerate(row): - if cell != '1': - continue - x0 = cx + col_idx * CELL - y0 = row_idx * (CELL + ROW_GAP) - x1 = x0 + CELL - 4 - y1 = y0 + CELL - 4 - draw.rounded_rectangle((x0, y0, x1, y1), radius=4, fill=255) - cx += glyph_width(ch) * CELL - if idx != len(TITLE) - 1: - cx += CELL + GLYPH_GAP + for row, line in enumerate(lines): + y = row * (char_h + line_gap) + for col, ch in enumerate(line): + if ch == ' ': + continue + x = col * char_w + draw.text((x, y), ch, font=font, fill=255) return mask @@ -90,20 +82,22 @@ glow_draw.ellipse((520, 340, 1400, 760), fill=(255, 190, 40, 36)) glow = glow.filter(ImageFilter.GaussianBlur(60)) img = Image.alpha_composite(img.convert('RGBA'), glow) -logo_mask = render_logo_mask() +font_logo = load_font(MONO_FONT_CANDIDATES, 64) +char_w, char_h = mono_metrics(font_logo) +logo_mask = render_ascii_mask(font_logo, ASCII_ART, char_w, char_h, 8) logo_w, logo_h = logo_mask.size logo_x = (W - logo_w) // 2 -logo_y = 290 +logo_y = 270 shadow_mask = logo_mask.filter(ImageFilter.GaussianBlur(2)) img.paste(SHADOW, (logo_x + 16, logo_y + 14), shadow_mask) img.paste(FG_DIM, (logo_x + 8, logo_y + 7), logo_mask) img.paste(FG, (logo_x, logo_y), logo_mask) -font_sub = load_font(30) +font_sub = load_font(SUB_FONT_CANDIDATES, 30) sub_bb = draw.textbbox((0, 0), SUBTITLE, font=font_sub) sub_x = (W - (sub_bb[2] - sub_bb[0])) // 2 -sub_y = logo_y + logo_h + 54 +sub_y = logo_y + logo_h + 48 draw = ImageDraw.Draw(img) draw.text((sub_x + 2, sub_y + 2), SUBTITLE, font=font_sub, fill=(35, 28, 6)) draw.text((sub_x, sub_y), SUBTITLE, font=font_sub, fill=SUB)