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

--- Comment #33 from RJVB <rjvber...@gmail.com> ---
(In reply to Christoph Feck from comment #32)
> A good fix would be in KFontRequester.

Indeed, that's one central place where a workaround/fix can be implement.
However,

> There is no need to workaround it in widget styles or even applications.

I don't think that can be guaranteed. Applications can use Qt's native font
dialog for instance (that might even be the default behaviour when not running
under a Plasma setting). And widget styles can be used in "pure Qt"
applications.

> Unfortunately I have no development environment right now, but I can review
> any patches made to KFontRequester::nearestExistingFont().

Would the function I added to QtCurve be appropriate?

QFont Style::FontHelper::fontStripStyleName(const QFont &f) const
{
    const QString &styleName = f.styleName();
    if (styleName.isEmpty()) {
        // we can simply return the input font
        return f;
    } else {
        // Check for a mismatch between styleString and styleName; when
        // found the font probably had a style name set directly instead of
        // receiving it e.g. via the FontDialog. This means its attributes
        // may still correspond to the original font, not to the current style.
        // Do a database lookup to get a consistent QFont instance to work
with,
        // so that methods like setWeight(), setStyle() will work as expected.
        QFont g = (m_fntDB->styleString(f) != styleName) ?
            m_fntDB->font(f.family(), styleName, f.pointSize())
            : QFont(f.family(), f.pointSize(), f.weight());
        if (auto s = f.pixelSize() > 0) {
            g.setPixelSize(s);
        }
        g.setStyleHint(f.styleHint(), f.styleStrategy());
        g.setStyle(f.style());
        if (f.underline()) {
            g.setUnderline(true);
        }
        if (f.strikeOut()) {
            g.setStrikeOut(true);
        }
        if (f.fixedPitch()) {
            g.setFixedPitch(true);
        }
        return g;
    }
}

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

Reply via email to