diff --git a/fonts/fonts.go b/fonts/fonts.go index 71f0af2..eae68cc 100644 --- a/fonts/fonts.go +++ b/fonts/fonts.go @@ -10,3 +10,11 @@ var Regular []byte //go:embed ttf/OpenSans-Italic.ttf var Italic []byte + +//go:embed ttf/Phosphor.ttf +var Icons []byte + +const ( + IconXOffset = 38 + IconYOffset = 2 +) diff --git a/fonts/ttf/Phosphor.ttf b/fonts/ttf/Phosphor.ttf new file mode 100644 index 0000000..7c1b8a7 Binary files /dev/null and b/fonts/ttf/Phosphor.ttf differ diff --git a/img.go b/img.go index 1b5eae8..8696690 100644 --- a/img.go +++ b/img.go @@ -6,6 +6,7 @@ import ( "fmt" "github.com/Crocmagnon/display-epaper/epd" "github.com/Crocmagnon/display-epaper/fete" + "github.com/Crocmagnon/display-epaper/fonts" "github.com/Crocmagnon/display-epaper/home_assistant" "github.com/Crocmagnon/display-epaper/quotes" "github.com/Crocmagnon/display-epaper/transports" @@ -209,7 +210,15 @@ func drawVelov(gc *draw2dimg.GraphicContext, station *transports.Station, yOffse } text(gc, station.Name, 23, rightX, yOffset, fontBold) - text(gc, fmt.Sprintf("V : %v - P : %v", station.BikesAvailable, station.DocksAvailable), 22, rightX, yOffset+30, fontRegular) + + yOffset += 30 + + text(gc, "\uE0D6", 22, rightX, yOffset+fonts.IconYOffset, fontIcons) // bike icon + text(gc, strconv.Itoa(station.BikesAvailable), 22, rightX+fonts.IconXOffset, yOffset, fontRegular) + + nextCol := rightX + 100.0 + text(gc, "\uEC08", 22, nextCol, yOffset+fonts.IconYOffset, fontIcons) // parking icon + text(gc, strconv.Itoa(station.DocksAvailable), 22, nextCol+fonts.IconXOffset, yOffset, fontRegular) } func drawDate(gc *draw2dimg.GraphicContext, now time.Time) { @@ -232,7 +241,8 @@ func drawTCL(gc *draw2dimg.GraphicContext, passages *transports.Passages, yoffse for i, passage := range passages.Passages { x := float64(rightX + i*120) - text(gc, passage.Ligne, 23, x, yoffset, fontBold) + text(gc, "\uE106", 23, x, yoffset+fonts.IconYOffset, fontIcons) + text(gc, passage.Ligne, 23, x+fonts.IconXOffset, yoffset, fontBold) for j, delay := range passage.Delays { y := yoffset + float64(j+1)*35 text(gc, delay, 22, x, y, fontRegular) diff --git a/main.go b/main.go index 2baf8da..84c17df 100644 --- a/main.go +++ b/main.go @@ -19,6 +19,7 @@ const ( fontRegular = "regular" fontBold = "bold" fontItalic = "italic" + fontIcons = "icons" ) func main() { @@ -30,6 +31,7 @@ func main() { loadFont(ctx, fontCache, fonts.Regular, fontRegular) loadFont(ctx, fontCache, fonts.Bold, fontBold) loadFont(ctx, fontCache, fonts.Italic, fontItalic) + loadFont(ctx, fontCache, fonts.Icons, fontIcons) draw2d.SetFontCache(fontCache)