summaryrefslogtreecommitdiff
path: root/vcl/win/gdi/winlayout.cxx
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/win/gdi/winlayout.cxx
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/win/gdi/winlayout.cxx')
-rw-r--r--vcl/win/gdi/winlayout.cxx25
1 files changed, 17 insertions, 8 deletions
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index cb9bcc6a29da..673b223a263f 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -52,7 +52,7 @@
#include <shlwapi.h>
#include <winver.h>
-TextOutRenderer& TextOutRenderer::get(bool bUseDWrite)
+TextOutRenderer& TextOutRenderer::get(bool bUseDWrite, bool bRenderingModeNatural)
{
SalData* const pSalData = GetSalData();
@@ -64,9 +64,13 @@ TextOutRenderer& TextOutRenderer::get(bool bUseDWrite)
if (bUseDWrite)
{
- if (!pSalData->m_pD2DWriteTextOutRenderer)
+ if (!pSalData->m_pD2DWriteTextOutRenderer
+ || static_cast<D2DWriteTextOutRenderer*>(pSalData->m_pD2DWriteTextOutRenderer.get())
+ ->GetRenderingModeNatural()
+ != bRenderingModeNatural)
{
- pSalData->m_pD2DWriteTextOutRenderer.reset(new D2DWriteTextOutRenderer());
+ pSalData->m_pD2DWriteTextOutRenderer.reset(
+ new D2DWriteTextOutRenderer(bRenderingModeNatural));
}
return *pSalData->m_pD2DWriteTextOutRenderer;
}
@@ -78,7 +82,7 @@ TextOutRenderer& TextOutRenderer::get(bool bUseDWrite)
}
bool ExTextOutRenderer::operator()(GenericSalLayout const& rLayout, SalGraphics& /*rGraphics*/,
- HDC hDC)
+ HDC hDC, bool /*bRenderingModeNatural*/)
{
int nStart = 0;
DevicePoint aPos;
@@ -293,10 +297,11 @@ void WinFontInstance::SetGraphics(WinSalGraphics* pGraphics)
SelectObject(hDC, hOrigFont);
}
-void WinSalGraphics::DrawTextLayout(const GenericSalLayout& rLayout, HDC hDC, bool bUseDWrite)
+void WinSalGraphics::DrawTextLayout(const GenericSalLayout& rLayout, HDC hDC, bool bUseDWrite,
+ bool bRenderingModeNatural)
{
- TextOutRenderer& render = TextOutRenderer::get(bUseDWrite);
- render(rLayout, *this, hDC);
+ TextOutRenderer& render = TextOutRenderer::get(bUseDWrite, bRenderingModeNatural);
+ render(rLayout, *this, hDC, bRenderingModeNatural);
}
void WinSalGraphics::DrawTextLayout(const GenericSalLayout& rLayout)
@@ -312,7 +317,11 @@ void WinSalGraphics::DrawTextLayout(const GenericSalLayout& rLayout)
const HFONT hOrigFont = ::SelectFont(hDC, hLayoutFont);
// DWrite text renderer performs vertical writing better except printing.
- DrawTextLayout(rLayout, hDC, !mbPrinter && rLayout.GetFont().GetFontSelectPattern().mbVertical);
+ const bool bVerticalScreenText
+ = !mbPrinter && rLayout.GetFont().GetFontSelectPattern().mbVertical;
+ const bool bRenderingModeNatural = getTextRenderModeForResolutionIndependentLayoutEnabled();
+ const bool bUseDWrite = bVerticalScreenText || bRenderingModeNatural;
+ DrawTextLayout(rLayout, hDC, bUseDWrite, bRenderingModeNatural);
::SelectFont(hDC, hOrigFont);
}