Request - Adjust fonts in the java app.

djve

New member
I have a brand new laptop: 4k screen! Beautiful after 8 years, except for starting KoLMafia. The relay browser is not an issue.

This defaults to native resolution, or close to it. This means the font in the app is about 1mm in height for the capital letters. Not an issue if I was in my 20s but I'm in late 50s and my eyes are not like they used to be. This is very, very hard to read.

Can we get a setting that allows the java app to have larger fonts for the visually impaired? Or hit me with the clue bat on the settings I missed?

openjdk 11.0.6 is what I'm using for my java binary if it's any help.

Thanks,

David
 
Last edited:

Veracity

Developer
Staff member
I'm moving this to Community Suport. There are two threads there about this issue.

Upgraded Computer New Screen Resolution Makes Mafia Almost Unuable
Adjust Text-Size in Mafia Interface

Near I can tell, this is an issue with Windows systems, there are workarounds you can make to your Java environment, and there is nothing whatsoever we can do to our .jar files to make this work for you. Can you confirm that you are running on Windows?

FWIW, on my Mac Mini running OS-X 10.14.6, my monitor is 1920x1080 - half the resolution in both axes as 4K - but I saw no display issues in KoLmafia when I upgraded to that from a smaller, less resolute, screen.

This is an OS (or Java support for an OS) issue.
 
Last edited:

djve

New member
Thanks for that. I had no problems with a 2k screen either. It gets to be an issue when going to 4k.

I'm running Ubuntu 20.04, not windows. But it's still an interesting issue.
 

Veracity

Developer
Staff member
According to this java ticket, perhaps Java 9 would solve this issue for Windows and Linux.
Of course we just recently set up our compile and target environment to be Java 8.
 

fronobulax

Developer
Staff member
I answered elsewhere. But the problem went away on Windows about Java 9 so I would focus on differences between Oracle Java and OpenJDK and whether the OS is running on the hardware or in a virtual environment.
 

djve

New member
From the Discord channel on Mafia and Ash an simple answer is given:
https://discord.com/channels/466605739838930955/534709227260870656/767670710612787240

Windows is similar to: -Dsun.java2d.dpiaware=false
I'm on Ubuntu 20.04 using OpenJDK 14.0.1 and I had to use: -Dsun.java2d.uiScale=2.5

So this works but it seems if your not comfortable with command line this will worry a lot of people.

It would be nicer if someone could add a scaling parameter that could be change.
 

fronobulax

Developer
Staff member
From the Discord channel on Mafia and Ash an simple answer is given:
https://discord.com/channels/466605739838930955/534709227260870656/767670710612787240

Windows is similar to: -Dsun.java2d.dpiaware=false
I'm on Ubuntu 20.04 using OpenJDK 14.0.1 and I had to use: -Dsun.java2d.uiScale=2.5

So this works but it seems if your not comfortable with command line this will worry a lot of people.

It would be nicer if someone could add a scaling parameter that could be change.

Feel free to write and propose a patch. I could not figure out how to inject a command line parameter before and if anything my knowledge is degrading.

My previous point concerning OpenJDK vs Java remains. The problem went away for me on Java 9 (above) on Windows so the environment is a factor.

Finally there is an effort in progress that might make mafia more consistent with Java Look & Feel. If that happens then the ability to expose various UI parameters such as font size will be much easier.

Not the answer you're looking for but maybe someone smarter will become interested.
 

MCroft

Developer
Staff member
Feel free to write and propose a patch. I could not figure out how to inject a command line parameter before and if anything my knowledge is degrading.

My previous point concerning OpenJDK vs Java remains. The problem went away for me on Java 9 (above) on Windows so the environment is a factor.

Finally there is an effort in progress that might make mafia more consistent with Java Look & Feel. If that happens then the ability to expose various UI parameters such as font size will be much easier.
If we can get it to work (see below), we can make it a preference and give it a control in the Look and Feel UI, but horse first, then cart...

djve, can you modify source code and compile? I can build you a one-off patch, but if you want to try different combinations of properties, it would be faster if you did it (and made a patch).

Mafia sets some other jdk parameters in the main app, but I cannot test this (or I can say that it didn't have any effect on my mac). I have no idea if it changes it soon enough for it to work.

This can go around line 190 of KoLmafia.java. If it works, we can figure out how to make sure it's limited to linux HiDPI systems and not hardcode it
Code:
		// experimental!  very...
		if ( System.getProperty( "os.name" ).startsWith( "linux" ) )
		{
			System.setProperty( "sun.java2d.uiScale", "2.5" );
		}
 

fronobulax

Developer
Staff member
My recollection is that System.setProperty( "sun.java2d.uiScale", "2.5" ); did not work because the property was used when building the JRE, before any mafia classes were loaded. I'd love to be wrong but...

I also seem to recall that when it was set on the command line, there were still places in mafia where the text size was unchanged. If they still exist we'll get them with the L&F work...
 

MCroft

Developer
Staff member
My recollection is that System.setProperty( "sun.java2d.uiScale", "2.5" ); did not work because the property was used when building the JRE, before any mafia classes were loaded. I'd love to be wrong but...

I also seem to recall that when it was set on the command line, there were still places in mafia where the text size was unchanged. If they still exist we'll get them with the L&F work...

Yeah, I assumed it wasn't going to be that easy. There are 3-4 properties suggested on the web, but they're probably all in the same boat. This Stack Overflow comment was what I was thinking.

FlatLaf Look and Feel claims it's HiDPI aware, so maybe try that patch and see if it solves the problem? I'm sorry I can't see this, because it would be a lot easier to test little changes...

FlatMap Laf has a complete customize toolkit, which looks overwhelming, but fun for tweakers. All XML based, so you don't have to worry about users importing strange classes. That could be in "phase not 1"...

djve, you can try to move one step up the track by setting the GDK_SCALE environment variable. At least it's better than a CLI property...
 

fronobulax

Developer
Staff member
OpenJDK supposedly fixed this circa v9 in 2017.

Since djve has been hoping for a fix since March 2020 perhaps there is a vocabulary issue? A screenshot might confirm that the reported problem and the problem fixed in Java 9 really are the same thing?
 

MCroft

Developer
Staff member
OpenJDK supposedly fixed this circa v9 in 2017.

Since djve has been hoping for a fix since March 2020 perhaps there is a vocabulary issue? A screenshot might confirm that the reported problem and the problem fixed in Java 9 really are the same thing?

djve, linux will let you install multiple JREs at the same time and you can switch between them by changing the JAVA_HOME variable. Can you try the latest version of 9 on your HiDPI laptop? We can't really fix the JDK/JRE, but if we find a JRE it's fixed in, we can point people to the right one or report a regression if there is one.

https://adoptopenjdk.net/archive.html?variant=openjdk9&jvmVariant=openj9
 
Top