Permalink
Browse files

tdf#71603: Create a new DC for the font fallback

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
  • Loading branch information...
1 parent 3f04f3f commit 5d39c2013374727b1c8f147b8b99d54402a7ff02 @khaledhosny khaledhosny committed Nov 1, 2016
Showing with 10 additions and 6 deletions.
  1. +10 −6 vcl/win/gdi/salfont.cxx
View
@@ -146,18 +146,22 @@ 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:
HDC mhDC;
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<LPARAM>(&aInfo), 0 );
// set glyph fallback hook
- static WinGlyphFallbackSubstititution aSubstFallback( getHDC() );
+ static WinGlyphFallbackSubstititution aSubstFallback;
static WinPreMatchFontSubstititution aPreMatchFont;
pFontCollection->SetFallbackHook( &aSubstFallback );
pFontCollection->SetPreMatchHook(&aPreMatchFont);

0 comments on commit 5d39c20

Please sign in to comment.