Re: RFR: 8243255: Font size is large in JavaFX app with enabled Monocle on Raspberry Pi

2020-04-27 Thread Alexander Scherbatiy
On Fri, 24 Apr 2020 17:07:25 GMT, John Neffenger 
 wrote:

>>> 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 `javafx.platform.properties` 
>> file in the same directory as the
>> `javafx.base.jar` file instead of looking for it in the parent directory of 
>> the JAR file. I just stepped through the
>> code with this change, and the method `PlatformUtil.loadProperties` now 
>> finds the properties file in the location where
>> it is packaged by the build in the SDK.
>
> Related issues, including the original request for enhancement:
> 
> * [JDK-8100775](https://bugs.openjdk.java.net/browse/JDK-8100775): Means of 
> bundling platform specific settings for
>   glass/runtime
> * [JDK-8115678](https://bugs.openjdk.java.net/browse/JDK-8115678): JavaFX 
> preview on Raspberry Pi
>   requires -Djavafx.platform=eglfb to be set
> * [JDK-8117705](https://bugs.openjdk.java.net/browse/JDK-8117705): Embedded 
> JavaFX can't find javafx.platform.properties
> 
> 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)](https://hg.openjdk.java.net/openjfx/8/master/rt/rev/e4577fd9c0f1)
> In JDK 8, all of the Java property files, including 
> `javafx.platform.properties`, are located under the `jre/lib`
> directory of the JDK, but the JavaFX 8 JAR file `jfxrt.jar` in found in the 
> subdirectory `jre/lib/ext`. The changeset
> above fixed the JavaFX 8 code to look in the parent directory for its 
> properties.  Now, though, the JavaFX SDK puts the
> JAR file `javafx.base.jar` in the same `lib` directory as the property files, 
> so we need to remove the method call that
> changes the path to its parent.

> May I then suggest one additional change to this pull request? It's a 
> two-line fix.
> That change corrects the code to look for the `javafx.platform.properties` 
> file in the same directory as the
> `javafx.base.jar` file instead of looking for it in the parent directory of 
> the JAR file.

I have added the fix for `PlatformUtil.getRTDir()` method to the current pull 
request.

-

PR: https://git.openjdk.java.net/jfx/pull/193


Re: RFR: 8243255: Font size is large in JavaFX app with enabled Monocle on Raspberry Pi

2020-04-24 Thread John Neffenger
On Fri, 24 Apr 2020 08:20:02 GMT, Alexander Scherbatiy  
wrote:

> 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 `javafx.platform.properties` file 
in the same directory as the
`javafx.base.jar` file instead of looking for it in the parent directory of the 
JAR file. I just stepped through the
code with this change, and the method `PlatformUtil.loadProperties` now finds 
the properties file in the location where
it is packaged by the build in the SDK.

-

PR: https://git.openjdk.java.net/jfx/pull/193


Re: RFR: 8243255: Font size is large in JavaFX app with enabled Monocle on Raspberry Pi

2020-04-24 Thread Alexander Scherbatiy
On Fri, 24 Apr 2020 01:27:42 GMT, John Neffenger 
 wrote:

>> Wow, this is going to take some getting used to.  Below is a photograph of 
>> the button and text with two changes:
>> 
>> 1. the code from this pull request, and
>> 2. the `javafx.platform.properties` file moved to its parent directory.
>> 
>> ![withfix](https://user-images.githubusercontent.com/1413266/80160191-d344d380-8581-11ea-8fd4-09023ad30610.jpg)
>> 
>> 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 `isEmbedded` to `true`, picking up the correct screen 
> DPI, and I'm finally getting a good default
> font size: ((167 px/in ÷ 6 per in) ÷ 167 px/in) × 72 points/in = 12.0 points. 
> Amazing.

> @AlexanderScherbatiy Did you move the _javafx.platform.properties_ file to 
> its parent directory manually, as I just did?

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.

-

PR: https://git.openjdk.java.net/jfx/pull/193


Re: RFR: 8243255: Font size is large in JavaFX app with enabled Monocle on Raspberry Pi

2020-04-23 Thread John Neffenger
On Thu, 23 Apr 2020 23:58:19 GMT, John Neffenger 
 wrote:

>> 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:
>> ![normal](https://user-images.githubusercontent.com/1413266/80154159-e05ac600-8573-11ea-897b-49a82baaa10f.png)
>> ![toobig](https://user-images.githubusercontent.com/1413266/80154165-e3ee4d00-8573-11ea-8b67-45670b17b7f1.png)
>>   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:  
>> /home/ubuntu/lib/armv6hf-sdk/lib/javafx.platform.properties
>> 
>> Yet
>> [`com.sun.javafx.PlatformUtil.loadProperties`](https://github.com/openjdk/jfx/blob/master/modules/javafx.base/src/main/java/com/sun/javafx/PlatformUtil.java#L248)
>> looks in the following three locations, in order:  
>> /home/ubuntu/lib/armv6hf-sdk/javafx.platform.properties
>> /home/ubuntu/opt/jdk-14.0.1+7/lib/javafx.platform.properties
>> /javafx.platform.properties
>> 
>> 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 `null` on my system.
>> @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.  Below is a photograph of 
> the button and text with two changes:
> 
> 1. the code from this pull request, and
> 2. the `javafx.platform.properties` file moved to its parent directory.
> 
> ![withfix](https://user-images.githubusercontent.com/1413266/80160191-d344d380-8581-11ea-8fd4-09023ad30610.jpg)
> 
> 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 `isEmbedded` to `true`, picking up the correct screen 
DPI, and I'm finally getting a good default
font size: ((167 px/in ÷ 6 per in) ÷ 167 px/in) × 72 points/in = 12.0 points. 
Amazing.

-

PR: https://git.openjdk.java.net/jfx/pull/193


Re: RFR: 8243255: Font size is large in JavaFX app with enabled Monocle on Raspberry Pi

2020-04-23 Thread John Neffenger
On Thu, 23 Apr 2020 22:43:30 GMT, John Neffenger 
 wrote:

>> See the detailed issue description on: 
>> http://mail.openjdk.java.net/pipermail/openjfx-dev/2020-April/025975.html
>> 
>> The fix 8236448 https://github.com/openjdk/jfx/pull/75 changes
>> [MonocleApplication.staticScreen_getScreens()](https://github.com/openjdk/jfx/pull/75/files#diff-b66ff7fe72c6c5cd26003572ca901bfdL228)
>> method code from
>>> ns.getDPI(), ns.getDPI(), ns.getScale(), ns.getScale(), ns.getScale(), 
>>> ns.getScale()
>> 
>>  to
>>  > ns.getWidth(), ns.getHeight(), 1.f, 1.f, ns.getScale(), ns.getScale()"
>> 
>> 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.
>
> 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:
> ![normal](https://user-images.githubusercontent.com/1413266/80154159-e05ac600-8573-11ea-897b-49a82baaa10f.png)
> ![toobig](https://user-images.githubusercontent.com/1413266/80154165-e3ee4d00-8573-11ea-8b67-45670b17b7f1.png)
>   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:  
> /home/ubuntu/lib/armv6hf-sdk/lib/javafx.platform.properties
> 
> Yet
> [`com.sun.javafx.PlatformUtil.loadProperties`](https://github.com/openjdk/jfx/blob/master/modules/javafx.base/src/main/java/com/sun/javafx/PlatformUtil.java#L248)
> looks in the following three locations, in order:  
> /home/ubuntu/lib/armv6hf-sdk/javafx.platform.properties
> /home/ubuntu/opt/jdk-14.0.1+7/lib/javafx.platform.properties
> /javafx.platform.properties
> 
> 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 `null` on my system.
> @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.  Below is a photograph of the 
button and text with two changes:

1. the code from this pull request, and
2. the `javafx.platform.properties` file moved to its parent directory.

![withfix](https://user-images.githubusercontent.com/1413266/80160191-d344d380-8581-11ea-8fd4-09023ad30610.jpg)

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.

-

PR: https://git.openjdk.java.net/jfx/pull/193


Re: RFR: 8243255: Font size is large in JavaFX app with enabled Monocle on Raspberry Pi

2020-04-23 Thread John Neffenger
On Tue, 21 Apr 2020 16:47:44 GMT, Alexander Scherbatiy  
wrote:

> See the detailed issue description on: 
> http://mail.openjdk.java.net/pipermail/openjfx-dev/2020-April/025975.html
> 
> The fix 8236448 https://github.com/openjdk/jfx/pull/75 changes
> [MonocleApplication.staticScreen_getScreens()](https://github.com/openjdk/jfx/pull/75/files#diff-b66ff7fe72c6c5cd26003572ca901bfdL228)
> method code from
>> ns.getDPI(), ns.getDPI(), ns.getScale(), ns.getScale(), ns.getScale(), 
>> ns.getScale()
> 
>  to
>  > ns.getWidth(), ns.getHeight(), 1.f, 1.f, ns.getScale(), ns.getScale()"
> 
> 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.

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:

![normal](https://user-images.githubusercontent.com/1413266/80154159-e05ac600-8573-11ea-897b-49a82baaa10f.png)
![toobig](https://user-images.githubusercontent.com/1413266/80154165-e3ee4d00-8573-11ea-8b67-45670b17b7f1.png)

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:

/home/ubuntu/lib/armv6hf-sdk/lib/javafx.platform.properties

Yet
[`com.sun.javafx.PlatformUtil.loadProperties`](https://github.com/openjdk/jfx/blob/master/modules/javafx.base/src/main/java/com/sun/javafx/PlatformUtil.java#L248)
looks in the following three locations, in order:

/home/ubuntu/lib/armv6hf-sdk/javafx.platform.properties
/home/ubuntu/opt/jdk-14.0.1+7/lib/javafx.platform.properties
/javafx.platform.properties

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 `null` on my system.

@AlexanderScherbatiy Did you move the *javafx.platform.properties* file to its 
parent directory manually, as I just did?

-

PR: https://git.openjdk.java.net/jfx/pull/193