vcl/inc/win/salgdi.h    |    2 +-
 vcl/win/gdi/salfont.cxx |    7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)

New commits:
commit e75631211b596df3997f6fe6eb5422b931bd0384
Author:     Khaled Hosny <kha...@aliftype.com>
AuthorDate: Mon Sep 5 19:36:25 2022 +0200
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Tue Sep 6 07:19:57 2022 +0200

    vcl: Create HFNT on WinFontFace when needed
    
    I’m seeing frequent CI failures with warnings like:
    
    warn:sfx.appl:13336:18148:sfx2/source/appl/app.cxx:147: No DDE-Service 
possible. Error: 16399
    warn:vcl:13336:18148:vcl/win/gdi/salvd.cxx:99: CreateCompatibleDC failed: 
There are no more files.
    
    Lets see if this is causing us to hit the GDI object limit.
    
    Change-Id: I1257ac7e701277814b5d17b40192ad3bc81a8e0a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139449
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index ef7cdf210c94..b107308ec10b 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -80,7 +80,7 @@ private:
     BYTE                    mnPitchAndFamily;
     bool                    mbAliasSymbolsHigh;
     bool                    mbAliasSymbolsLow;
-    HFONT                   mhFont;
+    LOGFONTW                maLogFont;
 };
 
 /** Class that creates (and destroys) a compatible Device Context.
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 7614bbf4390c..200780426a5b 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -586,7 +586,7 @@ WinFontFace::WinFontFace(const ENUMLOGFONTEXW& rEnumFont, 
const NEWTEXTMETRICW&
     mnPitchAndFamily(rMetric.tmPitchAndFamily),
     mbAliasSymbolsHigh( false ),
     mbAliasSymbolsLow( false ),
-    mhFont(CreateFontIndirectW(&rEnumFont.elfLogFont))
+    maLogFont(rEnumFont.elfLogFont)
 {
     if (meWinCharSet == SYMBOL_CHARSET)
     {
@@ -612,7 +612,6 @@ WinFontFace::WinFontFace(const ENUMLOGFONTEXW& rEnumFont, 
const NEWTEXTMETRICW&
 
 WinFontFace::~WinFontFace()
 {
-    DeleteFont(mhFont);
 }
 
 sal_IntPtr WinFontFace::GetFontId() const
@@ -686,7 +685,8 @@ hb_blob_t* WinFontFace::GetHbTable(hb_tag_t nTag) const
     unsigned char* pBuffer = nullptr;
 
     HDC hDC(::GetDC(nullptr));
-    HFONT hOldFont = ::SelectFont(hDC, mhFont);
+    HFONT hFont = ::CreateFontIndirectW(&maLogFont);
+    HFONT hOldFont = ::SelectFont(hDC, hFont);
 
     nLength = ::GetFontData(hDC, OSL_NETDWORD(nTag), 0, nullptr, 0);
     if (nLength > 0 && nLength != GDI_ERROR)
@@ -696,6 +696,7 @@ hb_blob_t* WinFontFace::GetHbTable(hb_tag_t nTag) const
     }
 
     ::SelectFont(hDC, hOldFont);
+    ::DeleteFont(hFont);
     ::ReleaseDC(nullptr, hDC);
 
     hb_blob_t* pBlob = nullptr;

Reply via email to