-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
Modernizr.canvastext
instead of reinventing the wheel in the em…
…oji feature detect.
- Loading branch information
1 parent
18463cb
commit 036fc05
Showing
1 changed file
with
9 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Sorry, something went wrong. |
||
// 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; | ||
}); | ||
}); |
Argh, typo! Should’ve been
canvastext
…