Bad character spacing (kerning) in JavaFX font rendering (on Linux)

I started developing an application in JavaFX, and I ran into a problem, I could find very little useful information about the fact that the spacing between characters in Linux is very uneven. I'm not talking about the width of different characters, but about spaces between characters.

It appears in plain text, but the following example illustrates the effect better than usual. Take a look at the first row. The space between the first two characters is less than between the second and third. This also happens between the sixth and seventh characters and several others:

Uneven character spacing

Swing does not have this problem, and JavaFX does not have this problem on Windows, or it is barely noticeable on this OS. Also, this is not a serious problem for the Mac. For comparison, here is an example of output on a Mac Retina MacBook Pro, in mid-2014, with OS X 10.12.6 and Java 9.0.4:

enter image description here

Does anyone know if this is a bug in the JavaFX font rendering engine? If so, is there a workaround?

I'm really starting to wonder if I should change the structure, since, in my opinion, such poor font rendering is unacceptable.

There is one more question on this question, but it has not been answered yet: Why does JavaFX add extra letter spacing when using the Text component and how to fix it?

Linux, Manjaro, Debian :

package de.localtoast.fonttest;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class FontTest extends Application {

    @Override
    public void start(Stage primaryStage) {
        VBox root = new VBox();
        Label label1 = new Label("0000000000000000000000");
        Label label2 = new Label("OOOOOOOOOOOOOOOOOOOOOO");
        Label label3 = new Label("oooooooooooooooooooooo");

        root.getChildren().add(label1);
        root.getChildren().add(label2);
        root.getChildren().add(label3);

        Scene scene = new Scene(root, 300, 250);

        primaryStage.setTitle("Font Test");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

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

jewelsea openjfx-dex mailing. , :

JavaFX, Linux. JavaFX , . Manjaro, Archlinux. Archlinux , , Microsoft.

freetype2-ultimate5 AUR, , , freetype2-cleartype . - .

+4

-Dprism.lcdtext=false , , Linux , , .

0

Source: https://habr.com/ru/post/1694544/


All Articles