From 56faf349325ae4b4581b8ab9ecf689edbc4948a7 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 13 Nov 2023 01:36:04 +0900 Subject: [PATCH] examples/text: adjust the rendering position text/v2's Draw uses the given position as the upper-left position of the bounds by default, while text (v1) uses the given position as the origin position. In order to approximate the same result of the original text version, adjust the Y values. Updates #2454 --- examples/text/main.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/text/main.go b/examples/text/main.go index 186eaad87..5af49dbb4 100644 --- a/examples/text/main.go +++ b/examples/text/main.go @@ -96,7 +96,7 @@ func (g *Game) Draw(screen *ebiten.Image) { gray := color.RGBA{0x80, 0x80, 0x80, 0xff} { - const x, y = 20, 40 + const x, y = 20, 20 w, h := text.Measure(sampleText, mplusNormalFace, mplusNormalFace.Metrics().Height) vector.DrawFilledRect(screen, x, y, float32(w), float32(h), gray, false) op := &text.DrawOptions{} @@ -105,7 +105,7 @@ func (g *Game) Draw(screen *ebiten.Image) { text.Draw(screen, sampleText, mplusNormalFace, op) } { - const x, y = 20, 140 + const x, y = 20, 120 w, h := text.Measure(sampleText, mplusBigFace, mplusBigFace.Metrics().Height) vector.DrawFilledRect(screen, x, y, float32(w), float32(h), gray, false) op := &text.DrawOptions{} @@ -114,7 +114,7 @@ func (g *Game) Draw(screen *ebiten.Image) { text.Draw(screen, sampleText, mplusBigFace, op) } { - const x, y = 20, 240 + const x, y = 20, 220 op := &text.DrawOptions{} op.GeoM.Rotate(math.Pi / 4) op.GeoM.Translate(x, y) @@ -123,7 +123,7 @@ func (g *Game) Draw(screen *ebiten.Image) { text.Draw(screen, sampleText, mplusNormalFace, op) } { - const x, y = 160, 240 + const x, y = 160, 220 const lineHeight = 80 w, h := text.Measure(sampleText, mplusBigFace, lineHeight) vector.DrawFilledRect(screen, x, y, float32(w), float32(h), gray, false) @@ -133,7 +133,7 @@ func (g *Game) Draw(screen *ebiten.Image) { text.Draw(screen, sampleText, mplusBigFace, op) } { - const x, y = 240, 400 + const x, y = 240, 380 op := &ebiten.DrawImageOptions{} // g.glyphs is initialized by text.AppendGlyphs. // You can customize how to render each glyph.