Skip to content

Commit ea93877

Browse files
committed
feat(demo_game): update font usage and build process for demo pack
This commit replaces the Inter-Regular font with Inter_28pt-Regular.ttf across the demo game assets, enhancing text rendering quality. The build scripts and documentation have been updated to reflect the new font integration and the addition of a demo build target, which compiles the demo pack and copies necessary assets. Additionally, error handling for missing font files has been improved to ensure a smoother build process.
1 parent 69e6342 commit ea93877

13 files changed

Lines changed: 172 additions & 110 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ See `CLAUDE.md` for canonical build commands. The primary build script is `./scr
1414
./scripts/compile_engine.sh vulkan # Vulkan renderer, Release
1515
./scripts/compile_engine.sh opengl # OpenGL renderer, Release
1616
./scripts/compile_engine.sh vulkan debug # Vulkan renderer, Debug
17+
./scripts/compile_engine.sh vulkan demo # Also builds idtech3_demo.pk3 → release/demo_game/
1718
./scripts/compile_engine.sh clean vulkan # Clean build
1819
```
1920

CLAUDE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ sudo apt-get install cmake clang-18 gcc-15 ninja-build
268268
# Vulkan build (recommended)
269269
./scripts/compile_engine.sh vulkan
270270

271+
# Same, plus example demo mod: BUILD_EXAMPLE_DEMO_GAME=ON, target demo_game_pk3,
272+
# copies idtech3_demo.pk3 to release/demo_game/ when the pack builds successfully
273+
./scripts/compile_engine.sh vulkan demo
274+
271275
# OpenGL build (fallback)
272276
./scripts/compile_engine.sh opengl
273277

examples/demo_game/CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
set(DEMO_MOD_DIR "${CMAKE_SOURCE_DIR}/examples/demo_game/mod")
55
set(DEMO_BOOTSTRAP_DIR "${CMAKE_SOURCE_DIR}/examples/demo_game/bootstrap_media")
6+
set(DEMO_INTER_PACK_FONT "${CMAKE_SOURCE_DIR}/fonts/Inter_28pt-Regular.ttf")
67
set(DEMO_PK3 "${CMAKE_BINARY_DIR}/idtech3_demo.pk3")
78
set(DEMO_PACK_STAGING "${CMAKE_BINARY_DIR}/idtech3_demo_pack_staging")
89

@@ -14,15 +15,18 @@ set(DEMO_BOOTSTRAP_GFX_DEMO
1415
"${DEMO_BOOTSTRAP_DIR}/gfx/demo/bootstrap_shadow.png"
1516
)
1617
set(DEMO_BOOTSTRAP_FONTS
17-
"${DEMO_BOOTSTRAP_DIR}/fonts/Inter-Regular.ttf"
1818
"${DEMO_BOOTSTRAP_DIR}/fonts/LICENSE.txt"
1919
"${DEMO_BOOTSTRAP_DIR}/fonts/demo_console_sdf.png"
2020
"${DEMO_BOOTSTRAP_DIR}/fonts/demo_console_sdf.fnt"
2121
)
2222

23+
if(NOT EXISTS "${DEMO_INTER_PACK_FONT}")
24+
message(FATAL_ERROR "Missing demo UI TTF: ${DEMO_INTER_PACK_FONT}\n The idtech3_demo pack ships this file as fonts/Inter_28pt-Regular.ttf.\n SDF console atlas: python3 examples/demo_game/tools/gen_demo_console_sdf.py \"${DEMO_INTER_PACK_FONT}\" examples/demo_game/bootstrap_media/fonts")
25+
endif()
26+
2327
foreach(_demo_boot_chk IN LISTS DEMO_BOOTSTRAP_GFX2D DEMO_BOOTSTRAP_GFX_DEMO DEMO_BOOTSTRAP_FONTS)
2428
if(NOT EXISTS "${_demo_boot_chk}")
25-
message(FATAL_ERROR "Missing demo bootstrap file: ${_demo_boot_chk}\n Regenerate PNGs: python3 examples/demo_game/tools/gen_demo_bootstrap_media.py examples/demo_game/bootstrap_media\n SDF console font: python3 examples/demo_game/tools/gen_demo_console_sdf.py examples/demo_game/bootstrap_media/fonts/Inter-Regular.ttf examples/demo_game/bootstrap_media/fonts\n Install Inter OFL fonts under examples/demo_game/bootstrap_media/fonts/ if missing.")
29+
message(FATAL_ERROR "Missing demo bootstrap file: ${_demo_boot_chk}\n Regenerate PNGs: python3 examples/demo_game/tools/gen_demo_bootstrap_media.py examples/demo_game/bootstrap_media\n SDF console font: python3 examples/demo_game/tools/gen_demo_console_sdf.py \"${DEMO_INTER_PACK_FONT}\" examples/demo_game/bootstrap_media/fonts")
2630
endif()
2731
endforeach()
2832

@@ -112,7 +116,7 @@ add_custom_command(
112116
COMMAND ${CMAKE_COMMAND} -E copy_if_different
113117
"${DEMO_BOOTSTRAP_DIR}/gfx/demo/bootstrap_shadow.png" "${DEMO_PACK_STAGING}/gfx/demo/bootstrap_shadow.png"
114118
COMMAND ${CMAKE_COMMAND} -E copy_if_different
115-
"${DEMO_BOOTSTRAP_DIR}/fonts/Inter-Regular.ttf" "${DEMO_PACK_STAGING}/fonts/Inter-Regular.ttf"
119+
"${DEMO_INTER_PACK_FONT}" "${DEMO_PACK_STAGING}/fonts/Inter_28pt-Regular.ttf"
116120
COMMAND ${CMAKE_COMMAND} -E copy_if_different
117121
"${DEMO_BOOTSTRAP_DIR}/fonts/LICENSE.txt" "${DEMO_PACK_STAGING}/fonts/LICENSE.txt"
118122
COMMAND ${CMAKE_COMMAND} -E copy_if_different
@@ -134,7 +138,7 @@ add_custom_command(
134138
gfx/demo/bootstrap_console.png
135139
gfx/demo/bootstrap_flare.png
136140
gfx/demo/bootstrap_shadow.png
137-
fonts/Inter-Regular.ttf
141+
fonts/Inter_28pt-Regular.ttf
138142
fonts/LICENSE.txt
139143
fonts/demo_console_sdf.png
140144
fonts/demo_console_sdf.fnt

examples/demo_game/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This is **not** a standalone game: it is a **tiny mod** (`.pk3` of configs) you
66

77
| Artifact | Description |
88
|----------|-------------|
9-
| `idtech3_demo.pk3` | Config mod + **minimal native UI** (inside the zip as **`vm/ui<arch>.so`** and **`vm/ui.<arch>.so`**, same binary): enough to open a window without retail `ui.qvm`. The engine packs native shared libraries only inside zips; it **extracts** them to **`vm/native_cache/`** under your game home path (toggle **`com_nativeLibraryExtractPk3`**, default **1**) then loads that file, because `dlopen` cannot read zip entries directly. Also **Duktape** (`demo_js.cfg`), optional **Lua** (`demo_lua.cfg` / `scripts/lua/` when built with `USE_LUA`), and gameplay hints. **Bootstrap renderer assets** ship in the same zip (`gameinfo.txt`, `scripts/demo_bootstrap.shader`, `gfx/2d/bigchars.png`, small `gfx/demo/*.png`, **Inter** `fonts/Inter-Regular.ttf` + `fonts/LICENSE.txt`) so an **empty `base/`** still clears shader init and default `r_font` without retail `pak0`. For the filesystem **`default.cfg`** gate, use **`examples/demo_skeleton/base/z_minimal_bootstrap.pk3`** in **`base/`** (or retail paks). Regenerate PNGs with `python3 examples/demo_game/tools/gen_demo_bootstrap_media.py examples/demo_game/bootstrap_media`. |
9+
| `idtech3_demo.pk3` | Config mod + **minimal native UI** (inside the zip as **`vm/ui<arch>.so`** and **`vm/ui.<arch>.so`**, same binary): enough to open a window without retail `ui.qvm`. The engine packs native shared libraries only inside zips; it **extracts** them to **`vm/native_cache/`** under your game home path (toggle **`com_nativeLibraryExtractPk3`**, default **1**) then loads that file, because `dlopen` cannot read zip entries directly. Also **Duktape** (`demo_js.cfg`), optional **Lua** (`demo_lua.cfg` / `scripts/lua/` when built with `USE_LUA`), and gameplay hints. **Bootstrap renderer assets** ship in the same zip (`gameinfo.txt`, `scripts/demo_bootstrap.shader`, `gfx/2d/bigchars.png`, small `gfx/demo/*.png`, **Inter** `fonts/Inter_28pt-Regular.ttf` from repo `fonts/` + `fonts/LICENSE.txt`) so an **empty `base/`** still clears shader init; `demo_features.cfg` sets **`r_font`** to that file. For the filesystem **`default.cfg`** gate, use **`examples/demo_skeleton/base/z_minimal_bootstrap.pk3`** in **`base/`** (or retail paks). Regenerate PNGs with `python3 examples/demo_game/tools/gen_demo_bootstrap_media.py examples/demo_game/bootstrap_media`. |
1010
| `idtech3_demo_helper` | Optional tiny host binary that prints launch hints (built when `BUILD_EXAMPLE_DEMO_GAME=ON`). |
1111

1212
### “Playable” without custom qagame
@@ -63,7 +63,7 @@ Quick path: use the **[demo skeleton](../demo_skeleton/README.md)** (`run_demo_c
6363

6464
3. On load, `autoexec.cfg` runs `demo_features.cfg`, `demo_js.cfg`, `demo_lua.cfg`, and `demo_gameplay.cfg`. Edit files under `mod/` and rebuild `demo_game_pk3`.
6565

66-
**SDF console text:** `demo_features.cfg` enables `r_sdfEnable` / `r_sdfFont` using the packed **BMFont + distance atlas** (`fonts/demo_console_sdf.png` + `.fnt`). Regenerate with `python3 examples/demo_game/tools/gen_demo_console_sdf.py …/Inter-Regular.ttf examples/demo_game/bootstrap_media/fonts` (needs Pillow, numpy, scipy). If `autoexec.cfg` does not run from your install path, run `exec demo_features` once or add the same `r_sdf*` lines to your `default.cfg`.
66+
**SDF console text:** `demo_features.cfg` enables `r_sdfEnable` / `r_sdfFont` using the packed **BMFont + distance atlas** (`fonts/demo_console_sdf.png` + `.fnt`). Regenerate with `python3 examples/demo_game/tools/gen_demo_console_sdf.py fonts/Inter_28pt-Regular.ttf examples/demo_game/bootstrap_media/fonts` (needs Pillow, numpy, scipy). If `autoexec.cfg` does not run from your install path, run `exec demo_features` once or add the same `r_font` / `r_sdf*` lines to your `default.cfg`.
6767

6868
**JavaScript:** requires **USE_DUKTAPE** in the engine build. If `js_reload` fails, check the console; ensure `js_allowEvents` is `1` (default).
6969

-402 KB
Binary file not shown.

0 commit comments

Comments
 (0)