diff --git a/fonts/fonts.go b/fonts/fonts.go new file mode 100644 index 0000000..71f0af2 --- /dev/null +++ b/fonts/fonts.go @@ -0,0 +1,12 @@ +package fonts + +import _ "embed" + +//go:embed ttf/OpenSans-Bold.ttf +var Bold []byte + +//go:embed ttf/OpenSans-Regular.ttf +var Regular []byte + +//go:embed ttf/OpenSans-Italic.ttf +var Italic []byte diff --git a/fonts/ttf/OpenSans-Bold.ttf b/fonts/ttf/OpenSans-Bold.ttf new file mode 100644 index 0000000..98c74e0 Binary files /dev/null and b/fonts/ttf/OpenSans-Bold.ttf differ diff --git a/fonts/ttf/OpenSans-Italic.ttf b/fonts/ttf/OpenSans-Italic.ttf new file mode 100644 index 0000000..29ff693 Binary files /dev/null and b/fonts/ttf/OpenSans-Italic.ttf differ diff --git a/fonts/ttf/OpenSans-Regular.ttf b/fonts/ttf/OpenSans-Regular.ttf new file mode 100644 index 0000000..67803bb Binary files /dev/null and b/fonts/ttf/OpenSans-Regular.ttf differ diff --git a/img.go b/img.go index 0e0a0f1..1b5eae8 100644 --- a/img.go +++ b/img.go @@ -136,7 +136,7 @@ func getImg(ctx context.Context, nowFunc func() time.Time, transportsClient *tra msg = quotes.GetQuote(nowFunc()) } - drawTCL(gc, bus, 55) + drawTCL(gc, bus, 45) drawTCL(gc, tram, 205) drawVelov(gc, velovRoc, 365) drawDate(gc, nowFunc()) @@ -148,7 +148,7 @@ func getImg(ctx context.Context, nowFunc func() time.Time, transportsClient *tra } func drawMsg(gc *draw2dimg.GraphicContext, quote string) { - text(gc, quote, 15, leftX, 450, fontRegular) + text(gc, quote, 15, leftX, 450, fontItalic) } @@ -166,16 +166,20 @@ func drawWeather(ctx context.Context, gc *draw2dimg.GraphicContext, wthr *weathe daily := wthr.Daily[0] dailyWeather := daily.Weather[0] - err := drawWeatherIcon(gc, dailyWeather) + err := drawWeatherIcon(gc, wthr.Current.Weather[0]) if err != nil { slog.ErrorContext(ctx, "Failed to draw weather icon", "err", err) } - text(gc, formatTemp(wthr.Current.Temp), 23, leftX, 120, fontRegular) + text(gc, formatTemp(wthr.Current.Temp), 23, leftX, 125, fontRegular) - text(gc, "max "+formatTemp(daily.Temp.Max), 18, 120, 45, fontRegular) - text(gc, fmt.Sprintf("pluie %v%%", int(math.Round(daily.Pop*100))), 18, 120, 80, fontRegular) - text(gc, dailyWeather.Description, 18, 120, 115, fontRegular) + const xAlign = 120 + const fontSize = 18 + + text(gc, "journée", fontSize, xAlign, 35, fontBold) + text(gc, "max "+formatTemp(daily.Temp.Max), fontSize, xAlign, 65, fontRegular) + text(gc, fmt.Sprintf("pluie %v%%", int(math.Round(daily.Pop*100))), fontSize, xAlign, 95, fontRegular) + text(gc, dailyWeather.Description, fontSize, xAlign, 125, fontRegular) } func drawWeatherIcon(gc *draw2dimg.GraphicContext, dailyWeather weather.Weather) error { diff --git a/main.go b/main.go index 8564afc..2baf8da 100644 --- a/main.go +++ b/main.go @@ -3,22 +3,22 @@ package main import ( "context" "github.com/Crocmagnon/display-epaper/fete" + "github.com/Crocmagnon/display-epaper/fonts" "github.com/Crocmagnon/display-epaper/home_assistant" "github.com/Crocmagnon/display-epaper/transports" "github.com/Crocmagnon/display-epaper/weather" "github.com/golang/freetype/truetype" "github.com/llgcode/draw2d" _ "golang.org/x/image/bmp" - "golang.org/x/image/font/gofont/gobold" - "golang.org/x/image/font/gofont/goregular" "log/slog" "os" "time" ) const ( - fontRegular = "goregular" - fontBold = "gobold" + fontRegular = "regular" + fontBold = "bold" + fontItalic = "italic" ) func main() { @@ -27,8 +27,9 @@ func main() { slog.InfoContext(ctx, "starting...") fontCache := MyFontCache{} - loadFont(ctx, fontCache, goregular.TTF, fontRegular) - loadFont(ctx, fontCache, gobold.TTF, fontBold) + loadFont(ctx, fontCache, fonts.Regular, fontRegular) + loadFont(ctx, fontCache, fonts.Bold, fontBold) + loadFont(ctx, fontCache, fonts.Italic, fontItalic) draw2d.SetFontCache(fontCache)