summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2017-01-14 19:00:31 +0800
committerKhaled Hosny <khaledhosny@eglug.org>2017-02-09 23:38:55 +0000
commit6ea0cb85173ce075a4bc7e2f7c6370628a8ba339 (patch)
tree2d0aab44eac679e1bac92bfeaa4349502559d7a7 /vcl/win
parent2be5e763d2e03bffc692d40106212fe52a7b7304 (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. cherry-picked from aa9251103a131880afa621501936603d8c75af9d. Change-Id: I4e0361929f898eddc671b739b36a12dd26d68018 Reviewed-on: https://gerrit.libreoffice.org/33064 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Khaled Hosny <khaledhosny@eglug.org> Reviewed-on: https://gerrit.libreoffice.org/34093
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/gdi/winlayout.cxx30
1 files changed, 27 insertions, 3 deletions
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<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);
+ }
+ }
+
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);
}