Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "bufio"
- "fmt"
- "os"
- "strings"
- )
- func main() {
- inputString := os.Args[1] // string
- finalString := "" // to be printed out line-by-line
- slicedString := strings.Split(inputString, "\\n") // slicing words to handle \n
- for j, words := range slicedString { // going through every word in slice
- if words == "" && j != 0 {
- fmt.Println()
- } else if words != "" {
- for i := 0; i < 8; i++ { // printing out 8 lines
- finalString = characterReader(words, i) // returns one row that includes first line of every char
- fmt.Print(finalString)
- }
- }
- }
- }
- func characterReader(lause string, i int) string { // function to find row index, join that row for every char and return it
- var line string
- var finalLine string
- for j := 0; j < len(lause); j++ { // looping a row of every char in lause
- char := lause[j]
- index := 2 + (9 * (int(char) - 32)) + i // finding starting row
- file, err := os.Open("standard.txt")
- if err != nil {
- panic(err)
- }
- reader := bufio.NewReader(file)
- // loop font file to find right row to print
- for firstLine := 1; firstLine <= index; firstLine++ {
- line, err = reader.ReadString('\n')
- if err != nil {
- break
- }
- if firstLine == index { // adding lines together
- if j == len(lause)-1 { // keeping \n if its a last char in lause
- finalLine = finalLine + line
- } else { // removing newlines to keep row in one line
- finalLine = finalLine + strings.TrimRight(line, "\n")
- }
- }
- }
- file.Close()
- }
- return finalLine
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement