Bug 441852

Summary: Unread notification badge looks misaligned for numbers > 10 when using 10pt Noto Sans or other small-ish fonts
Product: [Plasma] plasmashell Reporter: ratijas <me>
Component: Task Manager and Icons-Only Task Manager widgetsAssignee: Eike Hein <hein>
Status: CONFIRMED ---    
Severity: minor CC: nate, plasma-bugs-null
Priority: NOR    
Version First Reported In: 5.22.5   
Target Milestone: 1.0   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: badge with 12 unread messages
Badge with 9,999 unread messages

Description ratijas 2021-09-01 09:23:30 UTC
Created attachment 141210 [details]
badge with 12 unread messages

SUMMARY
There are at least three components where this badge can be displayed: icon itself on a panel, popup on top of it WITH the window when on the same virtual desktop, and popup WITHOUT a window but with an application name when on any other virtual desktop.

All three badges are round circles. But numbers such as "12" do not fit well, causing text to overflow.

Interestingly, really huge numbers like "9,999" do cause a badge to stretch horizontally, and with "rounded" number such as "9" it really looks alright.

STEPS TO REPRODUCE
1. Ask your friend to send you 9,999 messages on Telegram.
2. Or just include muted chats in unread count.
3. Anyhow, get yourself a big number on a badge.
4. Hover over the app's icon on a Plasma panel/task manager.

OBSERVED RESULT
See the screenshot.

EXPECTED RESULT
Badge text should have some padding.


SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.22.5
KDE Frameworks Version: 5.85.0
Qt Version: 5.15.2
Kernel Version: 5.13.13-arch1-1 (64-bit)
Graphics Platform: X11
Processors: 8 × Intel® Core™ i7-6700HQ CPU @ 2.60GHz
Memory: 15.6 GiB of RAM
Graphics Processor: NVIDIA GeForce GTX 970M/PCIe/SSE2

ADDITIONAL INFORMATION
Comment 1 ratijas 2021-09-01 09:24:48 UTC
Created attachment 141211 [details]
Badge with 9,999 unread messages
Comment 2 Nate Graham 2021-09-02 17:29:21 UTC
Ooh, looks like the code in the Task Manager tooltip to do this got unsynced with the code to draw it on the icon.
Comment 3 Nate Graham 2021-09-02 17:31:22 UTC
So both of them use the shared Badge component (good) but each one sizes it in a different way (bad). Something about the sizing code in the tooltip is wrong, compared to the sizing code in the task itself.
Comment 4 Nate Graham 2021-09-02 17:38:28 UTC
The issue seems to be that in the tooltip, we're forcing the badge to be displayed at the same height as the close button. This height depends on the metrics of the default font. The default font is 10pt Noto Sans, which is rather small and result sin the button being rather small, and the badge getting squeezed.

It looks fine for me with 11pt Noto Sans, but this is because due to a quick or Noto Sans, 11pt is 22% bigger than 10pt which causes various buttons to be tall enough that the badge gets enough height.

Not sure what the best way to fix this would be. Feel free to play with the code in https://invent.kde.org/plasma/plasma-desktop/-/blob/master/applets/taskmanager/package/contents/ui/ToolTipInstance.qml#L115 and see if you can come up with a sane solution.
Comment 5 ratijas 2021-09-02 18:29:08 UTC
> this is because due to a quick or Noto Sans, 11pt is 22% bigger than 10pt

So, effectively this is a bug in a font? 😱

> Not sure what the best way to fix this would be. Feel free to play with the code in https://invent.kde.org/plasma/plasma-desktop/-/blob/master/applets/taskmanager/package/contents/ui/ToolTipInstance.qml#L115 and see if you can come up with a sane solution.

Hmm… The container Item's preferred size is that of closeButton's size. But the badge itself is merely centered in it. Height is bound to standard icon size, but width is not. Why wouldn't it resize at will?
Comment 6 Nate Graham 2021-09-02 18:34:14 UTC
Because nothing tells it to. :) PlasmaCore.Units.iconSizes.smallMedium is fixed to 22px.