dominikbulaj
12/10/2013 - 3:24 AM

Detect emoji support

Detect emoji support

  /**
   * Determine if this browser supports emoji.
   *
   * Modified from https://gist.github.com/mwunsch/4710561
   * and probobly originally github's javascript source
   */
  function doesSupportEmoji() {
    var context, smiley;
    if (!document.createElement('canvas').getContext) return;
    context = document.createElement('canvas').getContext('2d');
    if (typeof context.fillText != 'function') return;
    smile = String.fromCharCode(55357) + String.fromCharCode(56835);
 
    context.textBaseline = "top";
    context.font = "32px Arial";
    context.fillText(smile, 0, 0);
    return context.getImageData(16, 16, 1, 1).data[0] !== 0;
  }