Kaydet (Commit) 2392238e authored tarafından Mark Hung's avatar Mark Hung

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/45609Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMark Hung <marklh9@gmail.com>
üst 962873c8
...@@ -826,6 +826,9 @@ void ImplGetLogFontFromFontSelect( HDC hDC, ...@@ -826,6 +826,9 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
memcpy( &rLogFont.lfFaceName[0], aName.getStr(), nNameLen*sizeof(wchar_t) ); memcpy( &rLogFont.lfFaceName[0], aName.getStr(), nNameLen*sizeof(wchar_t) );
if( nNameLen < LF_FACESIZE ) if( nNameLen < LF_FACESIZE )
rLogFont.lfFaceName[nNameLen] = '\0'; rLogFont.lfFaceName[nNameLen] = '\0';
// keep it upright and create the font for sideway glyphs later.
rLogFont.lfEscapement = rLogFont.lfEscapement - 2700;
rLogFont.lfOrientation = rLogFont.lfEscapement;
} }
} }
} }
......
...@@ -250,6 +250,7 @@ bool ExTextOutRenderer::operator ()(CommonSalLayout const &rLayout, ...@@ -250,6 +250,7 @@ bool ExTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
HFONT hFont = static_cast<HFONT>(GetCurrentObject( hDC, OBJ_FONT )); HFONT hFont = static_cast<HFONT>(GetCurrentObject( hDC, OBJ_FONT ));
HFONT hAltFont = nullptr; HFONT hAltFont = nullptr;
bool bUseAltFont = false; bool bUseAltFont = false;
bool bShift = false;
if (rLayout.getFontSelData().mbVertical) if (rLayout.getFontSelData().mbVertical)
{ {
LOGFONTW aLogFont; LOGFONTW aLogFont;
...@@ -260,8 +261,16 @@ bool ExTextOutRenderer::operator ()(CommonSalLayout const &rLayout, ...@@ -260,8 +261,16 @@ bool ExTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
sizeof(aLogFont.lfFaceName)-sizeof(aLogFont.lfFaceName[0])); sizeof(aLogFont.lfFaceName)-sizeof(aLogFont.lfFaceName[0]));
hAltFont = CreateFontIndirectW(&aLogFont); hAltFont = CreateFontIndirectW(&aLogFont);
} }
else
{
bShift = true;
aLogFont.lfEscapement += 2700;
aLogFont.lfOrientation = aLogFont.lfEscapement;
hAltFont = CreateFontIndirectW(&aLogFont);
}
} }
UINT nTextAlign = GetTextAlign ( hDC );
int nStart = 0; int nStart = 0;
Point aPos(0, 0); Point aPos(0, 0);
const GlyphItem* pGlyph; const GlyphItem* pGlyph;
...@@ -273,7 +282,13 @@ bool ExTextOutRenderer::operator ()(CommonSalLayout const &rLayout, ...@@ -273,7 +282,13 @@ bool ExTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
bUseAltFont = !bUseAltFont; bUseAltFont = !bUseAltFont;
SelectFont(hDC, bUseAltFont ? hAltFont : hFont); 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); ExtTextOutW(hDC, aPos.X(), aPos.Y(), ETO_GLYPH_INDEX, nullptr, LPCWSTR(&glyphWStr), 1, nullptr);
if (bShift && pGlyph->IsVertical())
SetTextAlign(hDC, nTextAlign);
} }
if (hAltFont) if (hAltFont)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment