-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: emoji support #505
Comments
Assuming that you're talking about Windows, printing Emoji to Terminal works already via the That being said, full support for grapheme clusters (i.e. user-perceived characters) would be appreciated not for Emoji, but for all the non-Latin languages where a series of |
import com.ibm.icu.text.BreakIterator; public static List<String> getGraphemeClusters(String self) {
List<String> characters = new ArrayList<String>(self.length());
BreakIterator i = BreakIterator.getCharacterInstance();
i.setText(self);
for (int begin = 0, end = 0; (end = i.next()) != BreakIterator.DONE; begin = i.current()) {
characters.add(self.substring(begin, end));
}
return characters;
} The JDK built-in |
Seems certainly doable but would require a significant change (or addition) to the Lanterna interfaces. Currently, Also, Windows Terminal only displays emoji correctly if running a WSL session |
I don't see why emoji wouldn't work with the current system, given that we can do CJK characters just fine. I'll investigate, maybe it's the terminal encoding that needs to be updated. |
Interesting, so the CJK detector incorrectly flags |
Ok, I see the problem now. Java char type isn't able to store emoji: |
Yes, |
The problem I'm finding is that even |
Have been browsing articles and it really seems like while we can get the number of code points, there's no way to know if these code points are combined into a single character, or if that character is double or single width! |
Yep, pretty much. You can use the public static List<String> getGraphemeClusters(String self) {
List<String> characters = new ArrayList<String>(self.length());
BreakIterator i = BreakIterator.getCharacterInstance();
i.setText(self);
for (int begin = 0, end = 0; (end = i.next()) != BreakIterator.DONE; begin = i.current()) {
characters.add(self.substring(begin, end));
}
return characters;
}
It might make sense to make the
|
Ok, so here's what we'll do. In 3.0 we'll restrict TextCharacter to BMP only, with an override if you really know what you're doing. In 3.1, also restrict but change to use String internally and let you supply your own "String" character for complicated emoji. Will try this out. |
Ok, I misunderstood the BMP plane again. I've just blocked 3.0 from creating TextCharacters from surrogate char:s at least. So next will use the BreakIterator above to in 3.1 to try to group characters. |
Okay, I've re-worked TextCharacter to support this: |
Ok, code is merged. If you clone and build release/3.1 (I'll do another release in a week or so) you should be able to print emoji as double-width and your magic บุ character only occupying one column. Please try it out and report back before I close this. |
@mabe02 , cant print BOMB character "\uD83D\uDCA3" or 💣 using Lanterna 3.2.0-master on Windows 7 x64 (SwingTerminalWindow). I just get two rectangles( |
Emojis are a bit "complicated" - they are incompatible with lanterna's
current approach of 1 (java) "char" per
screen-position (cell).
The complicated solution would be to store Strings for each cell, but that
would lead to a more or less
complete rewrite of the whole library.
Eventually it might happen, and it will not only enable emojis, but also
enable some glyphs in
some scripts, that get combined out of several characters. But it may be
too early to start
holding your breath for it.
…On Tue, Oct 15, 2024 at 6:35 AM Austin ***@***.***> wrote:
@mabe02 <https://github.com/mabe02> I too can't get emojis working. I'm
testing on 3.1.2 and 3.2.0-alpha1 from maven. I'm only getting rectangles
in the swing window and question marks in the normal terminal window in
Ubuntu. Is there something I need to do to enable them or to display them.
Thanks for your assistance!
—
Reply to this email directly, view it on GitHub
<#505 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABIDBMX355XFJWSX4E6RUJDZ3SLQLAVCNFSM6AAAAABP6HSSCSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJSHA3TOMZQGY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
The code
textGraphics.putString(0, 3, "🍕")
results in two question mark characters being displayed in the terminal. At the same timeSystem.out.println("🍕")
works as intended (at least in terminal emulators supporting emojis: ie. the new Windows Terminal).Is it possible to support this use-case?
I guess the emoji codepoints do not fit into
char
type that is used inTerminal.putCharacter
so this would require major changes.The text was updated successfully, but these errors were encountered: