From 5ad16409847a17534389054a1b7f5fb83703fb4d Mon Sep 17 00:00:00 2001 From: Michael Lutz Date: Wed, 6 Jan 2021 22:56:44 +0100 Subject: [PATCH] Codechange: Make OS font handle of the FontCache read-only. --- src/fontcache.cpp | 2 +- src/fontcache.h | 2 +- src/os/windows/string_uniscribe.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fontcache.cpp b/src/fontcache.cpp index 0b2764aabf..9cdc0b9755 100644 --- 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 index 4c44876da1..fac08a3537 100644 --- 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 index ad37548662..6c0a9366e9 100644 --- a/src/os/windows/string_uniscribe.cpp +++ b/src/os/windows/string_uniscribe.cpp @@ -144,7 +144,7 @@ void UniscribeResetScriptCache(FontSize size) /** 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));