Bug 491867 - Language code's font size can be quite large with language codes that use narrow letters
Summary: Language code's font size can be quite large with language codes that use nar...
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Keyboard Layout (show other bugs)
Version: 6.1.4
Platform: Arch Linux Linux
: NOR minor
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords: junior-jobs
Depends on:
Blocks:
 
Reported: 2024-08-18 17:08 UTC by Sauf
Modified: 2024-08-23 16:37 UTC (History)
2 users (show)

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


Attachments
OBSERVED and EXPECTED RESULT (22.21 KB, image/png)
2024-08-18 17:08 UTC, Sauf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sauf 2024-08-18 17:08:55 UTC
Created attachment 172733 [details]
OBSERVED and EXPECTED RESULT

SUMMARY
The text size of keyboard layout plasmoid in some languages (e.g persian[ir]) is inconsistent. This bug is visible when panel height is high (e.g 52). refer to attachment.

STEPS TO REPRODUCE
1. Add persian keyboard layout
2. add system tray plasmoid to panel
3. resize panel to 52

OBSERVED RESULT
very big "ir" versus small other icons 

EXPECTED RESULT
same size as "us" or other system tray icons.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.1.4
KDE Frameworks Version: 6.5.0
Qt Version: 6.7.2
Graphics Platform: Wayland

ADDITIONAL INFORMATION
The problem arise from /usr/share/plasma/plasmoids/org.kde.plasma.keyboardlayout/contents/ui/main.qml. "font.pointSize" at line 89 is set to "height" which I think should change.
Comment 1 Nate Graham 2024-08-19 22:52:18 UTC
Can reproduce. I'm pretty sure of what's going on here: because the System Tray allocates the same square area for every applet, when the Latin letters for the current language are taller than they are wide, the text vertically fills the space rather than horizontally filling the space, and the the font size ends up larger than when the text is wider than it is long (e.g. with something like "us").

The effect is even more pronounced with Hebrew, which gets the Latin abbreviation "il". That's even narrower than "ir"! And if I add Latin American Spanish with the code "lat", then the text is small because it has to fit into the same box.

We could set a maximum text size so that it can't be quite so tall when the letters are narrow, but we can't make the size fixed or else longer codes would overflow.
Comment 2 Sauf 2024-08-20 11:57:09 UTC
(In reply to Nate Graham from comment #1)
> Can reproduce. I'm pretty sure of what's going on here: because the System
> Tray allocates the same square area for every applet, when the Latin letters
> for the current language are taller than they are wide, the text vertically
> fills the space rather than horizontally filling the space, and the the font
> size ends up larger than when the text is wider than it is long (e.g. with
> something like "us").
> 
> The effect is even more pronounced with Hebrew, which gets the Latin
> abbreviation "il". That's even narrower than "ir"! And if I add Latin
> American Spanish with the code "lat", then the text is small because it has
> to fit into the same box.
> 
> We could set a maximum text size so that it can't be quite so tall when the
> letters are narrow, but we can't make the size fixed or else longer codes
> would overflow.
Thanks for your reply.
I've set {font.pointSize} to {Math.max(root.height * 0.4)} and seems to be kina OK for "li",''fa" and they are same size "us", but layouts like "lat" or "apl" are smaller than normal. so it is not the best design.
The another solution is that user change font size like digital clock widget which I don't think it is that much "better".

Why don't we consider display text to be all two or three letters? for example to embrace ISO 639 language codes. In this case we have more control on font size. Also in keyboard layout context we're talking about languages than countries. For instance If I also install "Kurdish (Iran, Arabic-Latin)" and "Persian" for both of them the text display is "ir" and it is hard to distinguish them. and these are different languages.
Comment 3 Nate Graham 2024-08-20 22:10:12 UTC
The language code is actually user-configurable, or at least it will be in Plasma 6.2.

Anyway, it sounds like you've done some work on this; would you be interested in submitting a patch?
Comment 4 Bug Janitor Service 2024-08-21 10:34:31 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/2456
Comment 5 Nate Graham 2024-08-23 16:37:07 UTC
Git commit be73656d68bbc5c60de46cbf5be2af4a99f730c9 by Nate Graham, on behalf of Sauf Lvc.
Committed on 23/08/2024 at 16:36.
Pushed by ngraham into branch 'master'.

applets/keyboardlayout: Constrain text label to lower of width or height

This fixes the problem of the text changing size while switching due to
Latin letters having different heights and widths.
FIXED-IN: 6.2.0

M  +5    -1    applets/keyboardlayout/contents/ui/main.qml

https://invent.kde.org/plasma/plasma-desktop/-/commit/be73656d68bbc5c60de46cbf5be2af4a99f730c9