You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.3 KiB
54 lines
1.3 KiB
package main |
|
|
|
import ( |
|
"fmt" |
|
"io/ioutil" |
|
"os" |
|
"strings" |
|
) |
|
|
|
func main() { |
|
// If we have any other number of parameters, than one |
|
if len(os.Args[1:]) != 1 { |
|
return |
|
} |
|
// Separate every line |
|
lines := strings.Split(string(os.Args[1]), "\\n") |
|
// The most stupid fix in the world, for the empty lines |
|
// This variable stores how many new lines we add to the very end |
|
newLineCount := 0 |
|
// Just remove the new lines from the very end... splitting at \n causes empty strings to occur in the slice |
|
for lines[len(lines)-1] == "" { |
|
lines = lines[:len(lines)-1] |
|
newLineCount++ |
|
} |
|
|
|
// Read in the alphabet |
|
alphabet, err := ioutil.ReadFile("standard.txt") |
|
if err != nil { |
|
return |
|
} |
|
alpha := strings.Split(string(alphabet), "\n") |
|
|
|
// Loop through the slice of lines |
|
for _, v := range lines { |
|
// Loop through the lines of the font |
|
// All the characters are made up of eight lines |
|
// Essentially, 'i' tells us which line of printing we are at |
|
for i := 0; i < 8; i++ { |
|
// Loop through the current line |
|
for _, w := range v { |
|
// Get the index of the character in the font file |
|
fmt.Print(alpha[(w-32)*9+rune(i+1)]) |
|
} |
|
// Print out a new line for the future parts of the characters |
|
fmt.Println() |
|
} |
|
} |
|
|
|
// Add the newLines to the very end of the printing |
|
for ; newLineCount > 0; newLineCount-- { |
|
fmt.Println() |
|
} |
|
|
|
}
|
|
|