@@ -21,7 +21,10 @@ import (
21
21
22
22
func stringToColor (c string ) color.RGBA {
23
23
var r , g , b , a uint8
24
- fmt .Sscanf (c , "rgba(%d,%d,%d,%d)" , & r , & g , & b , & a )
24
+ _ , err := fmt .Sscanf (c , "rgba(%d,%d,%d,%d)" , & r , & g , & b , & a )
25
+ if err != nil {
26
+ log .Fatal (err )
27
+ }
25
28
return color.RGBA {r , g , b , a }
26
29
}
27
30
@@ -43,14 +46,16 @@ type DefinitionFile struct {
43
46
}
44
47
45
48
type Resource struct {
46
- Type string `yaml:"Type"`
47
- Icon string `yaml:"Icon"`
48
- Direction string `yaml:"Direction"`
49
- Preset string `yaml:"Preset"`
50
- Align string `yaml:"Align"`
51
- FillColor string `yaml:"FillColor"`
52
- Title string `yaml:"Title"`
53
- Children []string `yaml:"Children"`
49
+ Type string `yaml:"Type"`
50
+ Icon string `yaml:"Icon"`
51
+ Direction string `yaml:"Direction"`
52
+ Preset string `yaml:"Preset"`
53
+ Align string `yaml:"Align"`
54
+ FillColor string `yaml:"FillColor"`
55
+ Title string `yaml:"Title"`
56
+ TitleColor string `yaml:"TitleColor"`
57
+ Font string `yaml:"Font"`
58
+ Children []string `yaml:"Children"`
54
59
}
55
60
56
61
type Link struct {
@@ -151,7 +156,16 @@ func main() {
151
156
resources [k ].SetBorderColor (stringToColor (border .Color ))
152
157
}
153
158
if label := def .Label ; label != nil {
154
- resources [k ].SetLabel (label .Title , stringToColor (label .Color ))
159
+ if label .Title != "" {
160
+ resources [k ].SetLabel (& label .Title , nil , nil )
161
+ }
162
+ if label .Color != "" {
163
+ c := stringToColor (label .Color )
164
+ resources [k ].SetLabel (nil , & c , nil )
165
+ }
166
+ if label .Font != "" {
167
+ resources [k ].SetLabel (nil , nil , & label .Font )
168
+ }
155
169
}
156
170
if icon := def .Icon ; icon != nil {
157
171
if def .CacheFilePath == "" {
@@ -177,7 +191,17 @@ func main() {
177
191
resources [k ].SetBorderColor (stringToColor (border .Color ))
178
192
}
179
193
if label := def .Label ; label != nil {
180
- resources [k ].SetLabel (label .Title , stringToColor (label .Color ))
194
+ if label .Title != "" {
195
+ resources [k ].SetLabel (& label .Title , nil , nil )
196
+ }
197
+ if label .Color != "" {
198
+ c := stringToColor (label .Color )
199
+ resources [k ].SetLabel (nil , & c , nil )
200
+ }
201
+ if label .Font != "" {
202
+ resources [k ].SetLabel (nil , nil , & label .Font )
203
+ }
204
+
181
205
}
182
206
if icon := def .Icon ; icon != nil {
183
207
if def .CacheFilePath == "" {
@@ -190,7 +214,14 @@ func main() {
190
214
resources [k ].LoadIcon (v .Icon )
191
215
}
192
216
if v .Title != "" {
193
- resources [k ].SetLabel (title , color.RGBA {0 , 0 , 0 , 255 })
217
+ resources [k ].SetLabel (& title , nil , nil )
218
+ }
219
+ if v .TitleColor != "" {
220
+ c := stringToColor (v .TitleColor )
221
+ resources [k ].SetLabel (nil , & c , nil )
222
+ }
223
+ if v .Font != "" {
224
+ resources [k ].SetLabel (nil , nil , & v .Font )
194
225
}
195
226
if v .Align != "" {
196
227
resources [k ].SetAlign (v .Align )
@@ -244,7 +275,7 @@ func main() {
244
275
log .Info ("Drawing" )
245
276
resources ["Canvas" ].Scale ()
246
277
resources ["Canvas" ].ZeroAdjust ()
247
- img := resources ["Canvas" ].Draw (nil )
278
+ img := resources ["Canvas" ].Draw (nil , nil )
248
279
249
280
log .Infof ("Save %s\n " , * outputfile )
250
281
f , _ := os .OpenFile (* outputfile , os .O_WRONLY | os .O_CREATE , 0600 )
0 commit comments