         color.set()
         path.fill()
         
-//        NSGraphicsContext.restoreGraphicsState()
-        
-        image.unlockFocus()
-
-        image.lockFocus()
-        let imageRep = NSBitmapImageRep(focusedViewRect: NSMakeRect(0, 0, CGFloat(imageSize), CGFloat(imageSize)))
-        image.unlockFocus()
-            
-        return imageRep!
+        NSGraphicsContext.restoreGraphicsState()
+
+        return imageRep
     }
     
     func createTextureForBitmapImageRep(_ image: NSBitmapImageRep) -> MTLTexture

        let overscan = CGFloat(0.05) // the glyph is a little bigger than 1x1
        let imageSize = Int(floor(glyphSize * (1 + overscan)))
        
        let image = NSImage(size: NSMakeSize(CGFloat(imageSize), CGFloat(imageSize)))
        image.lockFocus()

//        let imageRep = NSBitmapImageRep(bitmapDataPlanes: nil, pixelsWide: imageSize, pixelsHigh: imageSize, bitsPerSample: 8, samplesPerPixel: 4, hasAlpha: true, isPlanar: false, colorSpaceName: NSCalibratedRGBColorSpace, bitmapFormat:.alphaNonpremultiplied, bytesPerRow: imageSize*4, bitsPerPixel:32)!
//        
//        NSGraphicsContext.saveGraphicsState()
//        NSGraphicsContext.setCurrent(NSGraphicsContext(bitmapImageRep: imageRep))
#if false
        let p0 = NSBezierPath()
        p0.appendRect(NSMakeRect(0, 0, CGFloat(imageSize), CGFloat(imageSize)))

        let region = MTLRegionMake2D(0, 0, Int(image.size.width), Int(image.size.height))
        texture.replace(region: region, mipmapLevel: 0, slice: 0, withBytes: image.bitmapData!, bytesPerRow: image.bytesPerRow, bytesPerImage: image.bytesPerRow * Int(image.size.height))

        return texture
    }

