70 lines
1.7 KiB
Go
70 lines
1.7 KiB
Go
package config
|
|
|
|
type Style struct {
|
|
Color string `hcl:"color,optional"`
|
|
Font string `hcl:"font,optional"`
|
|
FontSize float64 `hcl:"font_size,optional"`
|
|
Hinting string `hcl:"hinting,optional"`
|
|
DPI float64 `hcl:"dpi,optional"`
|
|
}
|
|
|
|
// Apply styles; errors are logged but don't override styles, so we don't break visuals.
|
|
/*
|
|
func (s Style) Apply(style *ui.Style) {
|
|
if s.Color != "" {
|
|
c, err := csscolorparser.Parse(s.Color)
|
|
if err != nil {
|
|
logrus.WithError(err).WithField("color", s.Color).Warn("invalid color name")
|
|
} else {
|
|
r, g, b, a := c.RGBA255()
|
|
style.Foreground = color.RGBA{r, g, b, a}
|
|
}
|
|
}
|
|
|
|
if s.Font != "" {
|
|
switch s.Font {
|
|
case "monteserrat":
|
|
style.Font = font.Montserrat
|
|
case "monaco":
|
|
style.Font = font.Monaco
|
|
case "mairy":
|
|
style.Font = font.MairyBlackItalic
|
|
case "microgrotesk":
|
|
style.Font = font.MicroGrotesk
|
|
default:
|
|
f, err := font.New(s.Font)
|
|
if err != nil {
|
|
logrus.WithError(err).WithField("font", s.Font).Warn("font failed to load")
|
|
} else {
|
|
attr := style.Font.Attr()
|
|
style.Font = f
|
|
style.Font.SetDPI(attr.DPI)
|
|
style.Font.SetHinting(attr.Hinting)
|
|
style.Font.SetLineSpacing(attr.LineSpacing)
|
|
style.Font.SetPointSize(attr.PointSize)
|
|
}
|
|
}
|
|
}
|
|
|
|
if s.FontSize > 0 {
|
|
style.Font.SetPointSize(s.FontSize)
|
|
}
|
|
|
|
if s.DPI > 0 {
|
|
style.Font.SetDPI(s.DPI)
|
|
}
|
|
|
|
switch strings.ToLower(s.Hinting) {
|
|
case "": // use default
|
|
case "none", "no", "false":
|
|
style.Font.SetHinting(font.HintingNone)
|
|
case "vertical":
|
|
style.Font.SetHinting(font.HintingVertical)
|
|
case "full", "yes":
|
|
style.Font.SetHinting(font.HintingFull)
|
|
default:
|
|
logrus.WithField("hinting", s.Hinting).Warn("font hinting invalid")
|
|
}
|
|
}
|
|
*/
|