summaryrefslogtreecommitdiff
path: root/vcl/win/gdi/DWriteTextRenderer.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-04-30 17:38:14 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-04-30 21:56:11 +0200
commitf7453b956bcf83ec13c805d243f20cb209289179 (patch)
tree2a57dc59cc90c3e995d5a68447dd46d85e0c4aea /vcl/win/gdi/DWriteTextRenderer.cxx
parent4aeb48d4691f8852b7afd908637d1a85ae434c84 (diff)
tdf#114209 vcl win DirectWrite: handle rotated text
Commit a51b7a1c3a7e7cf7b0c733e1dec40288278c1884 (tdf#103831, tdf#100986: Force using GDI when needed, 2017-03-03) noted that the DirectWrite text renderer doesn't support vertical text, add initial support for this now by extending the DirectWrite transform matrix to do rotation as well. This is initial support, as it can be improved in two ways: - vertical text is not cached - only vertical Latin text is handled, which wants rotated glyphs (vs e.g. Japanese text that would not rotate the glyphs) With this, the "unreadable" text in the bugdoc's chart is on par with the the GDI rendering. Change-Id: I07af4de6cb437f83cc40546396ec8c8aac456bb3 Reviewed-on: https://gerrit.libreoffice.org/71592 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'vcl/win/gdi/DWriteTextRenderer.cxx')
-rw-r--r--vcl/win/gdi/DWriteTextRenderer.cxx25
1 files changed, 18 insertions, 7 deletions
diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx b/vcl/win/gdi/DWriteTextRenderer.cxx
index dac6452a41a5..98daff12c4a4 100644
--- a/vcl/win/gdi/DWriteTextRenderer.cxx
+++ b/vcl/win/gdi/DWriteTextRenderer.cxx
@@ -234,7 +234,6 @@ bool D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa
const WinFontInstance& rWinFont = static_cast<const WinFontInstance&>(rLayout.GetFont());
float fHScale = rWinFont.getHScale();
- WinFontStretchGuard aStretchGuard(mpRT, fHScale);
tools::Rectangle bounds;
bool succeeded = rLayout.GetBoundRect(bounds);
@@ -266,6 +265,7 @@ bool D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa
DWRITE_GLYPH_OFFSET glyphOffsets[] = { { 0.0f, 0.0f }, };
D2D1_POINT_2F baseline = { static_cast<FLOAT>(aPos.X() - bounds.Left()) / fHScale,
static_cast<FLOAT>(aPos.Y() - bounds.Top()) };
+ WinFontTransformGuard aTransformGuard(mpRT, fHScale, rLayout, baseline);
DWRITE_GLYPH_RUN glyphs = {
mpFontFace,
mlfEmHeight,
@@ -384,18 +384,29 @@ bool D2DWriteTextOutRenderer::GetDWriteFaceFromHDC(HDC hDC, IDWriteFontFace ** p
return succeeded;
}
-WinFontStretchGuard::WinFontStretchGuard(ID2D1RenderTarget* pRenderTarget, float fHScale)
+WinFontTransformGuard::WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, float fHScale,
+ const GenericSalLayout& rLayout,
+ const D2D1_POINT_2F& rBaseline)
: mpRenderTarget(pRenderTarget)
{
pRenderTarget->GetTransform(&maTransform);
- if (fHScale == 1.0f)
- return;
+ D2D1::Matrix3x2F aTransform = maTransform;
+ if (fHScale != 1.0f)
+ {
+ aTransform
+ = aTransform * D2D1::Matrix3x2F::Scale(D2D1::Size(fHScale, 1.0f), D2D1::Point2F(0, 0));
+ }
- D2D1::Matrix3x2F aTransform
- = maTransform * D2D1::Matrix3x2F::Scale(D2D1::Size(fHScale, 1.0f), D2D1::Point2F(0, 0));
+ if (rLayout.GetOrientation() != 0)
+ {
+ // DWrite angle is in clockwise degrees, our orientation is in counter-clockwise 10th
+ // degrees.
+ aTransform
+ = aTransform * D2D1::Matrix3x2F::Rotation(-rLayout.GetOrientation() / 10, rBaseline);
+ }
mpRenderTarget->SetTransform(aTransform);
}
-WinFontStretchGuard::~WinFontStretchGuard() { mpRenderTarget->SetTransform(maTransform); }
+WinFontTransformGuard::~WinFontTransformGuard() { mpRenderTarget->SetTransform(maTransform); }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */