2V0-g: port the .fnt font pipeline over a FreeType GDI emulation
CGraphicText, CGraphicFontTexture and CGraphicDib are the 40250 bodies verbatim; CGraphicTextInstance is verbatim except that its D3D draws become UI render commands (one image quad per glyph, Bar for cursor/underline). - platform/Win32Gdi.cpp: the GDI subset those files call, over vendored FreeType 2.13.3, following GDI's LOGFONT cell height, win metrics and gasp rules; system font lookup with substitute and CJK fallback faces - Win32Crt: MultiByteToWideChar / WideCharToMultiByte (UTF-8 and 1252 by hand, other code pages through iconv) - CGraphicImageTexture memory textures: glyph pages reach Godot as "mem:<id>@<revision>"; Metin2PythonHost.memory_texture + Canvas cache - Util.cpp code page / font face table, SetDefaultCodePage at boot, DefaultFont_* block, fnt resource type, GetMaxTextureWidth/Height - TextTag, StringCodec, Arabic, Vietnamese copied from 40250 - tests: port.text (Tahoma 12 metrics, alignment, CP949), port.app_loop and python_host_test.gd now check glyph quads instead of text commands Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
141206cb69
commit
afe63bfa61
@@ -155,7 +155,6 @@ int g_iAccumulationTime = 0;
|
||||
|
||||
bool LoadLocaleData(const char*) { MT_PLATFORM_STUB(); return false; }
|
||||
void SetGuildSymbolPath(const char*) { MT_PLATFORM_STUB(); }
|
||||
void DefaultFont_SetName(const char*) { MT_PLATFORM_STUB(); }
|
||||
void TextTail_SetLivingTime(long) { MT_PLATFORM_STUB(); }
|
||||
namespace {
|
||||
// The supplied 40250 Client/locale.cfg selects "en" (code page 1252).
|
||||
@@ -173,3 +172,72 @@ void LocaleService_ForceSetLocale(const char* name, const char* path) {
|
||||
locale_name = name ? name : "";
|
||||
locale_path = path ? path : "";
|
||||
}
|
||||
|
||||
// 40250 UserInterface/GameType.cpp:9-73 (DEFAULT_FONT), verbatim.
|
||||
// PORT: the default names are CP949 literals in 40250; ui.py sets the locale font (app.SetDefaultFontName)
|
||||
// before anything asks for it.
|
||||
static std::string gs_strDefaultFontName = "굴림체:12.fnt";
|
||||
static std::string gs_strDefaultItalicFontName = "굴림체:12i.fnt";
|
||||
static CResource* gs_pkDefaultFont = NULL;
|
||||
static CResource* gs_pkDefaultItalicFont = NULL;
|
||||
|
||||
static bool gs_isReloadDefaultFont = false;
|
||||
|
||||
void DefaultFont_Startup()
|
||||
{
|
||||
gs_pkDefaultFont = NULL;
|
||||
}
|
||||
|
||||
void DefaultFont_Cleanup()
|
||||
{
|
||||
if (gs_pkDefaultFont)
|
||||
gs_pkDefaultFont->Release();
|
||||
}
|
||||
|
||||
void DefaultFont_SetName(const char * c_szFontName)
|
||||
{
|
||||
gs_strDefaultFontName = c_szFontName;
|
||||
gs_strDefaultFontName += ".fnt";
|
||||
|
||||
gs_strDefaultItalicFontName = c_szFontName;
|
||||
if(strchr(c_szFontName, ':'))
|
||||
gs_strDefaultItalicFontName += "i";
|
||||
gs_strDefaultItalicFontName += ".fnt";
|
||||
|
||||
gs_isReloadDefaultFont = true;
|
||||
}
|
||||
|
||||
bool ReloadDefaultFonts()
|
||||
{
|
||||
CResourceManager& rkResMgr = CResourceManager::Instance();
|
||||
|
||||
gs_isReloadDefaultFont = false;
|
||||
|
||||
CResource* pkNewFont = rkResMgr.GetResourcePointer(gs_strDefaultFontName.c_str());
|
||||
pkNewFont->AddReference();
|
||||
if (gs_pkDefaultFont)
|
||||
gs_pkDefaultFont->Release();
|
||||
gs_pkDefaultFont = pkNewFont;
|
||||
|
||||
CResource* pkNewItalicFont = rkResMgr.GetResourcePointer(gs_strDefaultItalicFontName.c_str());
|
||||
pkNewItalicFont->AddReference();
|
||||
if (gs_pkDefaultItalicFont)
|
||||
gs_pkDefaultItalicFont->Release();
|
||||
gs_pkDefaultItalicFont = pkNewItalicFont;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CResource* DefaultFont_GetResource()
|
||||
{
|
||||
if (!gs_pkDefaultFont || gs_isReloadDefaultFont)
|
||||
ReloadDefaultFonts();
|
||||
return gs_pkDefaultFont;
|
||||
}
|
||||
|
||||
CResource* DefaultItalicFont_GetResource()
|
||||
{
|
||||
if (!gs_pkDefaultItalicFont || gs_isReloadDefaultFont)
|
||||
ReloadDefaultFonts();
|
||||
return gs_pkDefaultItalicFont;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user