fix: wrong randomText when unicode preset (#8)

This commit is contained in:
Zhiger 2023-02-16 19:06:39 +06:00 committed by GitHub
parent 6b08f978b6
commit 1d4172a01f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -186,9 +186,9 @@ func drawWithOption(text string, img *image.NRGBA, options *Options) error {
} }
func randomText(opts *Options) (text string) { func randomText(opts *Options) (text string) {
n := len(opts.CharPreset) n := len([]rune(opts.CharPreset))
for i := 0; i < opts.TextLength; i++ { for i := 0; i < opts.TextLength; i++ {
text += string(opts.CharPreset[rand.Intn(n)]) text += string([]rune(opts.CharPreset)[rand.Intn(n)])
} }
return text return text