Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text/v2: Mongolian scripts are not rendered correctly #2849

Closed
11 tasks
hajimehoshi opened this issue Nov 23, 2023 · 1 comment
Closed
11 tasks

text/v2: Mongolian scripts are not rendered correctly #2849

hajimehoshi opened this issue Nov 23, 2023 · 1 comment

Comments

@hajimehoshi
Copy link
Owner

Ebitengine Version

b9b365a

Operating System

  • Windows
  • macOS
  • Linux
  • FreeBSD
  • OpenBSD
  • Android
  • iOS
  • Nintendo Switch
  • PlayStation 5
  • Xbox
  • Web Browsers

Go Version (go version)

go version go1.21.1 darwin/amd64

What steps will reproduce the problem?

Add NotoSansMongolian.ttf to examples/texti18n and apply this patch:

diff --git a/examples/texti18n/main.go b/examples/texti18n/main.go
index fe604db8a..56b47ca06 100644
--- a/examples/texti18n/main.go
+++ b/examples/texti18n/main.go
@@ -70,6 +70,19 @@ func init() {
        thaiFaceSource = s
 }
 
+//go:embed NotoSansMongolian-Regular.ttf
+var mongolianTTF []byte
+
+var mongolianFaceSource *text.GoTextFaceSource
+
+func init() {
+       s, err := text.NewGoTextFaceSource(bytes.NewReader(mongolianTTF))
+       if err != nil {
+               log.Fatal(err)
+       }
+       mongolianFaceSource = s
+}
+
 var japaneseFaceSource *text.GoTextFaceSource
 
 func init() {
@@ -139,6 +152,25 @@ func (g *Game) Draw(screen *ebiten.Image) {
                op.GeoM.Translate(float64(x), float64(y))
                text.Draw(screen, thaiText, f, op)
        }
+       {
+               const mongolianText = "ᠬᠦᠮᠦᠨ ᠪᠦᠷ ᠲᠥᠷᠥᠵᠦ ᠮᠡᠨᠳᠡᠯᠡᠬᠦ\nᠡᠷᠬᠡ ᠴᠢᠯᠥᠭᠡ ᠲᠡᠢ᠂ ᠠᠳᠠᠯᠢᠬᠠᠨ"
+               f := &text.GoTextFace{
+                       Source:    mongolianFaceSource,
+                       Direction: text.DirectionTopToBottomAndLeftToRight,
+                       Size:      24,
+                       Language:  language.Mongolian,
+                       // language.Mongolian.Script() returns "Cyrl" (Cyrillic), but we want Mongolian script here.
+                       Script: language.MustParseScript("Mong"),
+               }
+               const lineSpacing = 48
+               x, y := 20, 210
+               w, h := text.Measure(mongolianText, f, lineSpacing)
+               vector.DrawFilledRect(screen, float32(x), float32(y), float32(w), float32(h), gray, false)
+               op := &text.DrawOptions{}
+               op.GeoM.Translate(float64(x), float64(y))
+               op.LineSpacingInPixels = lineSpacing
+               text.Draw(screen, mongolianText, f, op)
+       }
        {
                const japaneseText = "あのイーハトーヴォの\nすきとおった風、\n夏でも底に冷たさを\nもつ青いそら…"
                f := &text.GoTextFace{

What is the expected result?

A vertical Mongolian script is rendered correctly

What happens instead?

The glyphs are not rotated:
image

Anything else you feel useful to add?

Apparently rotating glyphs is Ebitengine's responsibility.

See a rune's Vertical_Orientation property and rotate it correctly.

@hajimehoshi
Copy link
Owner Author

go-text/typesetting#111

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant