Created
February 18, 2018 14:50
-
-
Save hajimehoshi/72e6982596f6ed2e6333dd778a87f752 to your computer and use it in GitHub Desktop.
Red Text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"image/color" | |
"github.com/golang/freetype/truetype" | |
"github.com/hajimehoshi/ebiten" | |
"github.com/hajimehoshi/ebiten/text" | |
"golang.org/x/image/font" | |
"golang.org/x/image/font/gofont/goregular" | |
) | |
var regularFont font.Face | |
func init() { | |
tt, err := truetype.Parse(goregular.TTF) | |
if err != nil { | |
panic(err) | |
} | |
regularFont = truetype.NewFace(tt, &truetype.Options{ | |
Size: 24, | |
DPI: 72, | |
Hinting: font.HintingFull, | |
}) | |
if err != nil { | |
panic(err) | |
} | |
} | |
func update(screen *ebiten.Image) error { | |
screen.Fill(color.White) | |
text.Draw(screen, "dead", regularFont, 32, 32, color.RGBA{0x80, 0, 0, 0xff}) | |
return nil | |
} | |
func main() { | |
if err := ebiten.Run(update, 640, 480, 1, "Font Test"); err != nil { | |
panic(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment