JavaFX controls have large size on Raspberry Pi

Philip Race philip.race at oracle.com
Mon Apr 20 21:18:37 UTC 2020



 > I would start by looking at what Font.getDefault().getSize() returns 
since everything should be based off that.

I think the code below is the code that decides what the code above 
should return

 > Another thing to check is that the reported DPI of the screen is 
correct.

The way I read the code below is that it wants the default font to be 
1/6 of an inch high on the screen.
I think any smaller than 6 lines per inch and it will be hard to read. 
To do this correctly, it relies on
the y-res being accurate for the device.

So I would follow the path Kevin suggests. For example if something is 
wrongly returning the *dimension* of
the screen when it should be the *dpi* of the screen then you'd have 6 
lines of text filling up the screen.

-phil.

On 4/20/20, 1:56 PM, Kevin Rushforth wrote:
> Another thing to check is that the reported DPI of the screen is correct.
>
> -- Kevin
>
>
> On 4/20/2020 1:25 PM, David Grieve wrote:
>> The sizes of controls are controlled by CSS styles. Things like 
>> borders, backgrounds, padding, insets, all of
>> that defaults to the styles in a stylesheet. Most sizes are 'em' 
>> units, meaning they are relative to the size
>> of the font. JavaFX CSS will use the Font.getDefault() font size if 
>> there is no font explicitly set in either the
>> styles or in the application code.
>>
>> I would start by looking at what Font.getDefault().getSize() returns 
>> since everything should be based off that.
>> It could also be an issue with the default stylesheets themselves.
>>
>> -----Original Message-----
>> From: openjfx-dev <openjfx-dev-bounces at openjdk.java.net> On Behalf Of 
>> Alexander Scherbatiy
>> Sent: Monday, April 20, 2020 2:16 PM
>> To: openjfx-dev at openjdk.java.net
>> Subject: [EXTERNAL] JavaFX controls have large size on Raspberry Pi
>>
>> Hello,
>>
>> 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 size.
>> 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?
>>
>> [1]
>> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fopenjdk%2Fjfx%2Fblob%2Fec8608f39576035d41e8e532e9334b979b859543%2Fmodules%2Fjavafx.graphics%2Fsrc%2Fmain%2Fjava%2Fcom%2Fsun%2Fjavafx%2Ffont%2FPrismFontFactory.java%23L1944&data=02%7C01%7CDavid.Grieve%40microsoft.com%7Cc0b7e923fe4346bf947608d7e55746f0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637230035326172309&sdata=rEz4bxNE07aW5f22AXWPRLNffwoIixvNxJopLM%2Bfbi4%3D&reserved=0 
>>
>> [2]
>> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fopenjdk%2Fjfx%2Fblob%2Fec8608f39576035d41e8e532e9334b979b859543%2FbuildSrc%2Farmv6hf.gradle%23L182&data=02%7C01%7CDavid.Grieve%40microsoft.com%7Cc0b7e923fe4346bf947608d7e55746f0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637230035326172309&sdata=Fv2sKXwfwuo6JsD0CyeoF6iDmq8rDk5goPCsK31p1Sk%3D&reserved=0 
>>
>>
>> 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) {
>>           launch(args);
>>       }
>>
>>       @Override
>>       public void start(Stage primaryStage) {
>>           primaryStage.setTitle("Hello World!");
>>       Button button = new Button("Hello, World!");
>>
>>           StackPane root = new StackPane();
>>           root.getChildren().add(button);
>>           primaryStage.setScene(new Scene(root, 300, 250));
>>           primaryStage.show();
>>       }
>> }
>> ----------------------------
>>
>> Thanks,
>> Alexander.
>>
>>
>


More information about the openjfx-dev mailing list