g3n / engine

Go 3D Game Engine (http://g3n.rocks)
https://discord.gg/NfaeVr8zDg
BSD 2-Clause "Simplified" License
2.8k stars 295 forks source link

gui edit support on chinese or all unicode? add support on clipboard. #59

Closed alexniver closed 5 years ago

alexniver commented 6 years ago

hi, when I run the demo, i find that this edit does not support chinese. i guess japanese or Korean or emoji have the same problem.

I also find that this edit doesn't support clipboard.

default

danaugrs commented 6 years ago

Hi! Chinese characters are not working there because the default font included with the engine (FreeSans) only contains characters from the latin alphabet (to keep the total size small). You can change the default font to be one that includes Chinese characters e.g. SimSun (not included), then you can write in Chinese like so:

image

The same logic is valid for other languages - you just need to use a font that contains the characters you want displayed.

We plan to add support for clipboard as well as arbitrary text selection soon! I'll leave this open to track that. Thanks for your interest!

cloudfstrife commented 5 years ago

chinese characters demo

func main() {
    app, _ := application.Create(application.Options{
        Title:  "Hello G3N",
        Width:  800,
        Height: 600,
    })
    panel := gui.NewPanel(app.Gui().Width(), app.Gui().Height())
    panel.SetColor(math32.NewColor("white"))

    lab := gui.NewLabel("")
    font, err := text.NewFont("/usr/share/fonts/truetype/wqy/wqy-microhei.ttc")
    if err != nil {
        log.Fatal(err)
    }
    lab.SetFont(font)
    lab.SetPosition(100, 100)
    lab.SetColor(math32.NewColor("red"))
    button := gui.NewButton("button")
    button.SetPosition(1, 1)
    button.Subscribe(gui.OnClick, func(envName string, callback interface{}) {
        lab.SetText("按钮点击事件")
    })
    panel.Add(button)
    panel.Add(lab)
    app.Gui().Add(panel)
    app.Run()
}
danaugrs commented 5 years ago

Clipboard support being tracked by https://github.com/g3n/engine/issues/134