For the project I'm working on, I need to create an image file from emoji (ideally Apple emoji). I thought this should be pretty simple, but with every tool I use, I end up stumbling into a wall.
I also considered working with a set of emoji, for example this one , which I could request if necessary. Unfortunately, the one I'm connected to does not have Unicode 9.0 emoji, such as avocado (🥑) shrimp (🦐) or harambe (🦍). Do you know about such an updated set?
In the code, I tried opentype.js, but it does not support .ttc fonts, which is an extension of the emoji font on my mac (Apple Color Emoji.ttc). I converted the font to .ttf, but that didn't work either:
var opentype = require('opentype.js');
opentype.load('./build_scripts/apple_color_emoji.ttf', function (err, font) {
if (err) {
alert('Could not load font: ' + err);
} else {
console.log("loaded the font",font);
var Canvas = require('canvas')
, Image = Canvas.Image
, canvas = new Canvas(200, 200)
, ctx = canvas.getContext('2d');
var path = font.getPath('🐐🦃', 0, 150, 72);
path.draw(ctx);
console.log('<img src="' + canvas.toDataURL() + '" />');
}
});
The result is as follows:
fontkit, , , .ttc , , Apple Color Emoji.
var fontkit = require('fontkit');
var font = fontkit.openSync('./build_scripts/Apple Color Emoji.ttc');
.ttf, svg:
var fontkit = require('fontkit');
var font = fontkit.openSync('./build_scripts/apple_color_emoji.ttf');
var run = font.layout('🐐🦃');
var svg = run.glyphs[0].path.toSVG();
console.log(svg);
: ? emoji, .png , , , .
EDIT:
emoji ( rodrigopolo). :
var emoji = "😊".codePointAt(0).toString(16);
var emojiFile = fs.readFileSync('./my-emoji-folder/' + emoji + '.png');
, , - !
:
, emoji Unicode 8.0, Unicode 9.0. gemoji, . ruby ( ), :
git clone https://github.com/github/gemoji.git
cd gemoji
bundle install
bundle exec gemoji extract some-directory/emoji
Unicode 9.0 emoji /emoji!