forked from raykov/mdtopdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
document_style_options.go
109 lines (87 loc) · 2.27 KB
/
document_style_options.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
107
108
109
package document
import (
"strings"
"github.com/Acke0/mdtopdf/color"
)
// NewSetFontStyleOption sets new Font Style
func (d *Document) NewSetFontStyleOption(fontStyle string) func(style any) error {
return func(style any) error {
s := style.(*Style)
s.FontStyle = fontStyle
return nil
}
}
// NewAddFontStyleOption adds Font style to the current
func (d *Document) NewAddFontStyleOption(fontStyle string) func(style any) error {
return func(style any) error {
s := style.(*Style)
if strings.Contains(s.FontStyle, fontStyle) {
return nil
}
s.FontStyle += fontStyle
return nil
}
}
// NewFontFamilyOption sets Font Family
func (d *Document) NewFontFamilyOption(family string) func(style any) error {
return func(style any) error {
s := style.(*Style)
s.FontFamily = family
return nil
}
}
// NewFontSizeOption sets Font Size
func (d *Document) NewFontSizeOption(size float64) func(style any) error {
return func(style any) error {
s := style.(*Style)
s.FontSize = size
return nil
}
}
// NewTextColorOption sets Text Color
func (d *Document) NewTextColorOption(color *color.Color) func(style any) error {
return func(style any) error {
s := style.(*Style)
s.TextColor = color
return nil
}
}
// NewFillColorOption sets Fill Color
func (d *Document) NewFillColorOption(color *color.Color) func(style any) error {
return func(style any) error {
style.(*Style).FillColor = color
return nil
}
}
// NewAddMarginOption adds Left Margin
func (d *Document) NewAddMarginOption(margin float64) func(style any) error {
return func(style any) error {
s := style.(*Style)
s.LeftMargin += margin
return nil
}
}
// NewPaddingOption Adds Left Margin
func (d *Document) NewPaddingOption(padding float64) func(style any) error {
return func(style any) error {
s := style.(*Style)
s.LeftMargin = padding
return nil
}
}
// NewAddCellMarginOption adds CellMargin
func (d *Document) NewAddCellMarginOption(margin float64) func(style any) error {
return func(style any) error {
s := style.(*Style)
s.CellMargin += margin
return nil
}
}
// NewSetCellMarginOption sets CellMargin
func (d *Document) NewSetCellMarginOption(margin float64) func(style any) error {
return func(style any) error {
s := style.(*Style)
s.CellMargin = margin
return nil
}
}