A Go-based ASCII Art Generator that converts input text into ASCII art using customizable font files. This project demonstrates modular programming in Go and handles edge cases like newlines, empty input, and multiple font styles.
- Convert any text into ASCII art using a selected font (
shadow.txt,standard.txt,thinkertoy.txt). - Handles multi-line input using
\n. - Handles empty input and single newline inputs.
- Modular Go design:
main.go– orchestrates the programreadfont.go– reads the ASCII font fileparseinput.go– processes input into words/linesparseascii.go– loops through words and prints ASCIIprintword.go– prints each word character by character
ascii-art-project/
├── main.go
├── asciiart/
│ ├── readfont.go
│ ├── parseinput.go
│ ├── parseascii.go
│ └── printword.go
├── standard.txt
├── thinkertoy.txt
├── shadow.txt
└── README.mdBy default, the program reads standard.txt:
go run . "Hello"You can switch fonts by changing the file in ReadFont in main.go:
fileLines, err := asciiart.ReadFont("thinkertoy.txt")or
fileLines, err := asciiart.ReadFont("shadow.txt")- Single word:
go run . "Hello" | cat -eOutput:
_ _ _ _ $
| | | | | | | | $
| |__| | ___ | | | | ___ $
| __ | / _ \ | | | | / _ \ $
| | | | | __/ | | | | | (_) | $
|_| |_| \___| |_| |_| \___/ $
$
$
$
- Multi-line input using
\n:
go run . "Hello\nThere" | cat -eOutput:
_ _ _ _ $
| | | | | | | | $
| |__| | ___ | | | | ___ $
| __ | / _ \ | | | | / _ \ $
| | | | | __/ | | | | | (_) | $
|_| |_| \___| |_| |_| \___/ $
$
$
_______ _ $
|__ __| | | $
| | | |__ ___ _ __ ___ $
| | | _ \ / _ \ | '__| / _ \ $
| | | | | | | __/ | | | __/ $
|_| |_| |_| \___| |_| \___| $
$
$
- Empty input:
go run . "" | cat -eOutput:
- Single newline input:
go run . "\n" | cat -eOutput:
$
main.goreads the input from the command line.readfont.goloads the selected ASCII font file and splits it into lines.parseinput.goconverts the input string into words/lines, handling literal\n.parseascii.goloops through each word and prints its ASCII representation or a blank line if empty.printword.goprints each character row by row using the font file.
- Each font file contains all printable ASCII characters.
- Each character is 8 lines tall + 1 empty line, forming a 9-line block.
- The program maps each character to the correct block using:
asciiIndex := int(char) - 32
start := asciiIndex * 9- Changing the font file changes the style of ASCII art output.
- Learn modular programming in Go
- Practice file I/O and string manipulation
- Handle edge cases like empty input and newlines
- Build a reusable ASCII Art generator with multiple font styles