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:
shenlei
2026-09-23 14:17:25 +09:00
co-authored by Claude Opus 5.5
parent 141206cb69
commit afe63bfa61
272 changed files with 137097 additions and 316 deletions
+20 -1
View File
@@ -8,7 +8,8 @@ build. Crypto++ joined later (2026-09-02) with the `MT_PROTOCOL=classic` 40250
backend and was vendored the same way from the start.
CPython joined on 2026-09-23 with 批次 2P (the embedded 40250 script layer) and is
vendored source as well.
vendored source as well. FreeType joined the same day with 批次 2V0-g (the 40250
font path over an emulated GDI).
Everything lives under `extension/third_party/` and is wired by
`extension/third_party/CMakeLists.txt`, which exposes five aliases:
@@ -20,6 +21,7 @@ Everything lives under `extension/third_party/` and is wired by
| `mt3p::minilzo` | `minilzo` | `mtproto` |
| `mt3p::cryptopp` | `cryptopp` | `mtnet` (classic backend) |
| `mt3p::python` | `mtpython` | the script layer (`py_embed_test`) |
| `mt3p::freetype` | `freetype` | `port_platform` (`platform/Win32Gdi.cpp`) |
No source file changed: `#include <sodium.h>`, `#include <zstd.h>`,
`#include <lzo/lzo1x.h>` and `#include <cryptopp/…>` all still resolve (the LZO
@@ -143,6 +145,23 @@ one via a 1-line shim header, see below).
only obligation is keeping the license and a change notice, which this section
and the patched files' comments serve.
## FreeType 2.13.3 — vendored source, trimmed (not a submodule)
* **Files:** `extension/third_party/freetype-2.13.3/` (~5 MB): the official
`freetype-2.13.3.tar.xz` (source URL and sha256 in the directory's
`CMakeLists.txt` header) cut down to `include/`, `src/{base,sfnt,truetype,smooth,raster,psnames,gzip}`,
`LICENSE.TXT` and `docs/FTL.TXT`.
* **Build:** our own `CMakeLists.txt` (upstream's pulls in optional deps we don't
want); `mt-config/freetype/config/ftmodule.h` replaces the stock module list with
TrueType + sfnt + the mono and gray rasterizers. No upstream file is modified.
* **Why:** 40250's `CGraphicFontTexture` / `CGraphicDib` render glyphs with GDI
(`CreateFontIndirect`, `TextOutW` into a DIB section). `platform/Win32Gdi.cpp`
implements that GDI subset over FreeType with GDI's cell-height, win-metric and
gasp rules, so the 40250 font code stays verbatim.
* **License:** FreeType License (`docs/FTL.TXT`, BSD-style with credit clause):
the shipped product's documentation must credit "Portions of this software are
copyright © The FreeType Project (www.freetype.org)".
## Rebuilding / fetching
`./build.sh` auto-runs `git submodule update --init --recursive` if any of the