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>
This commit is contained in:
Mark Hung
2021-05-08 06:37:05 +02:00
parent b35b8079b3
commit f0653d01e1
+19 -3
View File
@@ -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;