Merge pull request #75 from linkerlin/patch-1

Added support for Chinese
This commit is contained in:
Vladimir Markelov 2018-01-23 21:42:06 -08:00 committed by GitHub
commit fb6ab7b916
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ import (
xs "github.com/huandu/xstrings" xs "github.com/huandu/xstrings"
term "github.com/nsf/termbox-go" term "github.com/nsf/termbox-go"
"strings" "strings"
"unicode"
) )
type attr struct { type attr struct {
@ -274,7 +275,13 @@ func DrawText(x, y int, text string) {
SetTextColor(elem.Fg) SetTextColor(elem.Fg)
SetBackColor(elem.Bg) SetBackColor(elem.Bg)
drawn := PutChar(x, y, elem.Ch) drawn := PutChar(x, y, elem.Ch)
if unicode.Is(unicode.Scripts["Han"], elem.Ch){
x += 2
} else {
x += 1 x += 1
}
if firstdrawn && !drawn { if firstdrawn && !drawn {
break break
} }