From aa9251103a131880afa621501936603d8c75af9d 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. Change-Id: I4e0361929f898eddc671b739b36a12dd26d68018 Reviewed-on: https://gerrit.libreoffice.org/33064 Tested-by: Jenkins Reviewed-by: Khaled Hosny --- vcl/win/gdi/winlayout.cxx | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'vcl/win/gdi') diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx index 6436c618cda9..54c00afe3af6 100644 --- a/vcl/win/gdi/winlayout.cxx +++ b/vcl/win/gdi/winlayout.cxx @@ -291,14 +291,38 @@ bool ExTextOutRenderer::operator ()(SalLayout const &rLayout, HDC hDC, { bool bGlyphs = false; const GlyphItem* pGlyph; + 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); + } + } while (rLayout.GetNextGlyphs(1, &pGlyph, *pPos, *pGetNextGlypInfo)) { bGlyphs = true; WORD glyphWStr[] = { pGlyph->maGlyphId }; - if (pGlyph->IsVertical()) - glyphWStr[0] |= 0x02000000; // A (undocumented?) GDI flag for vertical glyphs + if (hAltFont && pGlyph->IsVertical() == bUseAltFont) + { + bUseAltFont = !bUseAltFont; + SelectFont(hDC, bUseAltFont ? hAltFont : hFont); + } ExtTextOutW(hDC, pPos->X(), pPos->Y(), ETO_GLYPH_INDEX, nullptr, LPCWSTR(&glyphWStr), 1, nullptr); } + if (hAltFont) + { + if (bUseAltFont) + SelectFont(hDC, hFont); + DeleteObject(hAltFont); + } return (pRectToErase && bGlyphs); } -- cgit