rodecomp/Source/Render/Text/FontCache.h
ragnarok-clanker 71afa48b43 Decompile 6 functions in Source/Render/Text/FontCache.cpp, Source/Render/Text/FontCache.h
Batch #11530 by Yommy: 1 byte-identical, 5 confirmed by peer review.

- fn_29519 FontCache::~FontCache: logic confirmed by peer review
- fn_01947 FontEntry::CreateSystemFont: logic confirmed by peer review
- fn_01948 CreateEmbeddedFont: logic confirmed by peer review
- fn_01949 FontEntry::CreatePrivateFont: logic confirmed by peer review
- fn_01958 FontCache::Get: logic confirmed by peer review
- fn_01956 ?MatchFont@?A0x1012ca8c@@YGHPBUtagLOGFONTA@@PBUtagTEXTMETRICA@@KJ@Z: byte-identical (already on main)

Peer-reviewed-by: KWDev, Tanke, cremane
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
2026-11-05 03:20:49 +00:00

74 lines
2 KiB
C++

#ifndef RAGNAROK_SOURCE_RENDER_TEXT_FONTCACHE_H
#define RAGNAROK_SOURCE_RENDER_TEXT_FONTCACHE_H
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <string>
#include <vector>
#include <windows.h>
#include <objidl.h>
namespace Gdiplus {
using std::max;
using std::min;
}
#include <gdiplus.h>
struct FontEntry {
void CreateSystemFont();
bool CreatePrivateFont();
void RemovePrivateFont() const;
/* 0000 */ int family;
/* 0004 */ int height;
/* 0008 */ unsigned charset;
/* 000C */ unsigned char bold;
/* 000D */ unsigned char italic;
/* 0010 */ HFONT font;
/* 0014 */ int privateResources;
};
class FontCache {
public:
FontCache();
~FontCache();
HFONT Get(int family, int height, unsigned charset, unsigned char bold, unsigned char italic);
private:
/* 0000 */ std::vector<FontEntry> m_fonts;
/* 000C */ Gdiplus::GdiplusStartupInput m_startup;
/* 001C */ ULONG_PTR m_gdiplus;
FontCache(const FontCache&) = delete;
FontCache& operator=(const FontCache&) = delete;
friend struct FontCacheLayout;
};
HFONT __stdcall CreateEmbeddedFont(int height, std::int16_t family);
std::string __stdcall PrivateFontFamilyName(const std::string& path);
int FallbackFontIndex(const std::string& name);
struct FontCacheLayout {
#if defined(_WIN32) && !defined(_WIN64)
static_assert(offsetof(FontCache, m_fonts) == 0x0000);
static_assert(offsetof(FontCache, m_startup) == 0x000C);
static_assert(offsetof(FontCache, m_gdiplus) == 0x001C);
#endif
};
#if defined(_WIN32) && !defined(_WIN64)
static_assert(sizeof(FontEntry) == 24);
static_assert(offsetof(FontEntry, family) == 0x0000);
static_assert(offsetof(FontEntry, height) == 0x0004);
static_assert(offsetof(FontEntry, charset) == 0x0008);
static_assert(offsetof(FontEntry, bold) == 0x000C);
static_assert(offsetof(FontEntry, italic) == 0x000D);
static_assert(offsetof(FontEntry, font) == 0x0010);
static_assert(offsetof(FontEntry, privateResources) == 0x0014);
#endif
extern FontCache g_fontCache;
#endif