Bug 428138

Summary: Strange values ​​of units.iconSizes.smallMedium with different DPI scaling
Product: [Frameworks and Libraries] libplasma Reporter: popov895 <popov895>
Component: libplasmaAssignee: Marco Martin <notmart>
Status: RESOLVED DUPLICATE    
Severity: normal CC: nate, plasma-bugs, popov895
Priority: NOR    
Version: 5.75.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Toolbutton scaling

Description popov895 2020-10-23 13:18:25 UTC
SUMMARY

I'm not sure is it a bug or feature. I decided to check how the Plasma scales icon sizes with different DPI scaling. What I expected to get for units.iconSizes.smallMedium:

100% - 22
125% - 27 or 28
150% - 33
175% - 38 or 39
200% - 44

And here's what I got:

100% - 22
125% - 22
150% - 33
175% - 33
200% - 44

Why are the values ​​so strange? Then I found some function that adjusts the sizes of the icons (https://invent.kde.org/frameworks/plasma-framework/-/blob/master/src/declarativeimports/kirigamiplasmadesktopstyle/Units.qml#L119):

function roundedIconSize(size) {
    if (size < 16) {
        return size;
    } else if (size < 22) {
        return 16;
    } else if (size < 32) {
        return 22;
    } else if (size < 48) {
        return 32;
    } else if (size < 64) {
        return 48;
    } else {
        return size;
    }
}

Why are icon sizes adjusted? It seems like svg icons should render fine at any scaling. Or am I missing something?

SOFTWARE/OS VERSIONS

Linux/KDE Plasma: KDE neon 5.20 User Edition / X11
KDE Plasma Version: 5.20.1
KDE Frameworks Version: 5.75.0
Qt Version: 5.15.0
Comment 1 popov895 2020-10-24 08:14:55 UTC
Created attachment 132679 [details]
Toolbutton scaling

Here's an example of scaling a toolbutton. The area of the toolbutton is filled in blue and the area of the icon is filled in yellow. As you can see, the scaling looks pretty strange: padding inside a toolbutton isn't scaled at all and the content of the icon has different sizes for different scales (100% and 125% - 16px, 150% and 200% - 24px).
Comment 2 Nate Graham 2020-10-26 15:25:10 UTC
> It seems like svg icons should render fine at any scaling
If you had a screen with infinite resolution, they would. In reality, even SVGs get blurry when you take a small icon that is pixel-aligned and scale it up by 10 0r 25 or 50%. This is why Plasma's native scaling uses this complicated and sometimes unexpected behavior.

If you want icons to be unconditionally scaled, you have to use Qt scaling, which does that you seem to expect--at the cost of blurry icons when using fractional scaling with a low resolution screen. To use Qt scaling, use Wayland (where it is always used) or on X11 set the environment variable PLASMA_USE_QT_SCALING=1.

*** This bug has been marked as a duplicate of bug 356446 ***
Comment 3 Nate Graham 2021-07-26 18:35:03 UTC

*** This bug has been marked as a duplicate of bug 390147 ***