Can JavaFX render full colour emojis? Is the greyscale rendering on macOS
intentional?
https://bugs.openjdk.org/browse/JDK-8290866
I was looking at this before we started our winter break, and realised it was
going to be a chunk of work.
So not intentional but anything that ever appeared to work was just
serendipitous.
Presumably the smaller scale and vertical shift on macOS are bugs?
Not noticed vertical shift but for the size problem this was already reported
but not yet investigated
https://bugs.openjdk.org/browse/JDK-8291469
Can Swing on Windows render emojis in colour like it does on macOS?
You mean Java 2D ? Swing is "FX Controls" whereas Java 2D is "FX Graphics".
What you see on Windows is because Windows Emoji fonts also contain
standard glyphs and so any font / text code that doesn't know about Emojis
uses those so gets something sensible, just not in colour.t
Apple's Emoji font just contains PNG images at several sizes .. CoreText scales
the closest image of the same size or larger to what is requested.
BTW GDI will never be updated to report Emoji glyphs, but I think Java 2D
on Windows can use freetype for that rather than more complex migration to
DirectWrite.
(Btw, SwingPane on Windows 11 doesn’t paint at all until it is “provoked” with
some sort of event,
like dragging the window so it is partially obscured.)
I think Kevin recently discovered this and there's a bug open.
> And finally, is there any hope to get cross-platform support for
full colour emojis in a JavaFX application
> via Text nodes, or would it be best to abandon the idea altogether
and use Image nodes for them instead?
Well, there is not going to be a cross-platform way for this to work
internally
Some code can be cross-platform but platform-specific code is inevitable.
I mean in the FX implementation. I am not suggesting FX user apps try this
So it is probable that Emoji support will appear one platform at a time but
will always be cross-platform to user code .. it'll just be a matter of
whether it works or not.
But the goal is (or should be) that they appear in colour in Text nodes
and UI controls
no matter what the text rendering mode. There may be some challenges
along the
way to this, but that is the goal.
-phil.
On 1/1/23 11:02 AM, Scott Palmer wrote:
I’ve been experimenting, trying to figure out a cross-platform way of
displaying emojis in a JavaFX application. It has been interesting.
I tested on macOS and Windows 11. On macOS I explicitly set the font to “Apple
Color Emoji”, on Windows 11, I used “Segoe UI Emoji”. Those appear to be the
standard fonts for emojis on the respective platforms.
On macOS with JavaFX, emojis render in monochrome with shades of grey, smaller than they should be and shifted down slightly, sometimes cropping off the bottom pixels. With Swing (via SwingPane) they render in full colour the same as native applications.
On Windows with JavaFX the emoji is rendered in black and white (no shading)
for both JavaFX and Swing. This is the same as how WordPad renders them, but
different than Microsoft Word, which will show the emojis in full colour. The
emojis are the right size and not vertically shift as they are on macOS.
If I set the font to something else, I used “Fira Code” that I downloaded so it
should be the exact same on both platforms, I get different behaviour.
On Windows 11 with JavaFX the \uFE0F combining character that indicates the previous
character should be rendered as an emoji causes a blocked ? to print after a
non-emoji heart character. (To get a “Red Heart” emoji I am using the standard
Unicode heart “\u2764” followed by "\uFE0F”.)
Swing on macOS still renders full colour emojis, but on Windows 11 it claims it
can’t render the emoji characters at all - sure enough
java.awt.Font.canDisplay(codePoint) returns true on macOS and false on Windows
11, even though the font is the same.
If I use a logical font, e.g. “Monospaced”, Swing renders the emojis the same
as when using the explicit emoji font on both platforms, as does JavaFX on
macOS. However, JavaFX on Windows 11 still prints the blocked ? for \uFE0F.
So a few questions:
Can JavaFX render full colour emojis? Is the greyscale rendering on macOS
intentional?
Presumably the smaller scale and vertical shift on macOS are bugs?
Can Swing on Windows render emojis in colour like it does on macOS?
(Btw, SwingPane on Windows 11 doesn’t paint at all until it is “provoked” with
some sort of event, like dragging the window so it is partially obscured.)
And finally, is there any hope to get cross-platform support for full colour
emojis in a JavaFX application via Text nodes, or would it be best to abandon
the idea altogether and use Image nodes for them instead?
Regards,
Scott