JDK-8290866 : Apple Color Emoji turns gray after JavaFX version 18
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: openjfx18
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2022-07-22
  • Updated: 2022-12-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
openjfx20Unresolved
Related Reports
Relates :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
OS: MacOS 12.4
JDK: openjdk version "11.0.13" 2021-10-19 LTS

A DESCRIPTION OF THE PROBLEM :
Apple Color Emoji do not has color after JavaFX 18,  JavaFX 17.0.* and before works well.

I did some tests,  the following commit trigger this problem:
8236689: macOS 10.15 Catalina: LCD text renders badly
The emojis become colorful again when revert this commit.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the source code and run, a window having a emojis text label will display.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The emojis show with color.
ACTUAL -
Emojis is gray, with no color.

---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.text.Font;
import javafx.stage.Stage;

public class Test extends Application {

    @Override
    public void start(Stage stage) {
        Label label = new Label("🐢πŸ”₯🎎");
        label.setFont(new Font(30));
        Scene scene = new Scene(label);
        stage.setWidth(400);
        stage.setHeight(100);
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }

}
---------- END SOURCE ----------

FREQUENCY : always



Comments
More problems. Even if we go back to when it is supposed to "work", it doesn't work. The Emoji is rendered with the wrong colors. That is because the shader is designed for text and so the text color property set is the base for the rendering and is blended into the value in the Emoji image. On top of that there's a gamma adjustment applied in the LCD text shader which is needed when these are glyph images to reduce fringing but just adds an (albeit small) distortment to the color of edge pixels. So I don't think we should be using the same shader here. FWIW if I force the software pipeline the colours are correct .. hmm .. So this leads us to need to 1) Identify when we have a Color Glyph 2) 'Break' the string drawing at that point 3) Render the color glyphs as images, using the image data from the font and drawn at an appropriate offset based on glyph metrics This could be segmented string drawing, or it could be "just" swapping out shaders, within a Graphics.drawString call. both likely have their own drawbacks and consequences and we need to see how it works for non-shader cases. 4) Continue this for subsequent emojis, then resume rendering text segments 5) Rinse and repeat until done. Right now I don't know how to do #1 .. I haven't found any glyph info that macOS provides to distinguish it. Also if I print a node with Emoji characters, they are not printed. This may be something on the Java 2D side of printing, that affects doing this via glyph ids, since Java 2D definitely prints these using character codes (I verified). Then there's https://bugs.openjdk.org/browse/JDK-8291469 - emojis are half size on retina. So basically nothing about Emojis works properly, not in any release.
15-12-2022

As another data point (issue), javafx.scene.Text defaults to GRAY .. and in those earlier releases in such a case Emojis are also gray. Basically the original implementation of Emoji was not correct, and this bug is a consequence of that.
12-12-2022

I can also confirm that this means that in all previous releases if you specified -Dprism.lcdtext=off that Emojis are greyscale. It also means the user workaround to this in FX 18 is -Dprism.lcdtext=true.
23-08-2022

This is just about macOS + color Emojis. I am sure this was an unintended consequence of disabling LCD text. Probably this means we can't disable it in such a straightforward way. OTOH it is fortunate we didn't remove the support ..
04-08-2022

Checked with attached test case in Windows 10, observed with no color, gray emojis<attached screenshot> Test Result - no color emoji's observed in 8u341, openjfx11, openjfx17, openjfx18, openjfx19.
22-07-2022