github.com/wtfutil/wtf@v0.43.0/modules/digitalclock/fonts.go (about) 1 package digitalclock 2 3 import ( 4 "fmt" 5 "strings" 6 ) 7 8 // ClockFontInterface to makes sure all fonts implement join and get methods 9 type ClockFontInterface interface { 10 join() string 11 get() string 12 } 13 14 // ClockFont struct to hold the font info 15 type ClockFont struct { 16 fontRows int 17 fonts map[string][]string 18 } 19 20 // function to join fonts, since the fonts have multi rows 21 func fontsJoin(fontCharArray [][]string, rows int, color string) string { 22 outString := "" 23 24 for i := 0; i < rows; i++ { 25 outString += fmt.Sprintf("[%s]", color) 26 for _, charFont := range fontCharArray { 27 outString += " " + fmt.Sprintf("[%s]%s", color, charFont[i]) 28 } 29 outString += "\n" 30 } 31 return strings.TrimSuffix(outString, "\n") 32 } 33 34 func (font *ClockFont) get(char string) []string { 35 return font.fonts[char] 36 } 37 38 func getDigitalFont() ClockFont { 39 fontsMap := map[string][]string{ 40 "1": {"▄█ ", " █ ", "▄█▄"}, 41 "2": {"█▀█", " ▄▀", "█▄▄"}, 42 "3": {"█▀▀█", " ▀▄", "█▄▄█"}, 43 "4": {" █▀█ ", "█▄▄█▄", " █ "}, 44 "5": {"█▀▀", "▀▀▄", "▄▄▀"}, 45 "6": {"▄▀▀▄", "█▄▄ ", "▀▄▄▀"}, 46 "7": {"▀▀▀█", " █ ", " ▐▌ "}, 47 "8": {"▄▀▀▄", "▄▀▀▄", "▀▄▄▀"}, 48 "9": {"▄▀▀▄", "▀▄▄█", " ▄▄▀"}, 49 "0": {"█▀▀█", "█ █", "█▄▄█"}, 50 ":": {"█", " ", "█"}, 51 " ": {" ", " ", " "}, 52 "A": {"", "", "AM"}, 53 "P": {"", "", "PM"}, 54 } 55 56 digitalFont := ClockFont{fontRows: 3, fonts: fontsMap} 57 return digitalFont 58 } 59 60 func getBigFont() ClockFont { 61 fontsMap := map[string][]string{ 62 "1": {" ┏┓ ", "┏┛┃ ", "┗┓┃ ", " ┃┃ ", "┏┛┗┓", "┗━━┛"}, 63 "2": {"┏━━━┓", "┃┏━┓┃", "┗┛┏┛┃", "┏━┛┏┛", "┃ ┗━┓", "┗━━━┛"}, 64 "3": {"┏━━━┓", "┃┏━┓┃", "┗┛┏┛┃", "┏┓┗┓┃", "┃┗━┛┃", "┗━━━┛"}, 65 "4": {"┏┓ ┏┓", "┃┃ ┃┃", "┃┗━┛┃", "┗━━┓┃", " ┃┃", " ┗┛"}, 66 "5": {"┏━━━┓", "┃┏━━┛", "┃┗━━┓", "┗━━┓┃", "┏━━┛┃", "┗━━━┛"}, 67 "6": {"┏━━━┓", "┃┏━━┛", "┃┗━━┓", "┃┏━┓┃", "┃┗━┛┃", "┗━━━┛"}, 68 "7": {"┏━━━┓", "┃┏━┓┃", "┗┛┏┛┃", " ┃┏┛", " ┃┃ ", " ┗┛ "}, 69 "8": {"┏━━━┓", "┃┏━┓┃", "┃┗━┛┃", "┃┏━┓┃", "┃┗━┛┃", "┗━━━┛"}, 70 "9": {"┏━━━┓", "┃┏━┓┃", "┃┗━┛┃", "┗━━┓┃", "┏━━┛┃", "┗━━━┛"}, 71 "0": {"┏━━━┓", "┃┏━┓┃", "┃┃ ┃┃", "┃┃ ┃┃", "┃┗━┛┃", "┗━━━┛"}, 72 ":": {" ", "┏━┓", "┗━┛", "┏━┓", "┗━┛", " "}, 73 " ": {" ", " ", " ", " ", " ", " "}, 74 "A": {"", "", "", "", "", "AM"}, 75 "P": {"", "", "", "", "", "PM"}, 76 } 77 78 bigFont := ClockFont{fontRows: 6, fonts: fontsMap} 79 return bigFont 80 } 81 82 // getFont returns appropriate font map based on the font settings 83 func getFont(widgetSettings Settings) ClockFont { 84 if strings.ToLower(widgetSettings.font) == "digitalfont" { 85 return getDigitalFont() 86 } 87 return getBigFont() 88 }