vcl/win/gdi/salfont.cxx | 3 +++ vcl/win/gdi/winlayout.cxx | 15 +++++++++++++++ 2 files changed, 18 insertions(+)
New commits: commit 2392238e480ecc1d1a5e2e69789e79c10f142d6c Author: Mark Hung <[email protected]> Date: Thu Nov 30 19:42:08 2017 +0800 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 <[email protected]> Reviewed-by: Mark Hung <[email protected]> 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) { _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
