Skip to content

Commit

Permalink
Use Modernizr.canvastext instead of reinventing the wheel in the em…
Browse files Browse the repository at this point in the history
…oji feature detect.
  • Loading branch information
mathiasbynens committed Oct 17, 2011
1 parent 18463cb commit 036fc05
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions feature-detects/emoji.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Requires a Modernizr build with `canvastest` included

This comment has been minimized.

Copy link
@mathiasbynens

mathiasbynens Oct 18, 2011

Author Contributor

Argh, typo! Should’ve been canvastext

// http://www.modernizr.com/download/#-canvas-canvastext
Modernizr.addTest('emoji', function() {
var node = document.createElement('canvas');
if (!(node.getContext && node.getContext('2d'))) return false;
var ctx = node.getContext('2d');
ctx.textBaseline = "top";
ctx.font = "32px Arial";
ctx.fillText("😃", 0, 0);
if (!Modernizr.canvastext) return false;
var node = document.createElement('canvas'),
ctx = node.getContext('2d');
ctx.textBaseline = 'top';
ctx.font = '32px Arial';
ctx.fillText('\ud83d\ude03', 0, 0); // "smiling face with open mouth" emoji
return ctx.getImageData(16, 16, 1, 1).data[0] != 0;
});
});

0 comments on commit 036fc05

Please sign in to comment.