Class EmojiProcessor

java.lang.Object
com.github.tommyettinger.textra.EmojiProcessor

public final class EmojiProcessor extends Object
Allows getting a RegExodus Replacer that can replace any "correct Unicode" emoji sequences with the single PUA-char representation used by a Font to represent most emoji.
This can parse every emoji in Emoji 14, which is what our version of Twemoji uses. It probably can't parse every emoji in Noto Color Emoji at this point, and might not handle all of OpenMoji, either.
Taken mostly from emoji-regex, which is MIT-licensed.
  • Method Summary

    Modifier and Type
    Method
    Description
    static regexodus.Replacer
    Gets a RegExodus Replacer that will replace any standard Unicode 14 or lower emoji that can be displayed by the given Font with the special Unicode PUA char used by that Font to show that emoji.
    static void
    Initializes the singleton that stores the massive regular expression Pattern this uses internally.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • initialize

      public static void initialize()
      Initializes the singleton that stores the massive regular expression Pattern this uses internally.
    • getReplacer

      public static regexodus.Replacer getReplacer(Font font)
      Gets a RegExodus Replacer that will replace any standard Unicode 14 or lower emoji that can be displayed by the given Font with the special Unicode PUA char used by that Font to show that emoji. The given Font must have a Font.nameLookup, typically by adding an atlas with KnownFonts.addEmoji(Font). If there is no nameLookup in the given Font, this will replace any recognized emoji with the char '?'.
      Parameters:
      font - a Font that already has emoji added to it, typically Twemoji via KnownFonts.addEmoji(Font)
      Returns:
      a Replacer that can be used to replace any readable Unicode emoji in text with their Font-specific char representations