diff --git a/src/preferences/dialog/dlgpreflibrary.cpp b/src/preferences/dialog/dlgpreflibrary.cpp index c5151d87a785..efc730178bfe 100644 --- a/src/preferences/dialog/dlgpreflibrary.cpp +++ b/src/preferences/dialog/dlgpreflibrary.cpp @@ -595,11 +595,39 @@ void DlgPrefLibrary::slotRowHeightValueChanged(int height) { } void DlgPrefLibrary::setLibraryFont(const QFont& font) { - lineEdit_library_font->setText( - QString("%1 %2 %3pt") - .arg(font.family(), - font.styleName(), - QString::number(font.pointSizeF()))); + // Update the font name/style/size display + QString fontDescription = font.family(); + const QString style = font.styleName(); + if (!style.isEmpty()) { + // Use the style name if available, likely it's translated + fontDescription += ' ' + style; + } else { + // Else we compose the "style" string from weight and italic. + // It's not possible to access the translations used in QFontDialog, + // but let's can add them to the user translations + const auto weight = font.weight(); + if (weight >= QFont::Bold) { + if (weight >= QFont::Black) { + fontDescription += ' ' + tr("Black"); + } else if (weight >= QFont::ExtraBold) { + fontDescription += ' ' + tr("ExtraBold"); + } else if (weight >= QFont::Bold) { + fontDescription += ' ' + tr("Bold"); + } + } else if (weight >= QFont::DemiBold) { + fontDescription += ' ' + tr("SemiBold"); + } else if (weight >= QFont::Medium) { + fontDescription += ' ' + tr("Medium"); + } else if (weight >= QFont::Normal) { + // Skip "Normal" as it's implied + } else { + fontDescription += ' ' + tr("Light"); + } + } + fontDescription += ' ' + QString::number(font.pointSizeF()) + QStringLiteral("pt"); + lineEdit_library_font->setText(fontDescription); + + // Apply the font m_pLibrary->setFont(font); // Don't let the font height exceed the row height.