Kawe Mazidjatari 8e81d99585 CppKore: fix potential font resource leak
As of commit 168ad9aabd624510045d56aabcbfeff6f4aaad6f, we can assign uniform fonts to all child controls, but only 1 control can own the font resource. This is by default false since we do not want to free the resource when destroying the child controls, but we do want to free it once the parent window gets destroyed.
2024-06-01 11:43:10 +02:00

31 lines
591 B
C++

#pragma once
#include <memory>
#include "DrawingBase.h"
namespace Drawing
{
// Represents a font used for text rendering
class Font
{
public:
Font() = default;
Font(HWND Handle, const HFONT hFont, const bool OwnsFont = false);
Font(HWND Handle, const Gdiplus::Font& FontObject);
virtual ~Font();
// Gets a handle to the native font
HFONT GetFontHandle();
// Returns a GDI+ font
std::unique_ptr<Gdiplus::Font> GetFont();
private:
// Internal handle
HWND _Handle;
// Internal native handle
HFONT _NativeFont;
// Internal cached state
bool _OwnsFont;
};
}