Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Modernizr.canvastext instead of reinventing the wheel in the emoji #391

Merged
merged 1 commit into from
Oct 17, 2011
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
// 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';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OMG IT SAYS DUDE

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;
});
});