summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2021-05-05 21:53:41 +0800
committerMark Hung <marklh9@gmail.com>2021-05-08 06:37:05 +0200
commitf0653d01e15ed9f0e0e862a0679ae6ac88a2cb07 (patch)
tree66a5bce719ea9cd15347d291d834af58001008f8 /vcl/win
parentb35b8079b3f03b93efdaf2d54b4a515df296e71d (diff)
vcl: vertical writing in WinFontInstance::ImplGetGlyphBoundRect.
Identity matrix isn't enough for vertical writing. For those glyphs that is vertical, they have to be rotated 90 degrees. Change-Id: Ia5f1f8ac9cea89aec2c98b88058ec79f733fc238 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115148 Tested-by: Jenkins Reviewed-by: Mark Hung <marklh9@gmail.com>
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/gdi/salfont.cxx22
1 files changed, 19 insertions, 3 deletions
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 6fd4836e3040..39f67e26a057 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -1254,7 +1254,7 @@ void WinSalGraphics::ClearDevFontCache()
ImplReleaseTempFonts(*GetSalData(), false);
}
-bool WinFontInstance::ImplGetGlyphBoundRect(sal_GlyphId nId, tools::Rectangle& rRect, bool) const
+bool WinFontInstance::ImplGetGlyphBoundRect(sal_GlyphId nId, tools::Rectangle& rRect, bool bIsVertical) const
{
assert(m_pGraphics);
HDC hDC = m_pGraphics->getHDC();
@@ -1269,8 +1269,24 @@ bool WinFontInstance::ImplGetGlyphBoundRect(sal_GlyphId nId, tools::Rectangle& r
// use unity matrix
MAT2 aMat;
- aMat.eM11 = aMat.eM22 = FixedFromDouble( 1.0 );
- aMat.eM12 = aMat.eM21 = FixedFromDouble( 0.0 );
+ const FontSelectPattern& rFSD = GetFontSelectPattern();
+
+ // Use identity matrix for fonts requested in horizontal
+ // writing (LTR or RTL), or rotated glyphs in vertical writing.
+ if (!rFSD.mbVertical || !bIsVertical)
+ {
+ aMat.eM11 = aMat.eM22 = FixedFromDouble(1.0);
+ aMat.eM12 = aMat.eM21 = FixedFromDouble(0.0);
+ }
+ else
+ {
+ constexpr double nCos = 0.0;
+ constexpr double nSin = 1.0;
+ aMat.eM11 = FixedFromDouble(nCos);
+ aMat.eM12 = FixedFromDouble(nSin);
+ aMat.eM21 = FixedFromDouble(-nSin);
+ aMat.eM22 = FixedFromDouble(nCos);
+ }
UINT nGGOFlags = GGO_METRICS;
nGGOFlags |= GGO_GLYPH_INDEX;