https://bugs.kde.org/show_bug.cgi?id=431947

Noah Davis <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #6 from Noah Davis <[email protected]> ---
One potential workaround is to adjust the padding in places where gridUnit and
anything that shows text are used to compensate for the jump in size.

Here's an example of what I mean:

Units.qml:

    // The boundingRect height for Noto Sans 96 is 175 px and the pixelSize is
128.
    property var __boundingRectRatioFontMetrics: FontMetrics {
        font.pointSize: 96
    }

    // The value is exactly 1.3671875 with Noto Sans.
    property real __expectedPixelSizeBoundingRectRatio:
(__boundingRectRatioFontMetrics.height /
__boundingRectRatioFontMetrics.font.pixelSize)

    /* pixelSize is always pointSize / 0.75, pointSize is always pixelSize *
0.75.
     * Noto Sans 10 has a boundingRect height of 18.
     * Noto Sans 10.5 has a boundingRect height of 20.
     * Noto Sans 11 has a boundingRect height of 22.
     * Internally, QFontMetricsF rounds the font height (not floor, not ceil),
so we can't get the true height, but maybe it doesn't matter that much.
     *
     * With Noto Sans 10 (13.33... pixelSize), 13.33... * 1.3671875 is
18.229166...
     * 18 - 18.229166... is less than 0, so don't reduce padding.
     *
     * With Noto Sans 10.5 (14 pixelSize), 14 * 1.3671875 is 19.140625.
     * 20 - 19.140625 is 0.859375
     * Divide that by 2 since padding is applied for 2 sides on the same axis.
     * Round 0.4296875 to 0, so don't reduce padding.
     *
     * With Noto Sans 11, (14.66... pixelSize) 14.66... * 1.3671875 is
20.0520833...
     * 22 - 20.0520833... is 1.9479166...
     * Divide that by 2 since padding is applied for 2 sides on the same axis.
     * Round 0.97395833... to 1, so reduce padding by 1.
     */
    property int paddingOffset: Math.min(0, -Math.round(Math.max(0, gridUnit -
(fontMetrics.font.pixelSize * __expectedPixelSizeBoundingRectRatio))/2))

You could then use it like this:

    padding: someValue + paddingOffset

This isn't very elegant though. We could apply it directly to the spacings in
Kirigami.Units, but I'm not sure if we should.

I don't think we should reduce gridUnit because controls that show text will
still use the full font height as the content height. That could lead to
alignment issues.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to