Bug 474881 - Page headings elide inappropriately with 8pt fonts
Summary: Page headings elide inappropriately with 8pt fonts
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kirigami
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.110.0
Platform: Other Linux
: NOR normal
Target Milestone: Not decided
Assignee: kdelibs bugs
URL:
Keywords: qt6
: 473334 485518 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-09-26 01:23 UTC by Oliver Beard
Modified: 2024-04-26 15:34 UTC (History)
5 users (show)

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


Attachments
Demonstration of issue (12.71 KB, image/png)
2023-09-26 01:23 UTC, Oliver Beard
Details
System Settings — white gap (84.35 KB, image/png)
2023-09-26 12:03 UTC, ratijas
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Beard 2023-09-26 01:23:20 UTC
Created attachment 161873 [details]
Demonstration of issue

SUMMARY
Standard page headings elide inappropriately with 8pt fonts.

STEPS TO REPRODUCE
1. Set General font size in Fonts to 8pt.
2. Observe any Kirigami page heading

OBSERVED RESULT
Heading elides inappropriately in the middle, with clearly sufficient space not to.

EXPECTED RESULT
Heading wouldn't elide it runs out of space.

SOFTWARE/OS VERSIONS
KDE Plasma Version: 5.27.80
KDE Frameworks Version: 5.240.0
Qt Version: 6.5.2

Reproduced on Plasma 5 (plasma 5.27.8, kf 5.110.0, qt 5.15.10).
Comment 1 ratijas 2023-09-26 12:03:07 UTC
Created attachment 161887 [details]
System Settings — white gap

Not only that. It also resulted in amazing white stripe gap in System Settings sidebar. What an interesting font size it is.
Comment 2 ratijas 2023-09-26 12:10:37 UTC
Well, it's not a simple rounding error this time, it seems. I inspected one such title in GammaRay, and here are all its *width properties:

globalToolBar -> ToolBarPageHeader -> … -> titleLoader -> DefaultPageTitleDelegate -> Heading

- contentWidth: 34.453125
- implicitBackgroundWidth: 0
- implicitWidth: 38.984375
- paintedWidth: 34.453125
- width: 37

so for a string "Chips" which would normally take up 38.984375 px it displays "Chi…" that takes up 34.453125 px, and the whole thing is set to 37 px for whatever reason that doesn't match any of those previous values.
Comment 3 ratijas 2023-09-26 12:56:17 UTC
Apparently, TextMetrics is lying. It is inconsistent with implicit width reported by Text label, given the same font and the same string.

It is a known bug, it seems: https://bugreports.qt.io/browse/QTBUG-85936
And they introduced FontMetrics::renderType property to fix it: https://codereview.qt-project.org/c/qt/qtdeclarative/+/376617

However, even when binding renderType, I don't get consistent results across FontMetrics and Heading label.
Comment 4 Bug Janitor Service 2023-09-26 13:03:59 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kirigami/-/merge_requests/1280
Comment 5 Bug Janitor Service 2023-09-26 13:19:36 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kirigami/-/merge_requests/1281
Comment 6 ratijas 2023-09-26 15:11:14 UTC
Git commit effe300e70252bbe8baf941ee113ac70aa34f5dc by ivan tkachenko.
Committed on 26/09/2023 at 15:03.
Pushed by ratijas into branch 'master'.

ToolBar: Attempts at fixing heading size for specific fonts

Qt 6.3 introduced new property to fill the gap between Text/Label
implicitWidth and TextMetrics width/advanceWidth: renderType. It was
supposed to fix all the inconsistency issues with fonts like Noto Sans
8pt that causes our Kirigami headers to elide into oblivion.

Unfortunately though, it does not seem to be enough, as TextMetrics
still reports e.g. 36.40625 px for a "Chips" string for which a Heading
would require 38.984375 px of space. But at least now we can say we've
done everything we could on our side.

See also:
- https://bugreports.qt.io/browse/QTBUG-85936
- https://bugreports.qt.io/browse/QTBUG-83936
- https://bugreports.qt.io/browse/QTBUG-94023

M  +2    -1    src/controls/private/DefaultPageTitleDelegate.qml

https://invent.kde.org/frameworks/kirigami/-/commit/effe300e70252bbe8baf941ee113ac70aa34f5dc
Comment 7 ratijas 2023-09-26 15:11:22 UTC
Git commit 8c304c74159f3ed8b6bd93a8fdf59ab0d5033a08 by ivan tkachenko.
Committed on 26/09/2023 at 17:00.
Pushed by ratijas into branch 'master'.

ToolBar: Fix eliding titles for specific fonts

QtQuick/TextMetrics can not be trusted. Meanwhile, QtQuick.Text provides
sane implicitWidth regardless of elided string (which in turn only
affects paintedWidth & contentWidth).

See also:
- https://bugreports.qt.io/browse/QTBUG-85936
- https://bugreports.qt.io/browse/QTBUG-83936
- https://bugreports.qt.io/browse/QTBUG-94023

M  +2    -10   src/controls/private/DefaultPageTitleDelegate.qml

https://invent.kde.org/frameworks/kirigami/-/commit/8c304c74159f3ed8b6bd93a8fdf59ab0d5033a08
Comment 8 Patrick Silva 2023-09-30 12:05:44 UTC
*** Bug 473334 has been marked as a duplicate of this bug. ***
Comment 9 ratijas 2024-04-26 15:34:13 UTC
*** Bug 485518 has been marked as a duplicate of this bug. ***