title: How to render a high resolution image from emoji string
body: <p>I am trying to take an emoji and convert it to a 160x160 high resolution UIImage, but it seems like I am getting a grainy picture from my method.</p>
  
  <pre><code> func toImage(withDimension dimension: CGFloat) -&gt; UIImage {
      let font = UIFont.systemFont(ofSize: dimension)
  
      let stringBounds = (self as NSString).size(withAttributes: [NSAttributedStringKey.font: font])
      UIGraphicsBeginImageContextWithOptions(stringBounds, false, 3.0)
  
      let xCenter = (stringBounds.width - CGFloat(dimension))/3.0
      let rect = CGRect(origin: CGPoint(x: xCenter, y: 0.0), size: stringBounds)
      UIColor.clear.set()
      UIRectFill(CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: stringBounds))
  
      (self as NSString).draw(in: rect, withAttributes: [NSAttributedStringKey.font: font])
      let image = UIGraphicsGetImageFromCurrentImageContext()
      UIGraphicsEndImageContext()
  
      return image!
   }
  </code></pre>
  
  <p>Called:</p>
  
  <pre><code>"".toImage(withDimension: 160.0)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/sIGPe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sIGPe.png" alt="enter image description here"></a></p>
  
  <p>There is a similar thread to this, but it seems the problem was left unsolved. Is it possible to produce a high resolution 160x160 image from emoji? I am using Aspect Fill content mode</p>