diff options
author | Mark Hung <marklh9@gmail.com> | 2017-11-30 19:42:08 +0800 |
---|---|---|
committer | Mark Hung <marklh9@gmail.com> | 2017-12-06 00:03:21 +0100 |
commit | 2392238e480ecc1d1a5e2e69789e79c10f142d6c (patch) | |
tree | 87cde655cf18817e98fe164d0e6e28829ced65f6 /vcl/win | |
parent | 962873c863ee8f5dcb80af05bd658266304bb5cb (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>
Diffstat (limited to 'vcl/win')
-rw-r--r-- | vcl/win/gdi/salfont.cxx | 3 | ||||
-rw-r--r-- | vcl/win/gdi/winlayout.cxx | 15 |
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) { |