Skip to content

Switch engine to UTF-8 and add FreeType TTF/OTF font rendering (closes #419)#2113

Open
ChugunovRoman wants to merge 6 commits into
OpenXRay:devfrom
ChugunovRoman:issues-419-switch-on-utf8
Open

Switch engine to UTF-8 and add FreeType TTF/OTF font rendering (closes #419)#2113
ChugunovRoman wants to merge 6 commits into
OpenXRay:devfrom
ChugunovRoman:issues-419-switch-on-utf8

Conversation

@ChugunovRoman

Copy link
Copy Markdown
Contributor

This PR switches the engine to native UTF-8 text handling and adds FreeType-based TTF/OTF font rendering while keeping the existing legacy X-Ray bitmap font path intact. On Windows, file-system paths and clipboard operations now use wide-character APIs so Unicode works end-to-end, and BOM stripping is applied to INI/XML/script files loaded by the engine. Console and UI edit-box input was also updated to work with UTF-8 characters.

Two new console variables control the font behavior:

  • r_font_legacy — toggles between legacy bitmap fonts (1) and FreeType TTF/OTF fonts (0, default). If a requested TTF/OTF font cannot be found, the engine automatically falls back to the legacy bitmap font for that section.
  • ui_text_scale — global multiplier for in-game UI text width/height.

Externals/freetype is added as a Git submodule pointing to the project fork; make sure to run git submodule update --init --recursive after checking out this branch. Legacy .ini metrics files are still expected to be CP1251-encoded and are mapped to Unicode at load time.

Closes #419

Use the OpenXRay-adapted fork at https://github.com/ChugunovRoman/freetype.git
(commit f025a8c92c09d55a43d696985913005add4907e0). The upstream FreeType repo
is not used; the fork already contains the PFR fix, so no manual patches are
needed.
… Cyrillic input

Migrates the engine to native UTF-8 text handling:
- Adds FreeType TTF/OTF font rendering (GameFont, dxFontRender, FontManager, UILines).
- Adds xrCore/Text/Utf8Utils for UTF-8 <-> CP1251/ACP/Wide conversions.
- Handles UTF-8 BOM in XML and INI files.
- Enables Cyrillic input in console/edit controls.
- Updates path handling (FS, LocatorAPI, os_clipboard) for Unicode/UTF-8.
- Adds FreeType MSVC project and wires it into engine.sln / CMake.

Files deleted on dev (xrSentry.cpp, multiline_edit_control.cpp/.h) are left
deleted; the freetype_pfr_stub.cpp from the original commit is omitted because
the fork already fixes the PFR issue.
- Fix text rendering at small UI scales.
- Adjust default text scale.
- Add r_font_legacy console variable to switch back to legacy bitmap fonts
  (.dds + .ini) alongside FreeType TTF/OTF rendering.
@github-actions github-actions Bot added Renderer UI External (3rd party) This issue is related to external component used by our project. Game assets A feature or an issue that involves gamedata change labels Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External (3rd party) This issue is related to external component used by our project. Game assets A feature or an issue that involves gamedata change Renderer UI

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Switch to UTF-8

1 participant