mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-23 17:32:02 +01:00
examples/blocks: Use golang.org/x/image/font/opentype
This change also adds a new font "Press Start 2P". Updates #484
This commit is contained in:
parent
7b0e15cfc8
commit
c9af0e9bd4
@ -19,8 +19,8 @@ import (
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/freetype/truetype"
|
||||
"golang.org/x/image/font"
|
||||
"golang.org/x/image/font/opentype"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/examples/resources/fonts"
|
||||
@ -37,7 +37,7 @@ var (
|
||||
|
||||
func getArcadeFonts(scale int) font.Face {
|
||||
if arcadeFonts == nil {
|
||||
tt, err := truetype.Parse(fonts.ArcadeN_ttf)
|
||||
tt, err := opentype.Parse(fonts.PressStart2P_ttf)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -45,11 +45,14 @@ func getArcadeFonts(scale int) font.Face {
|
||||
arcadeFonts = map[int]font.Face{}
|
||||
for i := 1; i <= 4; i++ {
|
||||
const dpi = 72
|
||||
arcadeFonts[i] = truetype.NewFace(tt, &truetype.Options{
|
||||
arcadeFonts[i], err = opentype.NewFace(tt, &opentype.FaceOptions{
|
||||
Size: float64(arcadeFontBaseSize * i),
|
||||
DPI: dpi,
|
||||
Hinting: font.HintingFull,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return arcadeFonts[scale]
|
||||
|
@ -46,3 +46,12 @@ THESE FONTS ARE PROVIDED "AS IS" WITHOUT WARRANTY.
|
||||
|
||||
http://mplus-fonts.sourceforge.jp/mplus-outline-fonts/
|
||||
```
|
||||
|
||||
## PressStart2P-vaV7.ttf
|
||||
|
||||
```
|
||||
Copyright (c) 2011, Cody "CodeMan38" Boisclair (cody@zone38.net),
|
||||
with Reserved Font Name "Press Start".
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
```
|
||||
|
5
examples/resources/fonts/pressstart2p.go
Normal file
5
examples/resources/fonts/pressstart2p.go
Normal file
File diff suppressed because one or more lines are too long
BIN
examples/resources/fonts/pressstart2p.ttf
Normal file
BIN
examples/resources/fonts/pressstart2p.ttf
Normal file
Binary file not shown.
@ -18,6 +18,7 @@
|
||||
//go:generate file2byteslice -package=audio -input=./audio/ragtime.ogg -output=./audio/ragtime.go -var=Ragtime_ogg
|
||||
//go:generate file2byteslice -package=fonts -input=./fonts/arcade_n.ttf -output=./fonts/arcaden.go -var=ArcadeN_ttf
|
||||
//go:generate file2byteslice -package=fonts -input=./fonts/mplus-1p-regular.ttf -output=./fonts/mplus1pregular.go -var=MPlus1pRegular_ttf
|
||||
//go:generate file2byteslice -package=fonts -input=./fonts/pressstart2p.ttf -output=./fonts/pressstart2p.go -var=PressStart2P_ttf
|
||||
//go:generate file2byteslice -package=images -input=./images/ebiten.png -output=./images/ebiten.go -var=Ebiten_png
|
||||
//go:generate file2byteslice -package=images -input=./images/fiveyears.jpg -output=./images/fiveyears.go -var=FiveYears_jpg
|
||||
//go:generate file2byteslice -package=images -input=./images/gophers.jpg -output=./images/gophers.go -var=Gophers_jpg
|
||||
|
Loading…
Reference in New Issue
Block a user