summaryrefslogtreecommitdiff
path: root/vcl/qt5
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-12-22 15:49:52 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-01-13 18:32:05 +0100
commit99c51ce0e44bf03ddea0efd7612389faa636b658 (patch)
tree094021e7da7961886b6757bffe0413db1a9857b8 /vcl/qt5
parent5e218b5c51f7d9cd10bd9db832879efca41b9c75 (diff)
allow selecting text rendering mode suitable for natural glyph positions
Change-Id: I6b8c815fda3a48917467719432071c0716e3e9ab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127338 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/qt5')
-rw-r--r--vcl/qt5/QtGraphics_Text.cxx17
1 files changed, 16 insertions, 1 deletions
diff --git a/vcl/qt5/QtGraphics_Text.cxx b/vcl/qt5/QtGraphics_Text.cxx
index 37825c970327..02158fca29db 100644
--- a/vcl/qt5/QtGraphics_Text.cxx
+++ b/vcl/qt5/QtGraphics_Text.cxx
@@ -294,11 +294,26 @@ std::unique_ptr<GenericSalLayout> QtGraphics::GetTextLayout(int nFallbackLevel)
return std::make_unique<QtCommonSalLayout>(*m_pTextStyle[nFallbackLevel]);
}
+static QRawFont GetRawFont(const QFont& rFont, bool bWithoutHintingInTextDirection)
+{
+ QFont::HintingPreference eHinting = rFont.hintingPreference();
+ bool bAllowedHintStyle
+ = !bWithoutHintingInTextDirection
+ || (eHinting == QFont::PreferNoHinting || eHinting == QFont::PreferVerticalHinting);
+ if (bWithoutHintingInTextDirection && !bAllowedHintStyle)
+ {
+ QFont aFont(rFont);
+ aFont.setHintingPreference(QFont::PreferVerticalHinting);
+ return QRawFont::fromFont(aFont);
+ }
+ return QRawFont::fromFont(rFont);
+}
+
void QtGraphics::DrawTextLayout(const GenericSalLayout& rLayout)
{
const QtFont* pFont = static_cast<const QtFont*>(&rLayout.GetFont());
assert(pFont);
- QRawFont aRawFont(QRawFont::fromFont(*pFont));
+ QRawFont aRawFont(GetRawFont(*pFont, getTextRenderModeForResolutionIndependentLayoutEnabled()));
QVector<quint32> glyphIndexes;
QVector<QPointF> positions;