Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible inconsistencies on large monitor with scaling #523

Closed
ijabz opened this issue Apr 28, 2022 · 7 comments
Closed

Possible inconsistencies on large monitor with scaling #523

ijabz opened this issue Apr 28, 2022 · 7 comments

Comments

@ijabz
Copy link

ijabz commented Apr 28, 2022

I have recently moved to Flatlaf, I also moved from Java 11 to Java 17. A couple of user who use scaling on their large monitors have complained the text in my application is now too large compared to other applications. Even without scaling the text seems to be larger than other apps, however in my test on normal size monitor it looks fine and is actually smaller then other apps.

I'm really not clear if there is a Flatlaf issue, Java 17 issue, coding error in my app or user error, but if you could offer any assistance would be appreciated.

Rather than repeat everything here the thread with screenshots can be seen at

https://community.jthink.net/t/blur-update-annoying-enlarged-view/10735/18

@DevCharly
Copy link
Collaborator

That's strange 😕

Are you modifying the default font in some way in your app.
E.g. UIManager.put( "defaultFont", myFont );

Or do you set system properties flatlaf.uiScale or sun.java2d.uiScale?

GTinOZ's problem: Font size is correct at startup, but changes after a few seconds to double size (from 17px to 34px). Icons and gaps are unchanged.

I've no idea why this happens. FlatLaf gets the font from desktop property win.messagebox.font and also updates the font if that changes. E.g. user changes text size in Windows settings (Accessibility > Text size). Changing display scaling does not change font size.

To find out whether this is the case, you could add some logging to your app. E.g.:

// setup FlatLaf
FlatLightLaf.setup();

Toolkit toolkit = Toolkit.getDefaultToolkit();

// log initial font
log( toolkit.getDesktopProperty( "win.messagebox.font" ) );

// listen to system font changes
toolkit.addPropertyChangeListener( "win.messagebox.font", e -> {
    log( toolkit.getDesktopProperty( "win.messagebox.font" ) );
} );

BTW the default font on Windows is:

java.awt.Font[family=Segoe UI,name=Segoe UI,style=plain,size=12]

GTinOZ: Interestingly, if I change the scale in this setting to (say) 150%, all my other apps shrink, but the Jaikoz app doesn’t.

That's strange because Java 17 apps automatically change scaling when Windows display scaling is changed.
Are you sure that GTinOZ is using Java 17?
Do you bundle Java 17 with our app?

Another (probably unrelated) thing I noticed on the screenshots from GTinOZ and Dani82 is that both are not getting FlatLaf's window decorations (dark title bar and menubar embedded into window title bar), but paultaylor's screenshot show them.

So either both use Windows on ARM processors (which FlatLaf does not yet support),
or access to temporary directory is denied (which is necessary to extract FlatLaf DLL from Jar).

To fix this, you could extract the DLLs from flatlaf.jar, distribute them with your app, and set system property flatlaf.nativeLibraryPath (see https://www.formdev.com/flatlaf/system-properties/) so that FlatLaf can find them.
See also PR #453

@ijabz
Copy link
Author

ijabz commented Apr 29, 2022

thankyou for looking at this, I think the dll extraction thing is likely the problem. On my devlopment machine where i am adminstrator it is all fine, but I just downloaded my application and tried it another PC, and it also incorrectly continued to show lighttitle bars when in dark mode.

I'm using the standard jpackage tool for Windows, so for the existing installed version of Jaikoz on my dev machine I have removed the dlls from flatlaf.jar to sucessfully replicate the the titlebar issue, and then I tried to fix it by putting the dlls into C:/Program Files/Jthink/Jaikoz/app

and adding a line to Jaikoz.cfg

[JavaOptions]
java-options=-Djpackage.app-version=11.4
java-options=-Dhttps.protocols=TLSv1.1,TLSv1.2
java-options=-Dflatlaf.nativeLibraryPath="C:\Program Files\Jthink\Jaikoz\app"

but it has no effect, the title bar remains light

So I seem to be doing something wrong but cant see what ?

@ijabz
Copy link
Author

ijabz commented Apr 29, 2022

To answer some of your other questions They are on Intel not arm, Im not modifying fonts or using any flatlaf scaling

@ijabz
Copy link
Author

ijabz commented Apr 29, 2022

Okay fixed the dll issue, didnt realize have to store in folder structure that matches the jar, i.e
C:\Program Files\Jthink\Jaikoz\app\com\formdev\flatlaf\natives, if I put in app it actually works without using Dflatlaf.nativeLibraryPath guess must look there by default. I will get users to try and see if helps with font problem

@DevCharly
Copy link
Collaborator

didnt realize have to store in folder structure that matches the jar, i.e C:\Program Files\Jthink\Jaikoz\app\com\formdev\flatlaf\natives

Hmm, that's not true. If system property flatlaf.nativeLibraryPath is set to a directory, then the DLL is loaded from that directory:

String libraryName = "flatlaf-windows-x86";
if( SystemInfo.isX86_64 )
libraryName += "_64";
String libraryPath = System.getProperty( FlatSystemProperties.NATIVE_LIBRARY_PATH );
if( libraryPath != null ) {
File libraryFile = new File( libraryPath, System.mapLibraryName( libraryName ) );
if( libraryFile.exists() )
return new NativeLibrary( libraryFile, true );

@ijabz
Copy link
Author

ijabz commented May 12, 2022

OK, sorry must just be me getting confused have that bit working now. One customer got round issue by using -Dflatlaf.uiScale to shrink size, but don't know the underlying cause.

@remcopoelstra
Copy link

Please see issue #580, I think you are also encountering the problem where JPackage creates a windows executable without a manifest, this causes problems with dpi-awareness which can result in large fonts. I was able to solve this by using OpenJDK 19 for creating a JPackage'd app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants