From 5d39c2013374727b1c8f147b8b99d54402a7ff02 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Wed, 2 Nov 2016 01:37:21 +0200 Subject: [PATCH] tdf#71603: Create a new DC for the font fallback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some reason re-using the DC from SalGraphics results in GetFontData() returning GDI_ERROR and we fail to read the font’s “cmap” table. The wired thing is that this happens only for fonts that were not used before, so if you open a document directly the fallback works but if you open start center or blank Writer document you get no fallback. GDI is “interesting”. Change-Id: Ic23095cabbd2623717271ce5d89bea75dca76a9a --- vcl/win/gdi/salfont.cxx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index 8d6f0656b1fa..d0c00a63a4d5 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -146,7 +146,15 @@ class WinGlyphFallbackSubstititution : public ImplGlyphFallbackFontSubstitution { public: - explicit WinGlyphFallbackSubstititution( HDC ); + explicit WinGlyphFallbackSubstititution() + { + mhDC = GetDC(nullptr); + }; + + ~WinGlyphFallbackSubstititution() + { + ReleaseDC(nullptr, mhDC); + }; bool FindFontSubstitute( FontSelectPattern&, OUString& rMissingChars ) const override; private: @@ -154,10 +162,6 @@ class WinGlyphFallbackSubstititution bool HasMissingChars(PhysicalFontFace*, OUString& rMissingChars) const; }; -inline WinGlyphFallbackSubstititution::WinGlyphFallbackSubstititution( HDC hDC ) -: mhDC( hDC ) -{} - // does a font face hold the given missing characters? bool WinGlyphFallbackSubstititution::HasMissingChars(PhysicalFontFace* pFace, OUString& rMissingChars) const { @@ -1677,7 +1681,7 @@ void WinSalGraphics::GetDevFontList( PhysicalFontCollection* pFontCollection ) SalEnumFontsProcExW, reinterpret_cast(&aInfo), 0 ); // set glyph fallback hook - static WinGlyphFallbackSubstititution aSubstFallback( getHDC() ); + static WinGlyphFallbackSubstititution aSubstFallback; static WinPreMatchFontSubstititution aPreMatchFont; pFontCollection->SetFallbackHook( &aSubstFallback ); pFontCollection->SetPreMatchHook(&aPreMatchFont);