Git Product home page Git Product logo

gdx-emojisupport's Introduction

gdx-EmojiSupport

LibGDX Emoji support (glyphs injection technique)

Usage:

  1. Just drop the EmojiSupport.java into your project
  2. Copy the emoji atlas files into your assets folder
  3. Add code support
...
 EmojiSupport emojiSupport;   // global instance
 ...
 // Create instance, load emojis and add to existing font(s)
 emojiSupport= new EmojiSupport();
 emojiSupport.Load(Gdx.files.internal("data/emojis25.atlas"));
 emojiSupport.AddEmojisToFont(skin.getFont("default-font"));
 ...
 // Filter/translate emojis before display
 Label label1 = new Label(emojiSupport.FilterEmojis(str), skin);

Description of the problem:

Current limitation: The Glyph class uses a char as index so should need a lot of work to change all the logic (ex: line-breaks) to use multi-chars (unicode emojis). So the solution is to "inject" new Glyphs (from another Texture page) to the current BitmapFont using a special char index ( > 0xB000). When a string includes an Emoji Code, for example: ๐Ÿ˜Ž (\ud83d\ude0e) [two chars] is replaced by a char 0xB001 [one char] that points to its emoji Glyph texture region.

Benefits:

  • Only one emoji.png (Atlas) file needed (can be added to all fonts in the App)
  • Don't messes the GlyphsRun, BitmapFonts, BitmapFontCache, etc core Gdx classes
  • You can add only your "preferred" emojis (reduce space)
  • You can use emojis at greater or lower resolutions (will scale to the font size)
  • No cpu-cost in runtime (it's exactly the same as any other char)
  • Also supported in FreeType run-time generated fonts
  • Supports multi-pages emojis (emoji atlas with more than one png).
  • Tested in iOS (RoboVM).

Drawbacks:

  • Always need to call to FilterEmojis to translate double-char codes (unicode) to 0xB000+i chars (This may not be a drawback as only in very few places you need to use texts with Emojis)
  • Text setColor() functions not supported (only in b&w emojis).

To Do work:

  • Not tested in TextAreas.
  • Flags emojis and some other emojis are missing
  • Not supported skin-tone modifiers

USEFUL LINKS:

All Unicode chars : https://en.wikipedia.org/wiki/List_of_Unicode_characters

Tables : https://www.utf8-chartable.de/unicode-utf8-table.pl

Conversions : https://stackoverflow.com/questions/33320058/converting-unicode-symbols-to-their-code

Java surrogate chars : https://docs.oracle.com/javase/8/docs/api/java/lang/Character.html

Special char FE0F : https://www.fileformat.info/info/unicode/char/fe0f/index.htm

Emoji images source : https://github.com/stv0g/unicode-emoji

Inspirated in : https://github.com/taluks/libgdx-emodji

CHANGELOG

  • v.1.1 - Support for multi pages emojis (bugfix)
  • v.1.0 - Initial release

Color or B&W emojis

Linear (anti-aliasing) or Nearest Filter

Emojis collections

Color Emojis 25x25 https://github.com/stv0g/unicode-emoji/tree/master/apple

Packed with TexturePacker : 821 emojis , 1.32 Mb size

Black and White Emojis 25x25 https://github.com/stv0g/unicode-emoji/tree/master/symbola

Packed with TexturePacker : 789 emojis , 0.36 Mb size

gdx-emojisupport's People

Contributors

davidpdev avatar

Stargazers

Faisal rasak avatar  avatar  avatar Jochem Barelds avatar  avatar Anton avatar  avatar Benjamin Schulte avatar Alex Driedger avatar Brett Dorrans avatar Eytan avatar Fabiitch avatar

Watchers

James Cloos avatar  avatar

gdx-emojisupport's Issues

Only renders emojis on first page of the atlas

Everything worked great when I used the emoji set you provided.

When I wanted to use more emojis (I packed about 1300 from noto-color), it generated more than one texture page for the atlas (in this case 5 png files for the atlas). Any emojis from pages that were not the first page were rendered as the emoji in the same location in the texture on the first page.

Ex: The sword emoji was on the 4th page, 2nd column, 8th row. It got rendered as the soap emoji, which was on the 1st page, 2nd column, 8th row. This happened with all emojis not on the first page.

I think it has to do with

Because page is always set to 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.