Skip to content

Commit

Permalink
examples/texti18n: sort texts in an alphabetical order of languages
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Dec 20, 2023
1 parent 127e686 commit 06ca015
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions examples/texti18n/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,32 +139,32 @@ func (g *Game) Draw(screen *ebiten.Image) {
text.Draw(screen, hindiText, f, op)
}
{
const thaiText = "โดยที่การยอมรับนับถือเกียรติศักดิ์ประจำตัว"
const myanmarText = "လူခပ်သိမ်း၏ မျိုးရိုးဂုဏ်သိက္ခာနှင့်တကွ"
f := &text.GoTextFace{
Source: thaiFaceSource,
Source: myanmarFaceSource,
Size: 24,
Language: language.Thai,
Language: language.Burmese,
}
x, y := 20, 160
w, h := text.Measure(thaiText, f, 0)
w, h := text.Measure(myanmarText, f, 0)
vector.DrawFilledRect(screen, float32(x), float32(y), float32(w), float32(h), gray, false)
op := &text.DrawOptions{}
op.GeoM.Translate(float64(x), float64(y))
text.Draw(screen, thaiText, f, op)
text.Draw(screen, myanmarText, f, op)
}
{
const myanmarText = "လူခပ်သိမ်း၏ မျိုးရိုးဂုဏ်သိက္ခာနှင့်တကွ"
const thaiText = "โดยที่การยอมรับนับถือเกียรติศักดิ์ประจำตัว"
f := &text.GoTextFace{
Source: myanmarFaceSource,
Source: thaiFaceSource,
Size: 24,
Language: language.Burmese,
Language: language.Thai,
}
x, y := 20, 210
w, h := text.Measure(myanmarText, f, 0)
x, y := 20, 220
w, h := text.Measure(thaiText, f, 0)
vector.DrawFilledRect(screen, float32(x), float32(y), float32(w), float32(h), gray, false)
op := &text.DrawOptions{}
op.GeoM.Translate(float64(x), float64(y))
text.Draw(screen, myanmarText, f, op)
text.Draw(screen, thaiText, f, op)
}
{
const japaneseText = "あのイーハトーヴォの\nすきとおった風、\n夏でも底に冷たさを\nもつ青いそら…"
Expand All @@ -175,7 +175,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
Language: language.Japanese,
}
const lineSpacing = 48
x, y := screenWidth-20, 300
x, y := screenWidth-20, 280
w, h := text.Measure(japaneseText, f, lineSpacing)
// The left upper point is not x but x-w, since the text runs in the rigth-to-left direction as the secondary direction.
vector.DrawFilledRect(screen, float32(x)-float32(w), float32(y), float32(w), float32(h), gray, false)
Expand Down

0 comments on commit 06ca015

Please sign in to comment.