From 6ea0cb85173ce075a4bc7e2f7c6370628a8ba339 Mon Sep 17 00:00:00 2001 From: Mark Hung Date: Sat, 14 Jan 2017 19:00:31 +0800 Subject: tdf#105286 use alternative font when glyph is not vertical. In vertical layout, a vertical font is selected. For windows, that means prepending a '@' to the font name. Switch back to the one without '@' in order to display characters that needs to be rotated 90 degrees in vertical layout correctly. cherry-picked from aa9251103a131880afa621501936603d8c75af9d. Change-Id: I4e0361929f898eddc671b739b36a12dd26d68018 Reviewed-on: https://gerrit.libreoffice.org/33064 Tested-by: Jenkins Reviewed-by: Khaled Hosny Reviewed-on: https://gerrit.libreoffice.org/34093 --- vcl/win/gdi/winlayout.cxx | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'vcl') diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx index cefe4b1b9edc..5cfa9b71425f 100644 --- a/vcl/win/gdi/winlayout.cxx +++ b/vcl/win/gdi/winlayout.cxx @@ -3117,6 +3117,22 @@ bool ExTextOutRenderer::operator ()(SalLayout const &rLayout, HDC hDC, sal_GlyphId glyphIntStr[MAX_GLYPHS]; int nGlyphs = 0; WORD glyphWStr[MAX_GLYPHS]; + HFONT hFont = static_cast(GetCurrentObject( hDC, OBJ_FONT )); + HFONT hAltFont = nullptr; + bool bUseAltFont = false; + const CommonSalLayout* pCSL = dynamic_cast(&rLayout); + if (pCSL && pCSL->getFontSelData().mbVertical) + { + LOGFONTW aLogFont; + GetObjectW(hFont, sizeof(LOGFONTW), &aLogFont); + if (aLogFont.lfFaceName[0] == '@') + { + memmove(&aLogFont.lfFaceName[0], &aLogFont.lfFaceName[1], + sizeof(aLogFont.lfFaceName)-sizeof(aLogFont.lfFaceName[0])); + hAltFont = CreateFontIndirectW(&aLogFont); + } + } + do { nGlyphs = rLayout.GetNextGlyphs(1, glyphIntStr, *pPos, *pGetNextGlypInfo); @@ -3125,10 +3141,12 @@ bool ExTextOutRenderer::operator ()(SalLayout const &rLayout, HDC hDC, if (SalLayout::UseCommonLayout()) { - for (int i = 0; i < nGlyphs; i++) + bool bVertical = (glyphIntStr[0] & GF_ROTMASK) == GF_ROTL; + + if (hAltFont && bVertical == bUseAltFont) { - if ((glyphIntStr[i] & GF_ROTMASK) == GF_ROTL) - glyphIntStr[i] |= GF_VERT; + bUseAltFont = !bUseAltFont; + SelectFont(hDC, bUseAltFont ? hAltFont : hFont); } } @@ -3136,6 +3154,12 @@ bool ExTextOutRenderer::operator ()(SalLayout const &rLayout, HDC hDC, ExtTextOutW(hDC, pPos->X(), pPos->Y(), ETO_GLYPH_INDEX, nullptr, LPCWSTR(&glyphWStr), nGlyphs, nullptr); } while (!pRectToErase); + if (hAltFont) + { + if (bUseAltFont) + SelectFont(hDC, hFont); + DeleteObject(hAltFont); + } return (pRectToErase && nGlyphs >= 1); } -- cgit