Closed alexniver closed 5 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:
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!
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()
}
Clipboard support being tracked by https://github.com/g3n/engine/issues/134
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.