package internal import ( "image/color" "github.com/hajimehoshi/ebiten/v2" "github.com/hajimehoshi/ebiten/v2/text" "golang.org/x/image/font" ) func drawCenteredText(img *ebiten.Image, s string, f font.Face, cx, cy int, c color.Color) { bounds, _ := font.BoundString(f, s) minX := bounds.Min.X.Round() minY := bounds.Min.Y.Round() maxX := bounds.Max.X.Round() maxY := bounds.Max.Y.Round() x, y := cx-minX-(maxX-minX)/2, cy-minY-(maxY-minY) text.Draw(img, s, f, x, y, c) }