8243255: Font size is large in JavaFX app with enabled Monocle on Raspberry Pi #193
Conversation
|
Webrevs
|
I couldn't understand why I wasn't hitting this error on the embedded Monocle EPD platform. Stepping through the code with the debugger, I found that JavaFX is looking for the javafx.platform.properties file in the wrong place. I moved the file to its parent directory, the location JavaFX expects, and saw the problem right away. The first image below shows the button and text without the properties file, and the second image shows the problem once the properties file is loaded: So there might be a secondary problem. After unzipping the SDK archive under $HOME/lib, the properties file is located at the following location on my system:
Yet
The first is based on the "runtime directory," the second is based on the value of java.home, and the third is based on the value of javafx.runtime.path, which is @AlexanderScherbatiy Did you move the javafx.platform.properties file to its parent directory manually, as I just did? |
Wow, this is going to take some getting used to.
The native screen on this platform returns 167 for its DPI. In general, the devices I'm testing have pixel densities of either 167 or 300 pixels per inch. |
I got out my trusty C-Thru Ruler (GA-96), and the type now measures 12 points, just as intended. PrismFontFactory.getSystemFontSize } else if (isEmbedded) {
try {
int screenDPI = Screen.getMainScreen().getResolutionY();
systemFontSize = ((float) screenDPI) / 6f; // 12 points
} catch (NullPointerException npe) {
// if no screen is defined
systemFontSize = 13f; // same as desktop Linux
}
} else {
systemFontSize = 13f; // Gnome uses 13.
} Without the platform properties file, I've been running (for years!) with a default font size of 13 pixels, which on this device is very small: (13 px ÷ 167 px/in) × 72 points/in = 5.60 points. Now JavaFX is setting |
I used the full version of jdk 14.0.1 on Raspberry Pi where JavaFX is included in jdk so the file javafx.platform.properties is already in jdk-14.0.1-full/lib directory. To debug the JavaFX on Raspberry Pi I built armv6hf-sdk and just copied the file javafx.platform.properties from the full jdk version with JavaFX to jdk-14.0.1/lib directory of jdk without JavaFX which I used to run my java application with JavaFX modules from armv6hf-sdk/lib. |
May I then suggest one additional change to this pull request? It's a two-line fix: --- a/modules/javafx.base/src/main/java/com/sun/javafx/PlatformUtil.java
+++ b/modules/javafx.base/src/main/java/com/sun/javafx/PlatformUtil.java
@@ -238,8 +238,7 @@ public class PlatformUtil {
// Strip everything after the last "/" or "\" to get rid of the jar filename
int lastIndexOfSlash = Math.max(
s.lastIndexOf('/'), s.lastIndexOf('\\'));
- return new File(new URL(s.substring(0, lastIndexOfSlash + 1)).getPath())
- .getParentFile();
+ return new File(new URL(s.substring(0, lastIndexOfSlash + 1)).getPath());
} catch (MalformedURLException e) {
return null;
} That change corrects the code to look for the |
Related issues, including the original request for enhancement:
The last two issues listed above were fixed by the following changeset: Fix for RT-28035 (Can't find embedded platform properties) and RT-27194 (Must set javafx.platform) In JDK 8, all of the Java property files, including Now, though, the JavaFX SDK puts the JAR file |
I have added the fix for |
Thanks, Alexander! I just tested your pull request again, and JavaFX is now picking up the properties file along with the correct native screen DPI on my Monocle ARM platform. |
I'm confused by this, what is the full version of JDK 14.0.1? JavaFX is not part of the JDK anymore, therefore I don't expect a javafx.platform.properties in the JDK. Iif this is the case, it seems a serious bug to me. |
I used non Oracle jdk 14.0.1 build which full version includes JavaFX. |
@@ -238,8 +238,7 @@ private static File getRTDir() { | |||
// Strip everything after the last "/" or "\" to get rid of the jar filename | |||
int lastIndexOfSlash = Math.max( | |||
s.lastIndexOf('/'), s.lastIndexOf('\\')); | |||
return new File(new URL(s.substring(0, lastIndexOfSlash + 1)).getPath()) | |||
.getParentFile(); | |||
return new File(new URL(s.substring(0, lastIndexOfSlash + 1)).getPath()); |
kevinrushforth
Apr 27, 2020
Member
The previous code looks like a hold-over from JDK 8, where jfxrt.jar was in lib/ext
. It also assumes that the JavaFX runtime is being loaded from a jar URL, which isn't necessarily the case. Probably the only reason it hasn't caused problems before now is that it is only used to locate javafx.platform.properties
. Worth noting is that we won't get here in the case JavaFX is jlinked into the Java runtime, although in that case, the fallback method of locating it relative to the JDK should be used.
I'll take a closer look this specific change, but I think it should be OK.
I'll defer the review as a whole to Johan.
The previous code looks like a hold-over from JDK 8, where jfxrt.jar was in lib/ext
. It also assumes that the JavaFX runtime is being loaded from a jar URL, which isn't necessarily the case. Probably the only reason it hasn't caused problems before now is that it is only used to locate javafx.platform.properties
. Worth noting is that we won't get here in the case JavaFX is jlinked into the Java runtime, although in that case, the fallback method of locating it relative to the JDK should be used.
I'll take a closer look this specific change, but I think it should be OK.
I'll defer the review as a whole to Johan.
kevinrushforth
Apr 28, 2020
Member
I can confirm that this part of the fix is correct. The change to DPI looks correct to me, too.
I can confirm that this part of the fix is correct. The change to DPI looks correct to me, too.
/reviewers 2 |
@kevinrushforth |
Pending review by @johanvos |
@AlexanderScherbatiy This change now passes all automated pre-integration checks. When the change also fulfills all project specific requirements, type
Since the source branch of this PR was last updated there have been 14 commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid automatic rebasing, please merge As you do not have Committer status in this project, an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@kevinrushforth, @johanvos) but any other Committer may sponsor as well.
|
/integrate |
@AlexanderScherbatiy |
/sponsor |
@kevinrushforth @AlexanderScherbatiy The following commits have been pushed to master since your change was applied:
Your commit was automatically rebased without conflicts. Pushed as commit 0385563. |
See the detailed issue description on: http://mail.openjdk.java.net/pipermail/openjfx-dev/2020-April/025975.html
The fix 8236448 #75 changes MonocleApplication.staticScreen_getScreens() method code from
to
so the font size is not properly calculated based on the given DPI value.
I left the platformScaleX and platformScaleY as 1.f because I do not know how it affects Android/Dalvik platform. On Raspberry Pi where I run JavaFX code with Monocle the DispmanScreen is used which have fixed scale 1.0 value so the app works in the same way.
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jfx pull/193/head:pull/193
$ git checkout pull/193