Bug 428138 - Strange values ​​of units.iconSizes.smallMedium with different DPI scaling
Summary: Strange values ​​of units.iconSizes.smallMedium with different DPI scaling
Status: RESOLVED DUPLICATE of bug 390147
Alias: None
Product: libplasma
Classification: Frameworks and Libraries
Component: libplasma (show other bugs)
Version: 5.75.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Marco Martin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-23 13:18 UTC by popov895
Modified: 2021-07-26 18:35 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Toolbutton scaling (101.67 KB, image/png)
2020-10-24 08:14 UTC, popov895
Details

Note You need to log in before you can comment on or make changes to this bug.
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 ***