-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathfont.go
53 lines (45 loc) · 1.37 KB
/
font.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package figlet4go
// Explanation of the .flf file header
// THE HEADER LINE
//
// The header line gives information about the FIGfont. Here is an example
// showing the names of all parameters:
//
// flf2a$ 6 5 20 15 3 0 143 229 NOTE: The first five characters in
// | | | | | | | | | | the entire file must be "flf2a".
// / / | | | | | | | \
// Signature / / | | | | | \ Codetag_Count
// Hardblank / / | | | \ Full_Layout*
// Height / | | \ Print_Direction
// Baseline / \ Comment_Lines
// Max_Length Old_Layout*
//
// * The two layout parameters are closely related and fairly complex.
// (See "INTERPRETATION OF LAYOUT PARAMETERS".)
//
import (
"strings"
)
// Represents a single font
type font struct {
// Hardblank symbol
hardblank string
// Height of one char
height int
// A string for each line of the char
fontSlice []string
}
// Get a slice of strings containing the chars lines
func (f *font) getCharSlice(char rune) []string {
height := f.height
beginRow := (int(char) - 32) * height
lines := make([]string, height)
// Get the char lines of the char
for i := 0; i < height; i++ {
row := f.fontSlice[beginRow+i]
row = strings.Replace(row, "@", "", -1)
row = strings.Replace(row, f.hardblank, " ", -1)
lines[i] = row
}
return lines
}