Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8311492

FontSmoothingType LCD produces wrong color when transparency is used

XMLWordPrintable

    • b05
    • generic
    • generic

        ADDITIONAL SYSTEM INFORMATION :
        Tested on Linux and Windows, with Java version 8u361 and with Java 20.1 and JavaFX 20.1

        A DESCRIPTION OF THE PROBLEM :
        When a colour with transparency is used, FontSmoothingType.LCD produces the wrong colour

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run the attached code and compare the colour of the Text nodes with the colour of the border

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The colour of the Text nodes should be the same as the colour of the border, independently of which FontSmoothingType is selected
        ACTUAL -
        When FontSmoothingType.LCD is selected, the color of the Text nodes is wrong

        ---------- BEGIN SOURCE ----------
        public class Transparency extends Application {

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

        @Override
        public void start( Stage primaryStage ) throws Exception {
        primaryStage.setTitle( "prism.lcdtext = " + System.getProperty( "prism.lcdtext" ) );

        Text txt = new Text( "TEST" );
        TextField tf = new TextField( "TEST" );

        ChoiceBox<FontSmoothingType> cb = new ChoiceBox<>( FXCollections.observableArrayList( FontSmoothingType.values() ) );
        cb.getSelectionModel().selectedItemProperty().addListener( ( obs, ol, ne ) -> {
        ( (Text) tf.lookup( ".text" ) ).setFontSmoothingType( ne );
        txt.setFontSmoothingType( ne );
        } );
        Platform.runLater( () -> cb.getSelectionModel().select( FontSmoothingType.LCD ) );
        TextArea ta = new TextArea( "-fx-border-width: 5px;\n"
        + "-fx-font-size: 24px;\n"
        + "-fx-font-family: \"Open Sans\";\n"
        + "-fx-font-weight: bold;\n"
        + "\n"
        + "-fx-background-color: transparent;\n"
        + "-fx-border-color: rgba(0, 44, 111, 0.4);\n"
        + "-fx-text-fill: rgba(0, 44, 111, 0.4);\n"
        + "-fx-fill: rgba(0, 44, 111, 0.4);\n"
        + "\n"
        + "" );
        tf.styleProperty().bind( ta.textProperty() );
        txt.styleProperty().bind( ta.textProperty() );
        HBox root = new HBox( 20 );
        root.setPadding( new Insets( 20 ) );

        final VBox controlBox = new VBox( cb, ta );
        controlBox.setSpacing( 20 );

        final VBox renderBox = new VBox( txt, tf );
        renderBox.setSpacing( 20 );

        root.getChildren().addAll( controlBox, renderBox );

        Scene scene = new Scene( root, 700, 200 );
        primaryStage.setScene( scene );
        primaryStage.show();
        }

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

        FREQUENCY : always


          1. Capture_ubuntu.PNG
            Capture_ubuntu.PNG
            62 kB
          2. Capture.PNG
            Capture.PNG
            27 kB
          3. Transparency.java
            2 kB

              kcr Kevin Rushforth
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: