Coder Social home page Coder Social logo

Comments (12)

kirill-grouchnikov avatar kirill-grouchnikov commented on May 25, 2024

I'll need much more information than this.

What is the version of Substance?
What is the OS and the version of the OS?
What is the version of Java?

Also, please attach screenshots of the same UI under Java 8 and Java 9 on that machine.

from substance.

utybo avatar utybo commented on May 25, 2024

image

Here is an image of the issue. On the left, with Java 8 (latest version), on the right, Java 9 (9.0.1). You can clearly see the edges of the components are not scaled properly in Java 9.

As for the OS, I'm using Windows 10, with a 125% scaling factor. Test done with Substance 7.1

Here is the code :

        SwingUtilities.invokeLater(() ->
        {
            try
            {
                UIManager.setLookAndFeel(new SubstanceBusinessLookAndFeel());
            }
            catch(UnsupportedLookAndFeelException e)
            {
                e.printStackTrace();
            }
            
            JFrame frame = new JFrame();
            JTabbedPane jtp = new JTabbedPane();
            JPanel pan = new JPanel();
            pan.add(new JButton("Hello!"));
            jtp.addTab("Testing", pan);
            frame.add(jtp);
            frame.setSize(300, 200);
            frame.setVisible(true);
            
        });

from substance.

utybo avatar utybo commented on May 25, 2024

As a side note, this issue also occurs when choosing the 150% scaling factor in Windows 10

from substance.

kirill-grouchnikov avatar kirill-grouchnikov commented on May 25, 2024

For now, use –Dsun.java2d.uiScale=1.0 on Java 9 to disable the built-in HiDPI emulation on Java 9 when the desktop is using a custom scaling factor.

I will look into whether it is feasible to provide support for HiDPI on both Java 8 and Java 9.

from substance.

utybo avatar utybo commented on May 25, 2024

Alright, thanks for the workaround. Keep up the great work! :)

from substance.

utybo avatar utybo commented on May 25, 2024

After testing the workaround you provided, it looks like fonts are not scaled with said workaround. Everything else works, but icons seem to not be scaled at all and, because of this, appear tiny.

from substance.

utybo avatar utybo commented on May 25, 2024

This fixes the text scaling issues when using the workaround. Use this after applying the LaF :

SubstanceLookAndFeel.setFontPolicy(SubstanceFontUtilities.getScaledFontPolicy(
                    (float)(SubstanceSizeUtils.getPointsToPixelsRatio()) / 1.33F));

Just to recap for anyone who encounters the same bug : the current way to get Substance to work nicely with HiDPI on Java 9 is to use -Dsun.java2d.uiScale=1.0 to disable the Java 9 HiDPI system, and the code snippet above to fix font scaling.

from substance.

kirill-grouchnikov avatar kirill-grouchnikov commented on May 25, 2024

Thank you. I've added that snippet at the end of https://github.com/kirill-grouchnikov/substance/blob/master/www/docs/faq.md

from substance.

utybo avatar utybo commented on May 25, 2024

The snippet has a problem though, in that now all the fonts are way bigger when using Java 8.

Edit : If compatibility with both Java 8 and Java 9 is required, one can simply run the snippet under the following if :

if(new JLabel("a").getFont().getSize() <= 12)

Kind of a hack, but it works. If the font is small, it is considered to not be scaled, then the scaling mechanism is applied. In this way, if the font was already scaled, the snippet isn't run, and if it wasn't scaled, the snippet is ran. In case of normal HiDPI, then it doesn't really matter, as it will just get a scaled policy that is scaled by 100% (i.e. actually not scaled).

from substance.

kirill-grouchnikov avatar kirill-grouchnikov commented on May 25, 2024

That can be "guarded" by checking the Java runtime version.

System.getProperty("java.specification.version").startsWith("9")

Of course, you wouldn't know the custom scaling factor set on the particular machine without yet more code.

from substance.

utybo avatar utybo commented on May 25, 2024

The problem is that i am also encountering issues with fonts not being scaled under other very specific circumstances I won't investigate further. (e.g using packr to create a .exe with an embedded JRE under Java 8. Substance doesn't scale fonts for an obscure unknown reason.)

So this is kind of a universal fix for any "font not being scaled" problem. I will open other issues if I manage to find the specific causes for this kind of problem.

EDIT : After doing some tests the scaling issues are not caused by Substance but by a weird bug in packr. So your guard is much better in most cases.

from substance.

kirill-grouchnikov avatar kirill-grouchnikov commented on May 25, 2024

This is ready for testing. There are a few "corners" where the visuals under fractional scaling factors are not quite perfect. Some of those will be addressed in time for the final 8.0.0 release, and those that slip will be handled a bit later.

from substance.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.