text: Fix nil pointer dereference in drawGlyph (#1732)

drawGlyph can panic when provided with a nil *ebiten.DrawImageOptions
reference. Check that the pointer is not nil before dereferencing.
This commit is contained in:
nanoslayer 2021-07-27 14:20:35 -04:00 committed by GitHub
parent 6efe7cbb8b
commit e52a933506
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,7 +61,9 @@ func drawGlyph(dst *ebiten.Image, face font.Face, r rune, img *ebiten.Image, dx,
}
op2.GeoM.Reset()
op2.GeoM.Translate(float64((dx+b.Min.X)>>6), float64((dy+b.Min.Y)>>6))
op2.GeoM.Concat(op.GeoM)
if op != nil {
op2.GeoM.Concat(op.GeoM)
}
dst.DrawImage(img, op2)
}