Kaydet (Commit) a51b7a1c authored tarafından Khaled Hosny's avatar Khaled Hosny

tdf#103831, tdf#100986: Force using GDI when needed

Our DirectWrite renderer is incomplete and can’t handle rotated text or text
with horizontal scaling, so route these two through GDI for now.

Change-Id: I87b85796a29e3acce782e01b4c629fec6f1a9e25
Reviewed-on: https://gerrit.libreoffice.org/34848Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarKhaled Hosny <khaledhosny@eglug.org>
üst 5742868c
......@@ -70,6 +70,7 @@ public:
const FontSelectPattern& getFontSelData() const { return mrFontSelData; };
HFONT getHFONT() const { return mhFont; }
WinFontInstance& getWinFontInstance() const { return mrWinFontInstance; }
bool hasHScale() const;
#elif defined(MACOSX) || defined(IOS)
explicit CommonSalLayout(const CoreTextStyle&);
const CoreTextStyle& getFontData() const { return mrCoreTextStyle; };
......
......@@ -38,11 +38,6 @@ T lround(T x)
}
#endif
#ifdef _WIN32
# include <vcl/opengl/OpenGLHelper.hxx>
#endif
static hb_blob_t* getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* pUserData)
{
char pTagName[5];
......@@ -189,7 +184,7 @@ CommonSalLayout::CommonSalLayout(HDC hDC, WinFontInstance& rWinFontInstance, con
}
// Calculate the mnAveWidthFactor, see the comment where it is used.
if (mrFontSelData.mnWidth && ! OpenGLHelper::isVCLOpenGLEnabled())
if (mrFontSelData.mnWidth)
{
double nUPEM = hb_face_get_upem(hb_font_get_face(mpHbFont));
......@@ -213,6 +208,13 @@ CommonSalLayout::CommonSalLayout(HDC hDC, WinFontInstance& rWinFontInstance, con
}
}
bool CommonSalLayout::hasHScale() const
{
int nHeight(mrFontSelData.mnHeight);
int nWidth(mrFontSelData.mnWidth ? mrFontSelData.mnWidth * mnAveWidthFactor : nHeight);
return nWidth != nHeight;
}
#elif defined(MACOSX) || defined(IOS)
CommonSalLayout::CommonSalLayout(const CoreTextStyle& rCoreTextStyle)
: mrFontSelData(rCoreTextStyle.maFontSelData)
......
......@@ -77,26 +77,6 @@ bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, HFONT hFont, int nGlyphIndex, S
return false;
}
// Bail for non-horizontal text.
{
wchar_t sFaceName[200];
int nFaceNameLen = GetTextFaceW(hNewDC, SAL_N_ELEMENTS(sFaceName), sFaceName);
if (!nFaceNameLen)
SAL_WARN("vcl.gdi", "GetTextFace failed: " << WindowsErrorString(GetLastError()));
LOGFONTW aLogFont;
GetObjectW(hFont, sizeof(LOGFONTW), &aLogFont);
SelectObject(hNewDC, hOrigFont);
DeleteDC(hNewDC);
if (sFaceName[0] == '@' || aLogFont.lfOrientation != 0 || aLogFont.lfEscapement != 0)
{
pTxt->ReleaseFont();
return false;
}
}
std::vector<WORD> aGlyphIndices(1);
aGlyphIndices[0] = nGlyphIndex;
// Fetch the ink boxes and calculate the size of the atlas.
......@@ -725,13 +705,18 @@ void WinSalGraphics::DrawTextLayout(const CommonSalLayout& rLayout, HDC hDC, boo
void WinSalGraphics::DrawTextLayout(const CommonSalLayout& rLayout)
{
HDC hDC = getHDC();
// Our DirectWrite renderer is incomplete, skip it for non-horizontal or
// stretched text.
bool bForceGDI = rLayout.GetOrientation() || rLayout.hasHScale();
bool bUseOpenGL = OpenGLHelper::isVCLOpenGLEnabled() && !mbPrinter;
if (!bUseOpenGL)
{
// no OpenGL, just classic rendering
DrawTextLayout(rLayout, hDC, false);
DrawTextLayout(rLayout, hDC, !bForceGDI);
}
else if (CacheGlyphs(rLayout) &&
else if (!bForceGDI && CacheGlyphs(rLayout) &&
DrawCachedGlyphs(rLayout))
{
// Nothing
......@@ -798,7 +783,7 @@ void WinSalGraphics::DrawTextLayout(const CommonSalLayout& rLayout)
SalColor salColor = MAKE_SALCOLOR(GetRValue(color), GetGValue(color), GetBValue(color));
// the actual drawing
DrawTextLayout(rLayout, aDC.getCompatibleHDC(), true);
DrawTextLayout(rLayout, aDC.getCompatibleHDC(), !bForceGDI);
std::unique_ptr<OpenGLTexture> xTexture(aDC.getTexture());
if (xTexture)
......
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