summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2017-01-14 19:00:31 +0800
committerKhaled Hosny <khaledhosny@eglug.org>2017-02-07 12:40:05 +0000
commitaa9251103a131880afa621501936603d8c75af9d (patch)
tree7a0f37365ce38687fcea0dc82bea97f59efa8350
parentd18089ec0a2a8758eda889a7b9b23b66128484d5 (diff)
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 <ci@libreoffice.org> Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
-rw-r--r--vcl/win/gdi/winlayout.cxx28
1 files changed, 26 insertions, 2 deletions
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<HFONT>(GetCurrentObject( hDC, OBJ_FONT ));
+ HFONT hAltFont = nullptr;
+ bool bUseAltFont = false;
+ const CommonSalLayout* pCSL = dynamic_cast<const CommonSalLayout*>(&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);
}