Skip to content

TTF and OTF Replacement#2178

Open
G-LimeJuice wants to merge 4 commits intoPhobos-developers:developfrom
G-LimeJuice:TTF-OTF-Replacement
Open

TTF and OTF Replacement#2178
G-LimeJuice wants to merge 4 commits intoPhobos-developers:developfrom
G-LimeJuice:TTF-OTF-Replacement

Conversation

@G-LimeJuice
Copy link
Copy Markdown

@G-LimeJuice G-LimeJuice commented Apr 24, 2026

Overview

This implementation is hooked directly into the game code (BitFont & BitText) to replace legacy .FNT font rendering with modern .TTF / .OTF fonts.

It overrides the original font pipeline and injects custom rendering using external libraries.


How It Works

  • Hooks into BitFont and BitText rendering functions
  • Replaces .FNT font loading with .TTF / .OTF
  • Uses:
    • HarfBuzz → glyph shaping
    • FriBidi → RTL (Arabic) handling

Setup

  1. Go to your game directory
  2. Create a folder and rename it to “Fonts”.
  3. Add codes in UIMD.ini
[EnableTTF]
Enabled=TRUE;

[Font]
FileName=arial.ttf

[FontSize]
LatinSize=14
ArabicSize=15 ; Ignore it

Place your .ttf / .otf file inside the Fonts folder.
The font file name must match the value set in FileName.

If you don’t have a font file, you can download .ttf or .otf fonts from online font websites.

you need clone into the Phobos project directory to install dependencies (HarfBuzz and FriBidi).

Source: https://github.com/microsoft/vcpkg

Run the integration command on directory vcpkg:

.\vcpkg integrate install

If it doesn't work, specify the root manually:

Replace "Directory" with your actual path, for example:

C:\XXX\Phobos\vcpgk

.\vcpkg --vcpkg-root="Directory" integrate install

And install harfbuzz

.\vcpkg install harfbuzz --triplet x86-windows

And also install fribidi

.\vcpkg install fribidi --triplet x86-windows

Now your project should support .TTF and .OTF fonts with proper rendering.

## Overview
This implementation is **hooked directly into the game code (BitFont & BitText)** to replace legacy `.FNT` font rendering with modern `.TTF` / `.OTF` fonts.

It overrides the original font pipeline and injects custom rendering using external libraries.

---

## How It Works
- Hooks into **BitFont** and **BitText** rendering functions
- Replaces `.FNT` font loading with `.TTF` / `.OTF`
- Uses:
  - **HarfBuzz** → glyph shaping
  - **FriBidi** → RTL (Arabic) handling

---

## Setup

1. Go to your game directory
2. Create a folder:
3. Create a config file inside it (e.g. `config.ini`)

---

## Configuration

```ini
[EnableTTF]
Enabled=TRUE;

[Font]
FileName=arial.ttf

[Size]
LatinSize=14
ArabicSize=15 ; Ignore it

Place your `.ttf` / `.otf` file inside the `Fonts` folder.
The font file name must match the value set in `FileName`.

If you don’t have a font file, you can download `.ttf` or `.otf` fonts from online font websites.

`vcpkg` was cloned into the Phobos project directory to install dependencies (HarfBuzz and FriBidi).

Source: https://github.com/microsoft/vcpkg

Run the integration command:

`.\vcpkg integrate install`

Done!

Now your project should support .TTF and .OTF fonts with proper rendering.

If it doesn't work, specify the root manually:

Replace "Directory" with your actual path, for example:

`C:\XXX\Phobos\vcpgk `

`.\vcpkg --vcpkg-root="Directory" integrate install`
@TaranDahl TaranDahl added Needs testing ⚙️T2 T2 maintainer review is sufficient ❓Unhardcoding / Customization Make something more tweakable labels Apr 24, 2026
@TaranDahl
Copy link
Copy Markdown
Contributor

Docs are needed.

@TaranDahl
Copy link
Copy Markdown
Contributor

Create a config file inside it (e.g. config.ini)

Is it necessary to create a new ini file? Why not in RA2MD.ini, RULESMD.ini or UIMD.ini?

@G-LimeJuice
Copy link
Copy Markdown
Author

Create a config file inside it (e.g. config.ini)

Is it necessary to create a new ini file? Why not in RA2MD.ini, RULESMD.ini or UIMD.ini?

updated

@TaranDahl TaranDahl requested a review from Metadorius April 25, 2026 11:26
@G-LimeJuice G-LimeJuice force-pushed the TTF-OTF-Replacement branch 2 times, most recently from 56e8746 to 8cefd18 Compare April 29, 2026 20:51
@G-LimeJuice G-LimeJuice force-pushed the TTF-OTF-Replacement branch from 62e4796 to d29defe Compare April 30, 2026 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs testing ⚙️T2 T2 maintainer review is sufficient ❓Unhardcoding / Customization Make something more tweakable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants