# HG changeset patch # User Michael Lutz # Date 2021-01-06 21:56:44 # Node ID 0ea535e59ac7887ea0bbba8c22fc20995a9bf111 # Parent b17cade5850e433068669c615dce267742f43975 Codechange: Make OS font handle of the FontCache read-only. diff --git a/src/fontcache.cpp b/src/fontcache.cpp --- a/src/fontcache.cpp +++ b/src/fontcache.cpp @@ -756,7 +756,7 @@ public: virtual GlyphID MapCharToGlyph(WChar key); virtual const char *GetFontName() { return WIDE_TO_MB(this->logfont.lfFaceName); } virtual bool IsBuiltInFont() { return false; } - virtual void *GetOSHandle() { return &this->logfont; } + virtual const void *GetOSHandle() { return &this->logfont; } }; diff --git a/src/fontcache.h b/src/fontcache.h --- a/src/fontcache.h +++ b/src/fontcache.h @@ -127,7 +127,7 @@ public: * Get the native OS font handle, if there is one. * @return Opaque OS font handle. */ - virtual void *GetOSHandle() + virtual const void *GetOSHandle() { return nullptr; } diff --git a/src/os/windows/string_uniscribe.cpp b/src/os/windows/string_uniscribe.cpp --- a/src/os/windows/string_uniscribe.cpp +++ b/src/os/windows/string_uniscribe.cpp @@ -144,7 +144,7 @@ void UniscribeResetScriptCache(FontSize /** Load the matching native Windows font. */ static HFONT HFontFromFont(Font *font) { - if (font->fc->GetOSHandle() != nullptr) return CreateFontIndirect((PLOGFONT)font->fc->GetOSHandle()); + if (font->fc->GetOSHandle() != nullptr) return CreateFontIndirect((const PLOGFONT)font->fc->GetOSHandle()); LOGFONT logfont; ZeroMemory(&logfont, sizeof(LOGFONT));