ebiten: Remove the error returning value from NewImageFromImage

Updates #1380
This commit is contained in:
Hajime Hoshi 2020-10-06 01:03:30 +09:00
parent c6053bcf14
commit 1b816eb249
42 changed files with 58 additions and 79 deletions

View File

@ -22,15 +22,10 @@ import (
) )
var ( var (
debugPrintTextImage *ebiten.Image debugPrintTextImage = ebiten.NewImageFromImage(assets.CreateTextImage())
debugPrintTextSubImages = map[rune]*ebiten.Image{} debugPrintTextSubImages = map[rune]*ebiten.Image{}
) )
func init() {
img := assets.CreateTextImage()
debugPrintTextImage, _ = ebiten.NewImageFromImage(img)
}
// DebugPrint draws the string str on the image on left top corner. // DebugPrint draws the string str on the image on left top corner.
// //
// The available runes are in U+0000 to U+00FF, which is C0 Controls and Basic Latin and C1 Controls and Latin-1 Supplement. // The available runes are in U+0000 to U+00FF, which is C0 Controls and Basic Latin and C1 Controls and Latin-1 Supplement.

View File

@ -45,9 +45,6 @@ func NewImageFromFile(path string) (*ebiten.Image, image.Image, error) {
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
img2, err := ebiten.NewImageFromImage(img) img2 := ebiten.NewImageFromImage(img)
if err != nil {
return nil, nil, err
}
return img2, img, err return img2, img, err
} }

View File

@ -37,6 +37,6 @@ func NewImageFromURL(url string) (*ebiten.Image, error) {
return nil, err return nil, err
} }
eimg, _ := ebiten.NewImageFromImage(img) eimg := ebiten.NewImageFromImage(img)
return eimg, nil return eimg, nil
} }

View File

@ -82,7 +82,7 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
ebitenImage, _ = ebiten.NewImageFromImage(img) ebitenImage = ebiten.NewImageFromImage(img)
ebiten.SetWindowSize(screenWidth*2, screenHeight*2) ebiten.SetWindowSize(screenWidth*2, screenHeight*2)
ebiten.SetWindowTitle("Additive Blending (Ebiten Demo)") ebiten.SetWindowTitle("Additive Blending (Ebiten Demo)")

View File

@ -48,7 +48,7 @@ func init() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
ebitenImage, _ = ebiten.NewImageFromImage(img) ebitenImage = ebiten.NewImageFromImage(img)
} }
func drawRect(screen *ebiten.Image, img *ebiten.Image, x, y, width, height float32, address ebiten.Address, msg string) { func drawRect(screen *ebiten.Image, img *ebiten.Image, x, y, width, height float32, address ebiten.Address, msg string) {

View File

@ -61,7 +61,7 @@ func init() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
gophersImage, _ = ebiten.NewImageFromImage(img) gophersImage = ebiten.NewImageFromImage(img)
const repeat = 5 const repeat = 5
w, h := gophersImage.Size() w, h := gophersImage.Size()
@ -89,7 +89,7 @@ func init() {
fogRGBA.SetRGBA(i, j, clr) fogRGBA.SetRGBA(i, j, clr)
} }
} }
fogImage, _ = ebiten.NewImageFromImage(fogRGBA) fogImage = ebiten.NewImageFromImage(fogRGBA)
} }
// player represents the current airship's position. // player represents the current airship's position.

View File

@ -91,7 +91,7 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
ebitenImage, _ = ebiten.NewImageFromImage(img) ebitenImage = ebiten.NewImageFromImage(img)
ebiten.SetWindowSize(screenWidth*2, screenHeight*2) ebiten.SetWindowSize(screenWidth*2, screenHeight*2)
ebiten.SetWindowTitle("Alpha Blending (Ebiten Demo)") ebiten.SetWindowTitle("Alpha Blending (Ebiten Demo)")

View File

@ -77,7 +77,7 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
runnerImage, _ = ebiten.NewImageFromImage(img) runnerImage = ebiten.NewImageFromImage(img)
ebiten.SetWindowSize(screenWidth*2, screenHeight*2) ebiten.SetWindowSize(screenWidth*2, screenHeight*2)
ebiten.SetWindowTitle("Animation (Ebiten Demo)") ebiten.SetWindowTitle("Animation (Ebiten Demo)")

View File

@ -132,7 +132,7 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
img, _ = ebiten.NewImageFromImage(rawimg) img = ebiten.NewImageFromImage(rawimg)
ebiten.SetWindowSize(screenWidth*2, screenHeight*2) ebiten.SetWindowSize(screenWidth*2, screenHeight*2)
ebiten.SetWindowTitle("Audio Panning Loop (Ebiten Demo)") ebiten.SetWindowTitle("Audio Panning Loop (Ebiten Demo)")

View File

@ -76,7 +76,7 @@ func init() {
if err != nil { if err != nil {
panic(err) panic(err)
} }
imageGameBG, _ = ebiten.NewImageFromImage(img) imageGameBG = ebiten.NewImageFromImage(img)
// Windows: Field // Windows: Field
x, y := fieldWindowPosition() x, y := fieldWindowPosition()

View File

@ -30,7 +30,7 @@ func init() {
if err != nil { if err != nil {
panic(err) panic(err)
} }
imageBlocks, _ = ebiten.NewImageFromImage(img) imageBlocks = ebiten.NewImageFromImage(img)
} }

View File

@ -32,7 +32,7 @@ func init() {
if err != nil { if err != nil {
panic(err) panic(err)
} }
imageBackground, _ = ebiten.NewImageFromImage(img) imageBackground = ebiten.NewImageFromImage(img)
} }
type TitleScene struct { type TitleScene struct {

View File

@ -82,7 +82,7 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
gophersImage, _ = ebiten.NewImageFromImage(img) gophersImage = ebiten.NewImageFromImage(img)
ebiten.SetWindowSize(screenWidth, screenHeight) ebiten.SetWindowSize(screenWidth, screenHeight)
ebiten.SetWindowTitle("Blur (Ebiten Demo)") ebiten.SetWindowTitle("Blur (Ebiten Demo)")

View File

@ -65,7 +65,7 @@ func init() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
tilesImage, _ = ebiten.NewImageFromImage(img) tilesImage = ebiten.NewImageFromImage(img)
} }
type Camera struct { type Camera struct {

View File

@ -203,7 +203,7 @@ func init() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
ebitenImage, _ = ebiten.NewImageFromImage(img) ebitenImage = ebiten.NewImageFromImage(img)
} }
func NewGame() *Game { func NewGame() *Game {

View File

@ -79,7 +79,7 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
ebitenImage, _ = ebiten.NewImageFromImage(img) ebitenImage = ebiten.NewImageFromImage(img)
ebiten.SetWindowSize(screenWidth, screenHeight) ebiten.SetWindowSize(screenWidth, screenHeight)
ebiten.SetWindowTitle("Filter (Ebiten Demo)") ebiten.SetWindowTitle("Filter (Ebiten Demo)")

View File

@ -82,13 +82,13 @@ func init() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
gopherImage, _ = ebiten.NewImageFromImage(img) gopherImage = ebiten.NewImageFromImage(img)
img, _, err = image.Decode(bytes.NewReader(resources.Tiles_png)) img, _, err = image.Decode(bytes.NewReader(resources.Tiles_png))
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
tilesImage, _ = ebiten.NewImageFromImage(img) tilesImage = ebiten.NewImageFromImage(img)
} }
func init() { func init() {

View File

@ -103,7 +103,7 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
ebitenImage, _ = ebiten.NewImageFromImage(img) ebitenImage = ebiten.NewImageFromImage(img)
ebiten.SetWindowSize(screenWidth*2, screenHeight*2) ebiten.SetWindowSize(screenWidth*2, screenHeight*2)
ebiten.SetWindowTitle("Flood fill with solid colors (Ebiten Demo)") ebiten.SetWindowTitle("Flood fill with solid colors (Ebiten Demo)")

View File

@ -55,7 +55,7 @@ func init() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
gophersImage, _ = ebiten.NewImageFromImage(img) gophersImage = ebiten.NewImageFromImage(img)
} }
func initFont() { func initFont() {

View File

@ -149,7 +149,7 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
gophersImage, _ = ebiten.NewImageFromImage(img) gophersImage = ebiten.NewImageFromImage(img)
ebiten.SetWindowSize(screenWidth*2, screenHeight*2) ebiten.SetWindowSize(screenWidth*2, screenHeight*2)
ebiten.SetWindowTitle("HSV (Ebiten Demo)") ebiten.SetWindowTitle("HSV (Ebiten Demo)")

View File

@ -75,7 +75,7 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
gophersImage, _ = ebiten.NewImageFromImage(img) gophersImage = ebiten.NewImageFromImage(img)
ebiten.SetWindowSize(screenWidth*2, screenHeight*2) ebiten.SetWindowSize(screenWidth*2, screenHeight*2)
ebiten.SetWindowTitle("Hue (Ebiten Demo)") ebiten.SetWindowTitle("Hue (Ebiten Demo)")

View File

@ -51,7 +51,7 @@ func init() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
bgImage, _ = ebiten.NewImageFromImage(img) bgImage = ebiten.NewImageFromImage(img)
} }
type viewport struct { type viewport struct {

View File

@ -42,7 +42,7 @@ func init() {
log.Fatal(err) log.Fatal(err)
} }
keyboardImage, _ = ebiten.NewImageFromImage(img) keyboardImage = ebiten.NewImageFromImage(img)
} }
type Game struct { type Game struct {

View File

@ -55,19 +55,19 @@ func init() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
gopher1, _ = ebiten.NewImageFromImage(img1) gopher1 = ebiten.NewImageFromImage(img1)
img2, _, err := image.Decode(bytes.NewReader(rmascot.Out02_png)) img2, _, err := image.Decode(bytes.NewReader(rmascot.Out02_png))
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
gopher2, _ = ebiten.NewImageFromImage(img2) gopher2 = ebiten.NewImageFromImage(img2)
img3, _, err := image.Decode(bytes.NewReader(rmascot.Out03_png)) img3, _, err := image.Decode(bytes.NewReader(rmascot.Out03_png))
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
gopher3, _ = ebiten.NewImageFromImage(img3) gopher3 = ebiten.NewImageFromImage(img3)
} }
func init() { func init() {

View File

@ -54,13 +54,13 @@ func init() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
bgImage, _ = ebiten.NewImageFromImage(img) bgImage = ebiten.NewImageFromImage(img)
img, _, err = image.Decode(bytes.NewReader(images.FiveYears_jpg)) img, _, err = image.Decode(bytes.NewReader(images.FiveYears_jpg))
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
fgImage, _ = ebiten.NewImageFromImage(img) fgImage = ebiten.NewImageFromImage(img)
// Initialize the spot light image. // Initialize the spot light image.
const r = 64 const r = 64
@ -75,7 +75,7 @@ func init() {
a.SetAlpha(i, j, color.Alpha{b}) a.SetAlpha(i, j, color.Alpha{b})
} }
} }
spotLightImage, _ = ebiten.NewImageFromImage(a) spotLightImage = ebiten.NewImageFromImage(a)
} }
type Game struct { type Game struct {

View File

@ -111,7 +111,7 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
gophersImage, _ = ebiten.NewImageFromImage(img) gophersImage = ebiten.NewImageFromImage(img)
ebiten.SetWindowSize(screenWidth, screenHeight) ebiten.SetWindowSize(screenWidth, screenHeight)
ebiten.SetWindowTitle("Minify (Ebiten Demo)") ebiten.SetWindowTitle("Minify (Ebiten Demo)")

View File

@ -52,7 +52,7 @@ func init() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
gophersImage, _ = ebiten.NewImageFromImage(img) gophersImage = ebiten.NewImageFromImage(img)
} }
type Game struct { type Game struct {

View File

@ -49,7 +49,7 @@ func init() {
a1, a2, a2, a1, a1, a2, a2, a1,
a0, a1, a1, a0, a0, a1, a1, a0,
} }
brushImage, _ = ebiten.NewImageFromImage(&image.Alpha{ brushImage = ebiten.NewImageFromImage(&image.Alpha{
Pix: pixels, Pix: pixels,
Stride: 4, Stride: 4,
Rect: image.Rect(0, 0, 4, 4), Rect: image.Rect(0, 0, 4, 4),

View File

@ -58,7 +58,7 @@ func init() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
smokeImage, _ = ebiten.NewImageFromImage(img) smokeImage = ebiten.NewImageFromImage(img)
} }
type sprite struct { type sprite struct {

View File

@ -82,7 +82,7 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
gophersImage, _ = ebiten.NewImageFromImage(img) gophersImage = ebiten.NewImageFromImage(img)
ebiten.SetWindowSize(screenWidth*2, screenHeight*2) ebiten.SetWindowSize(screenWidth*2, screenHeight*2)
ebiten.SetWindowTitle("Perspective (Ebiten Demo)") ebiten.SetWindowTitle("Perspective (Ebiten Demo)")

View File

@ -47,25 +47,25 @@ func init() {
if err != nil { if err != nil {
panic(err) panic(err)
} }
rightSprite, _ = ebiten.NewImageFromImage(img) rightSprite = ebiten.NewImageFromImage(img)
img, _, err = image.Decode(bytes.NewReader(rplatformer.Left_png)) img, _, err = image.Decode(bytes.NewReader(rplatformer.Left_png))
if err != nil { if err != nil {
panic(err) panic(err)
} }
leftSprite, _ = ebiten.NewImageFromImage(img) leftSprite = ebiten.NewImageFromImage(img)
img, _, err = image.Decode(bytes.NewReader(rplatformer.MainChar_png)) img, _, err = image.Decode(bytes.NewReader(rplatformer.MainChar_png))
if err != nil { if err != nil {
panic(err) panic(err)
} }
idleSprite, _ = ebiten.NewImageFromImage(img) idleSprite = ebiten.NewImageFromImage(img)
img, _, err = image.Decode(bytes.NewReader(rplatformer.Background_png)) img, _, err = image.Decode(bytes.NewReader(rplatformer.Background_png))
if err != nil { if err != nil {
panic(err) panic(err)
} }
backgroundImage, _ = ebiten.NewImageFromImage(img) backgroundImage = ebiten.NewImageFromImage(img)
} }
const ( const (

View File

@ -59,7 +59,7 @@ func init() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
bgImage, _ = ebiten.NewImageFromImage(img) bgImage = ebiten.NewImageFromImage(img)
triangleImage.Fill(color.White) triangleImage.Fill(color.White)
} }

View File

@ -82,7 +82,7 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
gophersImage, _ = ebiten.NewImageFromImage(img) gophersImage = ebiten.NewImageFromImage(img)
ebiten.SetWindowSize(screenWidth*2, screenHeight*2) ebiten.SetWindowSize(screenWidth*2, screenHeight*2)
ebiten.SetWindowTitle("Rotate (Ebiten Demo)") ebiten.SetWindowTitle("Rotate (Ebiten Demo)")

View File

@ -54,7 +54,7 @@ func init() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
gopherImage, _ = ebiten.NewImageFromImage(img) gopherImage = ebiten.NewImageFromImage(img)
} }
func init() { func init() {
@ -62,7 +62,7 @@ func init() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
gopherBgImage, _ = ebiten.NewImageFromImage(img) gopherBgImage = ebiten.NewImageFromImage(img)
} }
func init() { func init() {
@ -70,7 +70,7 @@ func init() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
normalImage, _ = ebiten.NewImageFromImage(img) normalImage = ebiten.NewImageFromImage(img)
} }
func init() { func init() {
@ -78,7 +78,7 @@ func init() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
noiseImage, _ = ebiten.NewImageFromImage(img) noiseImage = ebiten.NewImageFromImage(img)
} }
var shaderSrcs = [][]byte{ var shaderSrcs = [][]byte{

View File

@ -54,7 +54,7 @@ func init() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
origEbitenImage, _ := ebiten.NewImageFromImage(img) origEbitenImage := ebiten.NewImageFromImage(img)
w, h := origEbitenImage.Size() w, h := origEbitenImage.Size()
ebitenImage = ebiten.NewImage(w, h) ebitenImage = ebiten.NewImage(w, h)

View File

@ -56,7 +56,7 @@ func init() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
origEbitenImage, _ := ebiten.NewImageFromImage(img) origEbitenImage := ebiten.NewImageFromImage(img)
w, h := origEbitenImage.Size() w, h := origEbitenImage.Size()
ebitenImage = ebiten.NewImage(w, h) ebitenImage = ebiten.NewImage(w, h)

View File

@ -56,7 +56,7 @@ func init() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
tilesImage, _ = ebiten.NewImageFromImage(img) tilesImage = ebiten.NewImageFromImage(img)
} }
type Game struct { type Game struct {

View File

@ -58,7 +58,7 @@ func init() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
uiImage, _ = ebiten.NewImageFromImage(img) uiImage = ebiten.NewImageFromImage(img)
tt, err := opentype.Parse(goregular.TTF) tt, err := opentype.Parse(goregular.TTF)
if err != nil { if err != nil {

View File

@ -349,7 +349,7 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
gophersImage, _ = ebiten.NewImageFromImage(img) gophersImage = ebiten.NewImageFromImage(img)
ebiten.SetWindowIcon([]image.Image{createRandomIconImage()}) ebiten.SetWindowIcon([]image.Image{createRandomIconImage()})

View File

@ -31,8 +31,6 @@ var panicOnErrorAtImageAt bool
// Image represents a rectangle set of pixels. // Image represents a rectangle set of pixels.
// The pixel format is alpha-premultiplied RGBA. // The pixel format is alpha-premultiplied RGBA.
// Image implements image.Image and draw.Image. // Image implements image.Image and draw.Image.
//
// Functions of Image never returns error as of 1.5.0, and error values are always nil.
type Image struct { type Image struct {
// addr holds self to check copying. // addr holds self to check copying.
// See strings.Builder for similar examples. // See strings.Builder for similar examples.
@ -729,9 +727,7 @@ func NewImage(width, height int) *Image {
// NewImageFromImage creates a new image with the given image (source). // NewImageFromImage creates a new image with the given image (source).
// //
// If source's width or height is less than 1 or more than device-dependent maximum size, NewImageFromImage panics. // If source's width or height is less than 1 or more than device-dependent maximum size, NewImageFromImage panics.
// func NewImageFromImage(source image.Image) *Image {
// Error returned by NewImageFromImage is always nil as of 1.5.0.
func NewImageFromImage(source image.Image) (*Image, error) {
size := source.Bounds().Size() size := source.Bounds().Size()
width, height := size.X, size.Y width, height := size.X, size.Y
@ -743,7 +739,7 @@ func NewImageFromImage(source image.Image) (*Image, error) {
i.addr = i i.addr = i
i.ReplacePixels(imageToBytes(source)) i.ReplacePixels(imageToBytes(source))
return i, nil return i
} }
func newScreenFramebufferImage(width, height int) *Image { func newScreenFramebufferImage(width, height int) *Image {

View File

@ -59,10 +59,7 @@ func openEbitenImage() (*Image, image.Image, error) {
return nil, nil, err return nil, nil, err
} }
eimg, err := NewImageFromImage(img) eimg := NewImageFromImage(img)
if err != nil {
return nil, nil, err
}
return eimg, img, nil return eimg, img, nil
} }
@ -248,7 +245,7 @@ func TestImageDotByDotInversion(t *testing.T) {
func TestImageReplacePixels(t *testing.T) { func TestImageReplacePixels(t *testing.T) {
// Create a dummy image so that the shared texture is used and origImg's position is shfited. // Create a dummy image so that the shared texture is used and origImg's position is shfited.
dummyImg, _ := NewImageFromImage(image.NewRGBA(image.Rect(0, 0, 16, 16))) dummyImg := NewImageFromImage(image.NewRGBA(image.Rect(0, 0, 16, 16)))
defer dummyImg.Dispose() defer dummyImg.Dispose()
_, origImg, err := openEbitenImage() _, origImg, err := openEbitenImage()
@ -361,9 +358,7 @@ func TestNewImageFromEbitenImage(t *testing.T) {
t.Fatal(err) t.Fatal(err)
return return
} }
if _, err := NewImageFromImage(img); err != nil { _ = NewImageFromImage(img)
t.Errorf("NewImageFromImage returns error: %v", err)
}
} }
func TestNewImageFromSubImage(t *testing.T) { func TestNewImageFromSubImage(t *testing.T) {
@ -374,11 +369,7 @@ func TestNewImageFromSubImage(t *testing.T) {
} }
w, h := img.Bounds().Dx(), img.Bounds().Dy() w, h := img.Bounds().Dx(), img.Bounds().Dy()
subImg := img.(*image.NRGBA).SubImage(image.Rect(1, 1, w-1, h-1)) subImg := img.(*image.NRGBA).SubImage(image.Rect(1, 1, w-1, h-1))
eimg, err := NewImageFromImage(subImg) eimg := NewImageFromImage(subImg)
if err != nil {
t.Fatal(err)
return
}
sw, sh := subImg.Bounds().Dx(), subImg.Bounds().Dy() sw, sh := subImg.Bounds().Dx(), subImg.Bounds().Dy()
w2, h2 := eimg.Size() w2, h2 := eimg.Size()
if w2 != sw { if w2 != sw {

View File

@ -154,7 +154,7 @@ func getGlyphImages(face font.Face, runes []rune) []*ebiten.Image {
d.Dot = fixed.Point26_6{X: x, Y: y} d.Dot = fixed.Point26_6{X: x, Y: y}
d.DrawString(string(r)) d.DrawString(string(r))
img, _ := ebiten.NewImageFromImage(rgba) img := ebiten.NewImageFromImage(rgba)
if _, ok := glyphImageCache[face][r]; !ok { if _, ok := glyphImageCache[face][r]; !ok {
glyphImageCache[face][r] = &glyphImageCacheEntry{ glyphImageCache[face][r] = &glyphImageCacheEntry{
image: img, image: img,