JDK-8278760 : [macos] Text rendering in Menu and MenuItem controls are ugly
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: openjfx17
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: os_x
  • CPU: x86_64
  • Submitted: 2021-12-11
  • Updated: 2021-12-15
  • Resolved: 2021-12-15
Related Reports
Duplicate :  
Description
ADDITIONAL SYSTEM INFORMATION :
macOS Big Sur on Mac mini (late 2014). OpenJDK and OpenJFX 17

A DESCRIPTION OF THE PROBLEM :
The individual glyphs of the default font are rendered too close to each other, with the result that aesthetically a JavaFX application's menu looks terrible when compared to native applications. 
I thought I could work around the problem by using css styling, but setting style class on Menu instances have no effect. The styleClass property of a MenuItem (which Menu extends) doesn't appear to be used. I can make menu items look better with CustomMenuItem, but I cannot do anything about Menu instances.
So I guess this has something to do with JavaFX menus not appearing in the top menu bar on a Mac. If JetBrains can make it work with their Swing-based IntelliJ, why cannot JavaFX applications do the same?

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a simple hello world-type application with a menu and observe the individual glyphs of the font which a rendered partially overlapping each other.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Either render the menu the way native macOS application menus are rendered, i.e. in the system menubar or fix the default rendering of text in all JavaFX controls when running on macOS, since this ugliness can be observed everywhere! It should not require additional effort by a developer to achieve an aesthetically pleasing result by default.
ACTUAL -
All default text rendering on a Mac look terrible, but especially in Menus. It is possible to make text rendering look better through css styling - but not for menus.

---------- BEGIN SOURCE ----------
package com.example.menubug;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

import java.io.IOException;

public class HelloApplication extends Application {
    @Override
    public void start(Stage stage) throws IOException {
        MenuBar menuBar = new MenuBar();
        VBox vBox = new VBox(menuBar);
        Menu menu1 = new Menu("LookAtTheOoooooosInThisMenu");

        menuBar.getMenus().add(menu1);
        Scene scene = new Scene(vBox, 960, 600);
        stage.setTitle("Hello!");
        stage.setScene(scene);
        stage.show();
    }

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

CUSTOMER SUBMITTED WORKAROUND :
No workaround for Menu instances

FREQUENCY : always



Comments
Attached image provided by submitter(ImageBySubmitter.png) Moving it to Dev team for further analysis.
15-12-2021

This is fixed in JavaFX 18 by JDK-8236689, which turns off LCD (sub-pixel) text smoothing on macOS. In answer to the bug reporter's other question about using the macOS system menu, please refer to: https://openjfx.io/javadoc/17/javafx.controls/javafx/scene/control/MenuBar.html#setUseSystemMenuBar(boolean)
15-12-2021

Issue is not reproduced. The output window looks same for Mac OS as well as Windows (Screenshots attached) OS : MacOS BigSur 11.6 OpenJFX 17 : Pass OpenJFX 18ea : Pass OS: Windows 10 OpenJFX 17 : Pass
14-12-2021

additional information requested from submitter: =============================== Checked this issue on both Windows and Mac but couldn't find any difference. Could you please confirm what is the expected and actual behavior here? ===============================
14-12-2021