       try! atlas.addItem(char, item: tex)
       tool.deleteTexture(tex)
     }
-//    
-//    // Create the CG context to build the texture from
-//    UIGraphicsBeginImageContextWithOptions(textureSize, false, 1)
-//    let context = UIGraphicsGetCurrentContext()
-//    // We precalculated the adjustment due to screen scaling, so apply it manually
-//    // Also, flip the coordinates so it is upright in texture memory
-//    CGContextTranslateCTM(context, 0, textureSize.height)
-//    CGContextScaleCTM(context, CGFloat(scale), -CGFloat(scale))
-//    
-//    // Now render every character
-//    for char in 0..<atlasText.characters.count {
-//      // Get the character of the text string to render
-//      let renderChar = atlasText.characters[atlasText.characters.startIndex.advancedBy(char)]
-//      
-//      // Calculate the lookup index for this
-//      let lX = char % characterCount.x
-//      let lY = (char - lX) / characterCount.x
-//      
-//      // Work out the exact point to draw and do it
-//      let point = CGPoint(x: lX*characterFullPointSize.w, y: lY*characterFullPointSize.h)
-//      let drawString = (String(renderChar) as NSString)
-//      drawString.drawAtPoint(point, withAttributes: attrs)
-//    }
-//    
-//    // Now, grab this as a texture
-//    let image = CGBitmapContextCreateImage(context)!
-//    UIGraphicsEndImageContext()
-//    do {
-//      let texture = Texture(glk: try GLKTextureLoader.textureWithCGImage(image, options: nil))
-//      texture.debugName(fontName + " " + String(size))
-//
-//      // Bind this, and generate a mipmap
-//      tool.bind(texture)
-//      glGenerateMipmap(GLenum(GL_TEXTURE_2D));
-//
-//      
-//      let atlas = TextureAtlas(tools: tool, totalSize: Size2DFromCGSize(textureSize).map({UInt($0)}), itemSize: characterFullPixelSize.map({UInt($0)}))
-//      
-      // Build the atlas texture object
-//      let charLookup : [Character : (x: Int, y: Int)] = [:]
-//      let atlas = TextAtlas(texture: texture, fontSize: size, widthInCharacters: characterCount.x,
-//        uvSize: (uvSize.w, uvSize.h),
-//        texelSize: (width: GLfloat(characterFullPixelSize.w), height: GLfloat(characterFullPixelSize.h)),
-//        text: atlasText, coords: charLookup, newAtlas: newAtlas)
-//      textAtlasses[siz].append(atlas)
-//      
-//      return atlas
-//    } catch let err as NSError {
-//      fatalError("ERROR: " + err.localizedDescription)
-//    }
+
     textAtlasses[size] = atlas
     return atlas
   }

    let characterFullPixelSize = characterFullPointSize.map({Int(ceil(Float($0) * scale))})
    
    let textureSize = _required_texture_size(atlasText.characters.count, size: characterFullPixelSize)
    
//    // Work out how many characters we can fit in wide and high
//    let characterCount = (x: Int(floor(textureSize.width/CGFloat(characterFullPixelSize.w))),
//                          y: Int(floor(textureSize.height/CGFloat(characterFullPixelSize.h))))

    // Calculate the exact UV size to use
    let uvSize = Size2D(w: GLfloat(characterPixelSize.w)/GLfloat(textureSize.width),

  subscript (index: String) -> CGRect? {
    return items[index]
  }

  /** Add an item to the atlas texture.
  - parameters item     The texture to place in the atlas entry
  - parameters uvWidth  The proportion of the texture that covers the actual
                        physical size (for e.g. font fractionals) */
