-
Notifications
You must be signed in to change notification settings - Fork 15
/
style.go
106 lines (88 loc) · 2.36 KB
/
style.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package pdf
import (
"image/color"
"github.com/alecthomas/chroma/v2"
"github.com/alecthomas/chroma/v2/styles"
)
// Style is the struct to capture the styling features for text
// Size and Spacing are specified in points.
// The sum of Size and Spacing is used as line height value
// in the gofpdf API
type Style struct {
Font Font
Size float64
Spacing float64
TextColor color.Color
FillColor color.Color
// For formatting the text
format string
}
type Styles struct {
// Headings
H1 *Style
H2 *Style
H3 *Style
H4 *Style
H5 *Style
H6 *Style
// normal text
Normal *Style
// blockquote text
Blockquote *Style
// Table styling
THeader *Style
TBody *Style
// code and preformatted text
CodeFont Font
// Codeblock Chroma Theme
CodeBlockTheme *chroma.Style
// link text
LinkColor color.Color
// IndentValue float64
}
func DefaultStyles() Styles {
c := Styles{}
c.Normal = &Style{
Font: FontRoboto, Size: 12, Spacing: 3,
TextColor: color.RGBA{0, 0, 0, 0}, FillColor: color.RGBA{255, 255, 255, 0},
}
c.H1 = &Style{
Font: FontRoboto, Size: 24, Spacing: 5,
TextColor: color.RGBA{0, 0, 0, 0}, FillColor: color.RGBA{255, 255, 255, 0},
}
c.H2 = &Style{
Font: FontRoboto, Size: 22, Spacing: 5,
TextColor: color.RGBA{0, 0, 0, 0}, FillColor: color.RGBA{255, 255, 255, 0},
}
c.H3 = &Style{
Font: FontRoboto, Size: 20, Spacing: 5,
TextColor: color.RGBA{0, 0, 0, 0}, FillColor: color.RGBA{255, 255, 255, 0},
}
c.H4 = &Style{
Font: FontRoboto, Size: 18, Spacing: 5,
TextColor: color.RGBA{0, 0, 0, 0}, FillColor: color.RGBA{255, 255, 255, 0},
}
c.H5 = &Style{
Font: FontRoboto, Size: 16, Spacing: 5,
TextColor: color.RGBA{0, 0, 0, 0}, FillColor: color.RGBA{255, 255, 255, 0},
}
c.H6 = &Style{
Font: FontRoboto, Size: 14, Spacing: 5,
TextColor: color.RGBA{0, 0, 0, 0}, FillColor: color.RGBA{255, 255, 255, 0},
}
c.Blockquote = &Style{
Font: FontRoboto, Size: 14, Spacing: 1,
TextColor: color.RGBA{0, 0, 0, 0}, FillColor: color.RGBA{255, 255, 255, 0},
}
c.THeader = &Style{
Font: FontRoboto, Size: 12, Spacing: 2,
TextColor: color.RGBA{0, 0, 0, 0}, FillColor: color.RGBA{180, 180, 180, 0},
}
c.TBody = &Style{
Font: FontRoboto, Size: 12, Spacing: 2,
TextColor: color.RGBA{0, 0, 0, 0}, FillColor: color.RGBA{240, 240, 240, 0},
}
c.CodeFont = FontRobotoMono
c.CodeBlockTheme = styles.Get("monokai")
return c
}