mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-12 22:17:26 +01:00
text/v2: bug fix: the given slice to MultiFace should be copied
Updates #2845
This commit is contained in:
parent
dfa058a961
commit
fa3ec12731
@ -32,9 +32,10 @@ type MultiFace struct {
|
|||||||
|
|
||||||
// NewMultiFace creates a new MultiFace from the given faces.
|
// NewMultiFace creates a new MultiFace from the given faces.
|
||||||
func NewMultiFace(faces ...Face) *MultiFace {
|
func NewMultiFace(faces ...Face) *MultiFace {
|
||||||
return &MultiFace{
|
m := &MultiFace{}
|
||||||
faces: faces,
|
m.faces = make([]Face, len(faces))
|
||||||
}
|
copy(m.faces, faces)
|
||||||
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
// Metrics implements Face.
|
// Metrics implements Face.
|
||||||
|
@ -240,3 +240,14 @@ func TestUnhashableFace(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMultiFace(t *testing.T) {
|
||||||
|
faces := []text.Face{text.NewStdFace(bitmapfont.Face)}
|
||||||
|
f := text.NewMultiFace(faces...)
|
||||||
|
img := ebiten.NewImage(30, 30)
|
||||||
|
text.Draw(img, "Hello", f, nil)
|
||||||
|
|
||||||
|
// Confirm that the given slice doesn't cause crash.
|
||||||
|
faces[0] = nil
|
||||||
|
text.Draw(img, "World", f, nil)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user