         print(image)
     }
     
-    public class func fromCache(fontName font: String, pointSize: Float) -> FontAtlas {
+    func createTexture (context: Context) {
+        let imageBuffer = Imagebuffer(
+            array: _textureData,
+            width: _textureSize,
+            height: _textureSize,
+            bytesPerPixel: 1)
+        let source: TextureSource = .Buffer(imageBuffer)
+        let sampler = Sampler(context: context, wrapS: .ClampToZero, wrapT: .ClampToZero)
+        let options = TextureOptions(
+            source: source,
+            pixelFormat: .R8Unorm,
+            usage: TextureUsage.ShaderRead,
+            sampler: sampler)
+        texture = Texture(context: context, options: options)
+    }
+    
+    class func fromCache(context: Context, fontName font: String, pointSize: Float) -> FontAtlas {
         if let atlas = _cache["\(font)\(pointSize)"] {
             return atlas
         }
-        let atlas = FontAtlas(font: font, pointSize: pointSize)
+        let atlas = FontAtlas(context: context, font: font, pointSize: pointSize)
         _cache["\(font)\(pointSize)"] = atlas
         return atlas
     }

    
    internal var glyphDescriptors = [GlyphDescriptor]()
    
    private (set) var textureData = [UInt8]()
    
    private var MBE_GENERATE_DEBUG_ATLAS_IMAGE = true

    /// Create a signed-distance field based font atlas with the specified dimensions.
    /// The supplied font will be resized to fit all available glyphs in the texture.
    private init (font: String, pointSize: Float, textureSize: Int = MBEFontAtlasSize) {
        parentFont = CTFontCreateWithName(font, CGFloat(pointSize), nil)
        _fontPointSize = Int(ceilf(Float(pointSize)))
        _textureSize = textureSize
        spread = estimatedLineWidthForFont(parentFont) * 0.5
        createTextureData()
    }
/*
    - (instancetype)initWithCoder:(NSCoder *)aDecoder

        let spread = estimatedLineWidthForFont(parentFont) * 0.5
        
        // Quantize the downsampled distance field into an 8-bit grayscale array suitable for use as a texture
        _textureData = createQuantizedDistanceField(
            distanceField: scaledField,
            width: _textureSize,
            height: _textureSize,
