summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2017-11-30 19:42:08 +0800
committerCaolán McNamara <caolanm@redhat.com>2017-12-08 20:49:28 +0100
commit84b4aae808d904325c841c3b3e778d8bc4769dab (patch)
tree3f6e74428bd0589a32385531435bbfd21333db9b
parentf987cc2910ae90229ae7f76ed1dc9325b57b5cb6 (diff)
tdf#108302: keep the font unrotated if @font isn't available.
We will create the font in ExTextOutRenderer for glyphs that are expected to be sideway in vertical writing, so we can reset the font escapement and orientation if @font ( windows notation of fonts for CJK vertical writing. ) isn't available. That will keep the font consistent with @fonts for those glyphs expected to be upright in vertical writing. Note that it is necessary to change text alignment of DC when such font is used. Change-Id: I1a4a6e8aa232119dd136beeb6c19505d7980a534 Reviewed-on: https://gerrit.libreoffice.org/45609 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mark Hung <marklh9@gmail.com> (cherry picked from commit 2392238e480ecc1d1a5e2e69789e79c10f142d6c) Reviewed-on: https://gerrit.libreoffice.org/45919 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/win/gdi/salfont.cxx3
-rw-r--r--vcl/win/gdi/winlayout.cxx15
2 files changed, 18 insertions, 0 deletions
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 20bcce07d47e..9796ab928f3b 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -826,6 +826,9 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
memcpy( &rLogFont.lfFaceName[0], aName.getStr(), nNameLen*sizeof(wchar_t) );
if( nNameLen < LF_FACESIZE )
rLogFont.lfFaceName[nNameLen] = '\0';
+ // keep it upright and create the font for sideway glyphs later.
+ rLogFont.lfEscapement = rLogFont.lfEscapement - 2700;
+ rLogFont.lfOrientation = rLogFont.lfEscapement;
}
}
}
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index d6b9cd4b57c4..409b0b447986 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -250,6 +250,7 @@ bool ExTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
HFONT hFont = static_cast<HFONT>(GetCurrentObject( hDC, OBJ_FONT ));
HFONT hAltFont = nullptr;
bool bUseAltFont = false;
+ bool bShift = false;
if (rLayout.getFontSelData().mbVertical)
{
LOGFONTW aLogFont;
@@ -260,8 +261,16 @@ bool ExTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
sizeof(aLogFont.lfFaceName)-sizeof(aLogFont.lfFaceName[0]));
hAltFont = CreateFontIndirectW(&aLogFont);
}
+ else
+ {
+ bShift = true;
+ aLogFont.lfEscapement += 2700;
+ aLogFont.lfOrientation = aLogFont.lfEscapement;
+ hAltFont = CreateFontIndirectW(&aLogFont);
+ }
}
+ UINT nTextAlign = GetTextAlign ( hDC );
int nStart = 0;
Point aPos(0, 0);
const GlyphItem* pGlyph;
@@ -273,7 +282,13 @@ bool ExTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
bUseAltFont = !bUseAltFont;
SelectFont(hDC, bUseAltFont ? hAltFont : hFont);
}
+ if (bShift && pGlyph->IsVertical())
+ SetTextAlign(hDC, TA_TOP|TA_LEFT);
+
ExtTextOutW(hDC, aPos.X(), aPos.Y(), ETO_GLYPH_INDEX, nullptr, LPCWSTR(&glyphWStr), 1, nullptr);
+
+ if (bShift && pGlyph->IsVertical())
+ SetTextAlign(hDC, nTextAlign);
}
if (hAltFont)
{