Color Emoji as sprites

I’ve discovered that the new text rendering function introduced in v1.3 renders the colour emoji font. The font has a quite a few glyphs that would be useful for games. You can even type colour emoji into string literals in the Codea editor!

You need to acivate the emoji international keyboard in Settings > General > Keyboard.

Here’s an helper function that turns some text into an image for use as a sprite or texture. I can’t include an example of its use because the forum software barfs on the Unicode for the emoji glyphs.

function spriteFromFont(spriteFont, spriteFontSize, glyphs)
    pushStyle()
    
    font(spriteFont)
    fontSize(spriteFontSize)
    fill(255, 255, 255, 255)
    smooth()
    
    local w, h = textSize(glyphs)
    local sprite = image(w, h)
    
    setContext(sprite)
    textMode(CORNER)
    text(glyphs, 0, 0)
    
    setContext()
    popStyle()
    
    return sprite
end

It’s a really cool side-effect of Apple’s great font and type support. Very handy helper function, too!

I believe you can just enable the Emoji keyboard in Settings → Keyboards → International Keyboards → Add New Keyboard → Emoji.

(I updated your post to fix the code formatting)

You’re right. The app I downloaded gave misleading instructions.

Cool function, Nat! Thanks for sharing

Just a heads up, I’m planning to make a class where you say eEmoji(character,x,y) which will throw the emoji character. Now that’s easy to do, but the good thing about this is that it will automatically change it to emoji font and then change it back to the font you had. :slight_smile:

By the way, does mesh work with drawing text?
Thanks!

Ahh! I didn’t see your code. There was an error loading the code :frowning:

I also like to use the chinease simplified handwriting keyboard to draw character. Just recolor them, and they’re awsome. I also like Touch&Copy to get more character.

Mesh doesn’t work with drawing text directly, but using setContext() you can easily make an image with your text, then use that as the texture for the mesh. I posted some sample code that does just that in another thread… somewhere…