From 96f92ddd8ea1554766b358333e911f607c3e5d6c Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 2 Jan 2026 22:39:11 +0200 Subject: add large ASCII fonts and font cycling to live mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add 4 new ASCII art fonts (mono12, rebel, ansi, ansiShadow) adapted from pomo project - Implement random font selection on startup when no font is specified - Add 'f' hotkey in live mode to cycle through fonts - Update LICENSE with MIT attribution for pomo fonts - Update README with comprehensive font documentation - Bump version to v0.3.0 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- internal/ascii/render.go | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 internal/ascii/render.go (limited to 'internal/ascii/render.go') diff --git a/internal/ascii/render.go b/internal/ascii/render.go new file mode 100644 index 0000000..eb41dd1 --- /dev/null +++ b/internal/ascii/render.go @@ -0,0 +1,47 @@ +// Package ascii provides ASCII art rendering for timer display. +// This code is adapted from https://github.com/Bahaaio/pomo +// Copyright (c) 2025 Bahaa El Deen Mohamed +// Licensed under the MIT License +package ascii + +import ( + "github.com/charmbracelet/lipgloss" +) + +// RenderNumber renders a string of digits as ASCII art using the specified font. +// The number parameter should contain only digits (0-9) and colons (:). +// Returns the ASCII art representation as a single string with properly aligned characters. +func RenderNumber(number string, font Font) string { + digits := make([]string, 0, len(number)) + + for _, digit := range number { + digits = append(digits, renderDigit(digit, font)) + } + + asciiDigits := lipgloss.JoinHorizontal(lipgloss.Top, digits...) + return asciiDigits +} + +// GetFont returns the font with the given name. +// If the font doesn't exist, it returns the default font. +func GetFont(fontName string) Font { + if font, exists := fonts[fontName]; exists { + return font + } + + return fonts[DefaultFont] +} + +// renderDigit converts a single digit character to its ASCII art representation. +// Supports digits 0-9 and colon (:). Returns empty string for unsupported characters. +func renderDigit(digit rune, font Font) string { + if digit == ':' { + return font[len(font)-1] + } + + if digit < '0' || digit > '9' { + return "" + } + + return font[digit-'0'] +} -- cgit v1.2.3