fix: wrong randomText when unicode preset

This commit is contained in:
Zhiger Kalymov 2023-02-16 16:15:28 +06:00
parent 6b08f978b6
commit b4d5992e1f

View file

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