fixed unicode chars printed wrong in WriteString

This commit is contained in:
Timon Ringwald 2020-10-01 14:46:28 +02:00
parent 011bf8e616
commit d5ee06e128

View File

@ -3,11 +3,13 @@ package buf2d
// WriteString writes a whole string to the buffer at position (x,y) // WriteString writes a whole string to the buffer at position (x,y)
// no word wrap is applied at all. If the string does not fit, it will be truncated // no word wrap is applied at all. If the string does not fit, it will be truncated
func (b *Buffer) WriteString(str string, x, y int) { func (b *Buffer) WriteString(str string, x, y int) {
for dx, r := range str { dx := x
if x+dx >= b.width { for _, r := range str {
if dx >= b.width {
return return
} }
b.Set(x+dx, y, r) b.Set(dx, y, r)
dx++
} }
} }