Mage: Scale interface on Hi-DPI

Created on 15 May 2015  路  13Comments  路  Source: magefree/mage

XMage is really tiny on my shiny Hi-DPI screen on Linux (Fedora 22). It would be great if XMage scaled its interface on Hi-DPI screens (like the rest of my apps do).

GUI enhancement

Most helpful comment

Display scaling can be enabled for Windows 10 as follows:

  1. Install xmage in the usual way. I'm using a "C:\temp\xmage" directory in this example.

  2. Create a "javaw.exe.manifest" file and place it next to javaw.exe in the bundled JRE install (for example, at "C:\temp\xmage\java\jre1.8.0_131\bin") with the following contents:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<description>javaw</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
  <security>
    <requestedPrivileges>
      <requestedExecutionLevel xmlns:ms_asmv3="urn:schemas-microsoft-com:asm.v3"
        level="asInvoker"
        ms_asmv3:uiAccess="false">
      </requestedExecutionLevel>
    </requestedPrivileges>
  </security>
</trustInfo>
<asmv3:application>
  <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
    <ms_windowsSettings:dpiAware xmlns:ms_windowsSettings="http://schemas.microsoft.com/SMI/2005/WindowsSettings">false</ms_windowsSettings:dpiAware>
  </asmv3:windowsSettings>
</asmv3:application>
</assembly>
  1. Run regedit.exe and create a DWORD Value named "PreferExternalManifest" under "Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide". Set the value to 1.
  2. Create a modified version of startClient.bat with the following contents (for example, at "C:\temp\xmage\xmage\mage-client"):
@ECHO OFF
set JAVA_HOME=C:\temp\xmage\java\jre1.8.0_131\bin
set CLASSPATH=%JAVA_HOME%/bin;%CLASSPATH%
set PATH=%JAVA_HOME%/bin;%PATH%
start %JAVA_HOME%\javaw.exe -Xms256m -Xmx512m -XX:MaxPermSize=384m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -jar .\lib\mage-client-1.4.26.jar
  1. Run this version of startClient.bat to launch the client.

(These instructions are based on https://github.com/magarena/magarena/issues/795)

All 13 comments

+1, this problem occurs on my Yoga 2 Pro running Windows 8 as well. It'd be awesome to be able to play on that thing instead of just my Windows desktop (since it's currently unplayable on my Linux desktop as well).

AFAIK XMage's client is made with the Swing framework, which does not support Hi-DPI (see here, here for examples).
The whole client would have to be remade in JavaFX to allow this.

That blows. Can't find anything about upcoming support for swing and scaling either. For those who are in my particular situation, setting the resolution to half the maximum and the scaling to 100% makes Xmage usable.

Looks like Linux behaviour with Swing is just really awful. I'm on ElementaryOS and the client window originally opens cut off on the right side. I have to scoot it up and over to the left, then resize to achieve the desired size.

This is supposed to be supported in JDK9 according to JEP-263.

I tested switching out the Nimbus look-and-feel for the GTK+ one and can confirm that the scaling looks semi-reasonable but there were a bunch of bugs (the game panel wouldn't work for example).

Display scaling can be enabled for Windows 10 as follows:

  1. Install xmage in the usual way. I'm using a "C:\temp\xmage" directory in this example.

  2. Create a "javaw.exe.manifest" file and place it next to javaw.exe in the bundled JRE install (for example, at "C:\temp\xmage\java\jre1.8.0_131\bin") with the following contents:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<description>javaw</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
  <security>
    <requestedPrivileges>
      <requestedExecutionLevel xmlns:ms_asmv3="urn:schemas-microsoft-com:asm.v3"
        level="asInvoker"
        ms_asmv3:uiAccess="false">
      </requestedExecutionLevel>
    </requestedPrivileges>
  </security>
</trustInfo>
<asmv3:application>
  <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
    <ms_windowsSettings:dpiAware xmlns:ms_windowsSettings="http://schemas.microsoft.com/SMI/2005/WindowsSettings">false</ms_windowsSettings:dpiAware>
  </asmv3:windowsSettings>
</asmv3:application>
</assembly>
  1. Run regedit.exe and create a DWORD Value named "PreferExternalManifest" under "Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide". Set the value to 1.
  2. Create a modified version of startClient.bat with the following contents (for example, at "C:\temp\xmage\xmage\mage-client"):
@ECHO OFF
set JAVA_HOME=C:\temp\xmage\java\jre1.8.0_131\bin
set CLASSPATH=%JAVA_HOME%/bin;%CLASSPATH%
set PATH=%JAVA_HOME%/bin;%PATH%
start %JAVA_HOME%\javaw.exe -Xms256m -Xmx512m -XX:MaxPermSize=384m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -jar .\lib\mage-client-1.4.26.jar
  1. Run this version of startClient.bat to launch the client.

(These instructions are based on https://github.com/magarena/magarena/issues/795)

I've been searching for a solution for a while now and can only add to the above that no combination of the following options works on linux:

GDK_SCALE=2
GDK_DPI_SCALE=2
-Dsun.java2d.uiScale=2
-Dsun.java2d.dpiaware=false

Apparently the only real solution in this case is to switch to jdk9 or use run_scaled, albeit it looks a bit pixelated.

Apparently the only real solution in this case is to switch to jdk9 or use run_scaled, albeit it looks a bit pixelated.

Is this a future fix or is there a functional solution here? If it's the latter, could you provide some additional details?

@fearphage
Instead of running xmage with a version 8 jdk, use version 9 or newer.
I just tried with jdk 11, works fine.
To enable scaling, add this parameter to the command line: -Dsun.java2d.uiScale=2

@sweber83 can you give some details how you did that? What is your start command? Does everything just work?

@derlhurgoyf
Here is the command I use to start xmage:

java -Xms1G -Xmx2G -Dsun.java2d.xrender=true -Dsun.java2d.uiScale=2 -jar mage-client/lib/mage-client-1.4.44.jar

I left out the exact paths to java & the .jar file, because those will probably differ on your system.
The exact version of the jdk I use is openjdk version "11.0.7"
So far I did not experience any problems.

@sweber83 can you make example screenshots with and without that command? If it's really good then it must be added to launcher/client settings.

@JayDi85
I made two screenshots, which show the difference.
xmage_lodpi
xmage_hidpi

I see an issues with changing the launcher settings.
As far as I know, the launcher installs its own jdk, which is a version 8 jdk, iirc.
So that would first have to be changed to use a version 9 or newer jdk, otherwise the -Dsun.java2d.uiScale=2 command line switch does nothing.
I don't use the launcher myself, because I prefer to use the package manager of my OS, which is NixOS.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

drmDev picture drmDev  路  13Comments

spjspj picture spjspj  路  11Comments

acabaca24 picture acabaca24  路  5Comments

copperfield42 picture copperfield42  路  6Comments

use picture use  路  3Comments