JavaFX controls have large size on Raspberry Pi

Alexander Scherbatiy alexander.scherbatiy at
Mon Apr 20 18:15:48 UTC 2020


I run a simple JavaFX application which shows a button with jdk 14.0.1 
on Raspberry Pi and the drawn button has large size.

This is because of the algorithm which is used by 
PrismFontFactory.getSystemFontSize() method [1] to select a system font 
If a system is embedded then the font size is calculated as

     int screenDPI = Screen.getMainScreen().getResolutionY();
     systemFontSize = ((float) screenDPI) / 6f; // 12 points

and the system is detected as embedded because the armv6hf architecture 
is defined as embedded in the armv6hf.gradle file [2].

Raspberri Pi can work both with small touch displays and with big 
monitors. It looks like Raspberry Pi should support two modes for font 
size calculation: one for small screens and another for large.

I would like to contribute a fix for this but I do not know how the 
right fix could look like.
Should there be a special screen size so for smaller screens the font is 
is proportional to the screen size and for bigger screens the font size 
is fixed?
Is there a way to check that used screen is from embedded device?
May be it should be solved in different way?


JavaFX application:
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class ButtonFX extends Application {
     public static void main(String[] args) {

     public void start(Stage primaryStage) {
         primaryStage.setTitle("Hello World!");
     Button button = new Button("Hello, World!");

         StackPane root = new StackPane();
         primaryStage.setScene(new Scene(root, 300, 250));;


More information about the openjfx-dev mailing list