hajimehoshi / ebiten

Ebitengine - A dead simple 2D game engine for Go
https://ebitengine.org
Apache License 2.0
10.96k stars 656 forks source link

Unicode chars don't get drawn #3031

Closed mbolis closed 3 months ago

mbolis commented 3 months ago

Ebitengine Version

v2.7.5

Operating System

Go Version (go version)

go1.22.1 linux/amd64

What steps will reproduce the problem?

Draw some Unicode runes (from the "Supplemental Mathematical Operators" block, in my case)

fontPath, err := findfont.Find("Roboto-Regular")
if err != nil {
    panic(err)
}

fontReader, err := os.Open(fontPath)
if err != nil {
    panic(err)
}
defer fontReader.Close()
fontSource, err = text.NewGoTextFaceSource(fontReader)
if err != nil {
    panic(err)
}

face := text.GoTextFace{
    Source: fontSource,
    Size:   24,
}
opts = text.DrawOptions{}
text.Draw(screen, "⨯", &face, &opts) // example character is '⨯' (\u2a2f, Vector or Cross Product)

What is the expected result?

The glyph gets drawn on the screen

What happens instead?

An unrecognized symbol glyph gets drawn instead immagine

Anything else you feel useful to add?

I tried with different fonts, and the result is always similar

hajimehoshi commented 3 months ago

Apparently Roboto doesn't have a glyph for "⨯" (U+2A2F), so there is nothing Ebitengine can do.

image

mbolis commented 3 months ago

Excuse me @hajimehoshi I'm sure you are more knowledgeable than me in this regard. If Roboto doesn't have that glyph (which I'm sure is the truth), then why is a text editor like LibreOffice showing the glyph when I input it while using Roboto? Is it implementing some sort of fallback?? Then I wonder what font it is using as fallback! Thank you, and sorry for raising a nonexistent issue

hajimehoshi commented 3 months ago

If Roboto doesn't have that glyph (which I'm sure is the truth), then why is a text editor like LibreOffice showing the glyph when I input it while using Roboto? Is it implementing some sort of fallback?? Then I wonder what font it is using as fallback

Such applications likely have fallbacks and fallback fonts depends on applications.

mbolis commented 3 months ago

As a record for posterity, I discovered the fallback font using the following command:

$ fc-match :charset=2a2f
DejaVuSans.ttf: "DejaVu Sans" "Regular"

Here of course 2a2f is the Unicode codepoint for