简体   繁体   English

Java Swing 标签中的彩色表情符号

[英]Colored Emojis in Java Swing Labels

I was wondering how to dispaly colored emojis in swing. I have a feeling that the Swing (awt) font engine is unable to do this.我想知道如何在 swing 中显示彩色表情符号。我感觉 Swing (awt) 字体引擎无法做到这一点。 I've tried using the windows emoji font ( Segoe UI Emoji ), but sadly it only displays the monochrome variants.我试过使用 windows 表情符号字体 ( Segoe UI Emoji ),但遗憾的是它只显示单色变体。 Is there any UIManager-Property or Client-Property that I can set in order to get the non-monochrome variant or is Swing simply unable to do this?是否有任何我可以设置的 UIManager-Property 或 Client-Property 以获得非单色变体,或者 Swing 根本无法做到这一点?

I have also noticed that by default Swing doesn't display emoji at all.我还注意到默认情况下 Swing 根本不显示表情符号。 I thought that if there is an emoji font available, that there'd be some kind of fallback.我认为如果有可用的表情符号字体,就会有某种后备。 Usually an emoji font doesn't contain things besides emoji as far as I understand.据我所知,表情符号字体通常不包含表情符号以外的内容。 So for example I would use Segoe UI which would use Segoe UI Emoji for the emojis.因此,例如,我将使用Segoe UI ,而 Segoe UI 将使用Segoe UI Emoji作为表情符号。 On the other hand it should be possible to use Segoe UI for the normal text and Noto Color Emoji for the emojis.另一方面,应该可以对普通文本使用Segoe UI ,对表情符号使用Noto Color Emoji Am I missunderstanding something here?我在这里误解了什么吗?

Swing is not built to support colored emojis. Swing 不支持彩色表情符号。

Those are usually rendered by web browsers, so the Java-FX WebView might be able to support them (AFAIU it actually embeds a browser).这些通常由 web 浏览器呈现,因此 Java-FX WebView可能能够支持它们(AFAIU 它实际上嵌入了浏览器)。

Swing, OTOH was designed to handle a sub-set of HTML 3.2 (yes, it's that old). Swing,OTOH 旨在处理 HTML 3.2子集(是的,它就是那么旧)。

As of java 17, color emojis are now supported by swing (at least on macOS).从 java 17 开始,swing 现在支持彩色表情符号(至少在 macOS 上)。 Jira ticket here , and github pr here .这里是 Jira 票,这里是 github pr。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM