diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2020-03-02 10:04:24 +0100 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2020-03-02 13:26:44 +0100 |
commit | 63ea1e811a3b3806b6b2408d759a449f4e086eb3 (patch) | |
tree | 0874dea911d3c10b8b781caaeaf9b3562c92cf89 /vcl/unx | |
parent | 1f84470abc6087fc6a3d01defae5043772bdd95e (diff) |
Qt5 unify font attribute conversions
Adds conversion functions for VCLs FontWeight, FontWidth and
FontItalic to Qt5FontFace and remove the partial "switch"
tables from KF5SalFrame.
And correctly handle the FontWidth in Qt5Font as the stretch
value, so the default font in qt5 gets the correct stretch and
doesn't look bold.
Change-Id: I698986416dff13e6dfaf9dfa7f95851b89e9137d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89813
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/unx')
-rw-r--r-- | vcl/unx/kf5/KF5SalFrame.cxx | 42 |
1 files changed, 4 insertions, 38 deletions
diff --git a/vcl/unx/kf5/KF5SalFrame.cxx b/vcl/unx/kf5/KF5SalFrame.cxx index 27503444a0a1..cc08b9c07748 100644 --- a/vcl/unx/kf5/KF5SalFrame.cxx +++ b/vcl/unx/kf5/KF5SalFrame.cxx @@ -28,6 +28,7 @@ #include <KConfigGroup> #include <KSharedConfig> +#include <Qt5FontFace.hxx> #include "KF5SalFrame.hxx" #include <tools/color.hxx> @@ -62,44 +63,9 @@ static vcl::Font toFont(const QFont& rQFont, const css::lang::Locale& rLocale) strlen(static_cast<const char*>(rQFont.family().toUtf8())), RTL_TEXTENCODING_UTF8); - // set italic - aInfo.m_eItalic = (qFontInfo.italic() ? ITALIC_NORMAL : ITALIC_NONE); - - // set weight - int nWeight = qFontInfo.weight(); - if (nWeight <= QFont::Light) - aInfo.m_eWeight = WEIGHT_LIGHT; - else if (nWeight <= QFont::Normal) - aInfo.m_eWeight = WEIGHT_NORMAL; - else if (nWeight <= QFont::DemiBold) - aInfo.m_eWeight = WEIGHT_SEMIBOLD; - else if (nWeight <= QFont::Bold) - aInfo.m_eWeight = WEIGHT_BOLD; - else - aInfo.m_eWeight = WEIGHT_ULTRABOLD; - - // set width - int nStretch = rQFont.stretch(); - if (nStretch == 0) // QFont::AnyStretch since Qt 5.8 - aInfo.m_eWidth = WIDTH_DONTKNOW; - else if (nStretch <= QFont::UltraCondensed) - aInfo.m_eWidth = WIDTH_ULTRA_CONDENSED; - else if (nStretch <= QFont::ExtraCondensed) - aInfo.m_eWidth = WIDTH_EXTRA_CONDENSED; - else if (nStretch <= QFont::Condensed) - aInfo.m_eWidth = WIDTH_CONDENSED; - else if (nStretch <= QFont::SemiCondensed) - aInfo.m_eWidth = WIDTH_SEMI_CONDENSED; - else if (nStretch <= QFont::Unstretched) - aInfo.m_eWidth = WIDTH_NORMAL; - else if (nStretch <= QFont::SemiExpanded) - aInfo.m_eWidth = WIDTH_SEMI_EXPANDED; - else if (nStretch <= QFont::Expanded) - aInfo.m_eWidth = WIDTH_EXPANDED; - else if (nStretch <= QFont::ExtraExpanded) - aInfo.m_eWidth = WIDTH_EXTRA_EXPANDED; - else - aInfo.m_eWidth = WIDTH_ULTRA_EXPANDED; + aInfo.m_eItalic = Qt5FontFace::toFontItalic(qFontInfo.style()); + aInfo.m_eWeight = Qt5FontFace::toFontWeight(qFontInfo.weight()); + aInfo.m_eWidth = Qt5FontFace::toFontWidth(rQFont.stretch()); SAL_INFO("vcl.kf5", "font name BEFORE system match: \"" << aInfo.m_aFamilyName << "\""); |