Browse Source

FEATURE: Bigger font face size

master
parent
commit
3d5ed17487
  1. 28
      src/main.go
  2. 2
      src/util/font.go

28
src/main.go

@ -66,7 +66,7 @@ type Game struct {
AudioContext *audio.Context AudioContext *audio.Context
AudioPlayers map[string]*audio.Player AudioPlayers map[string]*audio.Player
ImageResources map[string]*ebiten.Image ImageResources map[string]*ebiten.Image
Font font.Face FontFace font.Face
AnimationData AnimationData AnimationData AnimationData
PassiveIncomeTicker int PassiveIncomeTicker int
} }
@ -93,8 +93,8 @@ func NewGame() *Game {
"background1": ebiten.NewImageFromImage(ImageFromFile("background_1.png")), "background1": ebiten.NewImageFromImage(ImageFromFile("background_1.png")),
"background2": ebiten.NewImageFromImage(ImageFromFile("background_2.png")), "background2": ebiten.NewImageFromImage(ImageFromFile("background_2.png")),
}, },
Font: util.NewFont(fnt, &opentype.FaceOptions{ FontFace: util.NewFace(fnt, &opentype.FaceOptions{
Size: 24, Size: 32,
DPI: 72, DPI: 72,
Hinting: font.HintingVertical, Hinting: font.HintingVertical,
}), }),
@ -275,9 +275,9 @@ func (g *Game) Draw(screen *ebiten.Image) {
text.Draw( text.Draw(
screen, screen,
msg, msg,
g.Font, g.FontFace,
10, 10,
30, g.FontFace.Metrics().Height.Ceil(),
color.White, color.White,
) )
@ -286,9 +286,9 @@ func (g *Game) Draw(screen *ebiten.Image) {
text.Draw( text.Draw(
screen, screen,
msg, msg,
g.Font, g.FontFace,
screen.Bounds().Dx()-len(msg)*19, 10,
30, g.FontFace.Metrics().Height.Ceil()*2,
color.White, color.White,
) )
@ -297,10 +297,9 @@ func (g *Game) Draw(screen *ebiten.Image) {
text.Draw( text.Draw(
screen, screen,
msg, msg,
g.Font, g.FontFace,
10, 10,
// screen.Bounds().Dy()-30, screen.Bounds().Dy()-g.FontFace.Metrics().Height.Ceil()*2,
screen.Bounds().Dy()-24*2,
color.White, color.White,
) )
@ -309,10 +308,9 @@ func (g *Game) Draw(screen *ebiten.Image) {
text.Draw( text.Draw(
screen, screen,
msg, msg,
g.Font, g.FontFace,
// screen.Bounds().Dx()-len(msg)*17,
10, 10,
screen.Bounds().Dy()-24, screen.Bounds().Dy()-g.FontFace.Metrics().Height.Ceil(),
color.White, color.White,
) )
} }
@ -381,7 +379,7 @@ func main() {
ebiten.SetWindowClosingHandled(true) // So we can save data ebiten.SetWindowClosingHandled(true) // So we can save data
ebiten.SetRunnableOnUnfocused(true) ebiten.SetRunnableOnUnfocused(true)
ebiten.SetWindowResizingMode(ebiten.WindowResizingModeEnabled) ebiten.SetWindowResizingMode(ebiten.WindowResizingModeEnabled)
ebiten.SetWindowSizeLimits(380, 576, -1, -1) ebiten.SetWindowSizeLimits(512, 576, -1, -1)
ebiten.SetTPS(60) ebiten.SetTPS(60)
ebiten.SetWindowSize(game.Config.WindowSize[0], game.Config.WindowSize[1]) ebiten.SetWindowSize(game.Config.WindowSize[0], game.Config.WindowSize[1])
ebiten.SetWindowPosition(game.Config.LastWindowPosition[0], game.Config.LastWindowPosition[1]) ebiten.SetWindowPosition(game.Config.LastWindowPosition[0], game.Config.LastWindowPosition[1])

2
src/util/font.go

@ -24,7 +24,7 @@ import (
"golang.org/x/image/font/sfnt" "golang.org/x/image/font/sfnt"
) )
func NewFont(tt *sfnt.Font, options *opentype.FaceOptions) font.Face { func NewFace(tt *sfnt.Font, options *opentype.FaceOptions) font.Face {
newFont, _ := opentype.NewFace(tt, options) newFont, _ := opentype.NewFace(tt, options)
return newFont return newFont
} }

Loading…
Cancel
Save