aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-01 21:32:55 +0300
committerValentin Popov <valentin@popov.link>2026-12-01 21:32:55 +0300
commitb48fb2caccc7a72b85f07e6ab652081af57c7855 (patch)
tree851858e8881e9c0ba1892b1173212092b53ff86c
parent6954eb74b535341bed234091e67f62ed13266c25 (diff)
downloadfparkan-b48fb2caccc7a72b85f07e6ab652081af57c7855.tar.xz
fparkan-b48fb2caccc7a72b85f07e6ab652081af57c7855.zip
feat(ui): render mission hints with the original game font
Resolve the witnessed 800x600 GAME_FONT through the installed resource configuration. Draw CP1251 bytes from the Tfnt atlas using the original variable-width metrics. Checked the original measurement routine and the first Constructor hint in the game window.
-rw-r--r--Cargo.lock2
-rw-r--r--README.md1
-rw-r--r--apps/fparkan-game/src/mission_hints.rs10
-rw-r--r--crates/fparkan-assets/Cargo.toml1
-rw-r--r--crates/fparkan-assets/src/game_font.rs54
-rw-r--r--crates/fparkan-assets/src/lib.rs2
-rw-r--r--crates/fparkan-assets/src/satellite_map.rs53
-rw-r--r--crates/fparkan-assets/src/ui_configuration.rs54
-rw-r--r--crates/fparkan-font/Cargo.toml1
-rw-r--r--crates/fparkan-font/src/bitmap.rs162
-rw-r--r--crates/fparkan-font/src/lib.rs15
-rw-r--r--docs/appendices/ui-shell.md32
12 files changed, 314 insertions, 73 deletions
diff --git a/Cargo.lock b/Cargo.lock
index f0331fdf..696ba441 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -470,6 +470,7 @@ name = "fparkan-assets"
version = "0.1.0"
dependencies = [
"fparkan-binary",
+ "fparkan-font",
"fparkan-material",
"fparkan-mission-format",
"fparkan-msh",
@@ -491,6 +492,7 @@ version = "0.1.0"
name = "fparkan-font"
version = "0.1.0"
dependencies = [
+ "encoding_rs",
"fparkan-nres",
"fparkan-texm",
]
diff --git a/README.md b/README.md
index 142f2353..a46805bf 100644
--- a/README.md
+++ b/README.md
@@ -75,6 +75,7 @@ Esc возвращает управление костюмом с прежним
Вне коммуникатора R включает и выключает бортовой саморемонт, если у героя
или управляемой машины есть это устройство. Саморемонт расходует питание.
`M` показывает и скрывает спутниковую карту миссии с компасом.
+`F2` скрывает и возвращает текущую подсказку. Текст рисуется игровым шрифтом из `ui/font.lib`.
Чтобы развернуть шахту, подойдите к месторождению и нажмите `Ctrl+M`. Заказ
использует руду ближайшего союзного строителя. Шахта подаёт добытую руду
в распределитель клана.
diff --git a/apps/fparkan-game/src/mission_hints.rs b/apps/fparkan-game/src/mission_hints.rs
index 9e6e2055..3ec9c440 100644
--- a/apps/fparkan-game/src/mission_hints.rs
+++ b/apps/fparkan-game/src/mission_hints.rs
@@ -4,6 +4,7 @@ use super::{
EnvironmentGpuRange, LegacyBlendMode, LegacyDepthMode, StaticPreviewScene, Vfs,
VulkanSmokeRenderer, VulkanStaticMesh, VulkanStaticTexture,
};
+use fparkan_assets::game_font::{load_game_font, BitmapFont};
use fparkan_path::{normalize_relative, PathPolicy};
use fparkan_platform_winit::text::{caption, StringResources};
use fparkan_runtime::MissionScriptOutcome;
@@ -48,6 +49,7 @@ struct MessageResources {
catalog: Arc<[u8]>,
strings: StringResources,
sender_strings: Option<StringResources>,
+ font: BitmapFont,
}
impl MissionHints {
@@ -163,7 +165,12 @@ impl MissionHints {
self.active = None;
if pager_visible(message.posted_ms, clock) {
let index = message.index;
- let (height, rgba) = match caption(&message.body, WIDTH, HEIGHT) {
+ let font = &self
+ .messages
+ .as_ref()
+ .expect("posted message resources")
+ .font;
+ let (height, rgba) = match font.caption(&message.body, WIDTH, HEIGHT) {
Ok(caption) => caption,
Err(error) => {
eprintln!(
@@ -266,6 +273,7 @@ impl MessageResources {
catalog,
strings,
sender_strings,
+ font: load_game_font(&vfs)?,
}))
}
}
diff --git a/crates/fparkan-assets/Cargo.toml b/crates/fparkan-assets/Cargo.toml
index c2b84416..663da7c5 100644
--- a/crates/fparkan-assets/Cargo.toml
+++ b/crates/fparkan-assets/Cargo.toml
@@ -7,6 +7,7 @@ repository.workspace = true
[dependencies]
fparkan-binary = { path = "../fparkan-binary" }
+fparkan-font = { path = "../fparkan-font" }
fparkan-material = { path = "../fparkan-material" }
fparkan-msh = { path = "../fparkan-msh" }
fparkan-nres = { path = "../fparkan-nres" }
diff --git a/crates/fparkan-assets/src/game_font.rs b/crates/fparkan-assets/src/game_font.rs
new file mode 100644
index 00000000..556aa79d
--- /dev/null
+++ b/crates/fparkan-assets/src/game_font.rs
@@ -0,0 +1,54 @@
+//! Original game text font used by the mission pager.
+
+use crate::ui_configuration::{field, number, object, read};
+use fparkan_font::decode_tfnt;
+pub use fparkan_font::BitmapFont;
+use fparkan_nres::{decode, EntryId, ReadProfile};
+use fparkan_vfs::Vfs;
+use std::sync::Arc;
+
+/// Load the `GAME_FONT` for the 800×600 pager profile witnessed in the original.
+pub fn load_game_font(vfs: &dyn Vfs) -> Result<BitmapFont, String> {
+ let bytes = read(vfs, "ui/game_resources.cfg")?;
+ let cfg = String::from_utf8_lossy(&bytes);
+ let aliases = object(&cfg, "font_substitutes2").ok_or("missing 800×600 font profile")?;
+ if [
+ number(&aliases, "DIMENSION_X")?,
+ number(&aliases, "DIMENSION_Y")?,
+ ] != [800, 600]
+ {
+ return Err("unexpected dimensions for the 800×600 font profile".into());
+ }
+ let key = field(&aliases, "GAME_FONT")?.to_ascii_uppercase();
+ let fonts = object(&cfg, "fonts").ok_or("missing font catalog")?;
+ let id = EntryId(number(&fonts, &key)?);
+ let archive = decode(read(vfs, field(&fonts, "LIBRARY")?)?, ReadProfile::Strict)
+ .map_err(|error| error.to_string())?;
+ let payload = archive.payload(id).map_err(|error| error.to_string())?;
+ let font = decode_tfnt(Arc::from(payload)).map_err(|error| error.to_string())?;
+ BitmapFont::prepare(&font)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::load_game_font;
+ use fparkan_vfs::DirectoryVfs;
+
+ #[test]
+ #[ignore = "requires licensed corpus"]
+ fn draws_russian_and_latin_glyphs_from_the_original_game_font() {
+ let root = std::env::var_os("FPARKAN_CORPUS_PART1_ROOT").expect("licensed corpus");
+ let font = load_game_font(&DirectoryVfs::new(root)).unwrap();
+ let (height, latin) = font.caption("A", 96, 80).unwrap();
+ let (russian_height, russian) = font.caption("П", 96, 80).unwrap();
+ assert_eq!(height, 34);
+ assert_eq!(russian_height, height);
+ assert_ne!(latin, russian);
+ for image in [&latin, &russian] {
+ assert!(image.chunks_exact(4).any(|pixel| pixel[0] == 255));
+ assert!(image.chunks_exact(4).any(|pixel| pixel[0] == 64));
+ }
+ let (multiline, _) = font.caption("Курсант\nA", 96, 80).unwrap();
+ assert_eq!(multiline, 45);
+ }
+}
diff --git a/crates/fparkan-assets/src/lib.rs b/crates/fparkan-assets/src/lib.rs
index db7484cf..75851628 100644
--- a/crates/fparkan-assets/src/lib.rs
+++ b/crates/fparkan-assets/src/lib.rs
@@ -35,8 +35,10 @@ mod chassis_profile;
mod control_drive;
mod control_weapon_sound;
mod explosion_profile;
+pub mod game_font;
pub mod satellite_map;
mod turret_elevation;
+mod ui_configuration;
pub use behavior_profile_values::{
decode_behavior_go_speed_percent, decode_behavior_work_rates, BehaviorWorkRates,
};
diff --git a/crates/fparkan-assets/src/satellite_map.rs b/crates/fparkan-assets/src/satellite_map.rs
index 49f8894e..9a18f2bd 100644
--- a/crates/fparkan-assets/src/satellite_map.rs
+++ b/crates/fparkan-assets/src/satellite_map.rs
@@ -1,11 +1,11 @@
//! Resources used by the satellite map overlay.
+use crate::ui_configuration::{field, number, object, read};
use fparkan_nres::{decode, EntryId, ReadProfile};
use fparkan_path::{normalize_relative, PathPolicy};
use fparkan_resource::{resource_name, CachedResourceRepository, ResourceRepository};
use fparkan_texm::{decode_mip_rgba8, decode_texm, RgbaImage};
use fparkan_vfs::Vfs;
-use std::collections::BTreeMap;
use std::sync::Arc;
/// The mission map and compass cut from the original interface texture atlas.
@@ -69,57 +69,6 @@ pub fn load_satellite_map(
}))
}
-fn read(vfs: &dyn Vfs, path: &str) -> Result<Arc<[u8]>, String> {
- let path = normalize_relative(
- path.replace("\\\\", "\\").as_bytes(),
- PathPolicy::StrictLegacy,
- )
- .map_err(|error| error.to_string())?;
- vfs.read(&path).map_err(|error| error.to_string())
-}
-
-fn object<'a>(text: &'a str, name: &str) -> Option<BTreeMap<String, &'a str>> {
- let mut lines = text
- .lines()
- .map(|line| line.split('#').next().unwrap_or_default().trim());
- for line in lines.by_ref() {
- let mut words = line.split_whitespace();
- if words
- .next()
- .is_some_and(|word| word.eq_ignore_ascii_case("object"))
- && words
- .next()
- .is_some_and(|word| word.eq_ignore_ascii_case(name))
- {
- return Some(
- lines
- .take_while(|line| !line.eq_ignore_ascii_case("end"))
- .filter_map(|line| line.split_once('='))
- .map(|(key, value)| (key.trim().to_ascii_uppercase(), value.trim()))
- .collect(),
- );
- }
- }
- None
-}
-
-fn field<'a>(fields: &BTreeMap<String, &'a str>, key: &str) -> Result<&'a str, String> {
- let raw = fields.get(key).ok_or_else(|| format!("missing {key}"))?;
- if let Some(quoted) = raw.strip_prefix('"') {
- return quoted
- .split_once('"')
- .map(|(value, _)| value)
- .ok_or_else(|| format!("invalid quoted value for {key}"));
- }
- Ok(raw)
-}
-
-fn number(fields: &BTreeMap<String, &str>, key: &str) -> Result<u32, String> {
- field(fields, key)?
- .parse()
- .map_err(|_| format!("invalid number for {key}"))
-}
-
fn texture(bytes: &[u8]) -> Result<RgbaImage, String> {
let document = decode_texm(Arc::from(bytes)).map_err(|error| error.to_string())?;
decode_mip_rgba8(&document, 0).map_err(|error| error.to_string())
diff --git a/crates/fparkan-assets/src/ui_configuration.rs b/crates/fparkan-assets/src/ui_configuration.rs
new file mode 100644
index 00000000..e678d760
--- /dev/null
+++ b/crates/fparkan-assets/src/ui_configuration.rs
@@ -0,0 +1,54 @@
+use fparkan_path::{normalize_relative, PathPolicy};
+use fparkan_vfs::Vfs;
+use std::{collections::BTreeMap, sync::Arc};
+
+pub(super) fn read(vfs: &dyn Vfs, path: &str) -> Result<Arc<[u8]>, String> {
+ let path = normalize_relative(
+ path.replace("\\\\", "\\").as_bytes(),
+ PathPolicy::StrictLegacy,
+ )
+ .map_err(|error| error.to_string())?;
+ vfs.read(&path).map_err(|error| error.to_string())
+}
+
+pub(super) fn object<'a>(text: &'a str, name: &str) -> Option<BTreeMap<String, &'a str>> {
+ let mut lines = text
+ .lines()
+ .map(|line| line.split('#').next().unwrap_or_default().trim());
+ for line in lines.by_ref() {
+ let mut words = line.split_whitespace();
+ if words
+ .next()
+ .is_some_and(|word| word.eq_ignore_ascii_case("object"))
+ && words
+ .next()
+ .is_some_and(|word| word.eq_ignore_ascii_case(name))
+ {
+ return Some(
+ lines
+ .take_while(|line| !line.eq_ignore_ascii_case("end"))
+ .filter_map(|line| line.split_once('='))
+ .map(|(key, value)| (key.trim().to_ascii_uppercase(), value.trim()))
+ .collect(),
+ );
+ }
+ }
+ None
+}
+
+pub(super) fn field<'a>(fields: &BTreeMap<String, &'a str>, key: &str) -> Result<&'a str, String> {
+ let raw = fields.get(key).ok_or_else(|| format!("missing {key}"))?;
+ if let Some(quoted) = raw.strip_prefix('"') {
+ return quoted
+ .split_once('"')
+ .map(|(value, _)| value)
+ .ok_or_else(|| format!("invalid quoted value for {key}"));
+ }
+ Ok(raw)
+}
+
+pub(super) fn number(fields: &BTreeMap<String, &str>, key: &str) -> Result<u32, String> {
+ field(fields, key)?
+ .parse()
+ .map_err(|_| format!("invalid number for {key}"))
+}
diff --git a/crates/fparkan-font/Cargo.toml b/crates/fparkan-font/Cargo.toml
index 3053a3e3..48147fd2 100644
--- a/crates/fparkan-font/Cargo.toml
+++ b/crates/fparkan-font/Cargo.toml
@@ -6,6 +6,7 @@ license.workspace = true
repository.workspace = true
[dependencies]
+encoding_rs = "0.8"
fparkan-texm = { path = "../fparkan-texm" }
[dev-dependencies]
diff --git a/crates/fparkan-font/src/bitmap.rs b/crates/fparkan-font/src/bitmap.rs
new file mode 100644
index 00000000..7f628b71
--- /dev/null
+++ b/crates/fparkan-font/src/bitmap.rs
@@ -0,0 +1,162 @@
+use crate::TfntDocument;
+use encoding_rs::WINDOWS_1251;
+use fparkan_texm::{decode_mip_rgba8, RgbaImage};
+
+/// The original bitmap and metrics for the native variable-width text path.
+pub struct BitmapFont {
+ atlas: RgbaImage,
+ glyphs: [Glyph; 256],
+ glyph_height: usize,
+ line_height: usize,
+ spacing: usize,
+}
+
+#[derive(Clone, Copy, Default)]
+struct Glyph {
+ left: usize,
+ top: usize,
+ source_width: usize,
+ source_height: usize,
+ width: usize,
+}
+
+impl BitmapFont {
+ /// Prepares source rectangles from the Tfnt UV pairs and common height.
+ pub fn prepare(font: &TfntDocument) -> Result<Self, String> {
+ let atlas = decode_mip_rgba8(&font.texm, 0).map_err(|error| error.to_string())?;
+ let glyph_height = usize::try_from(font.header.vertical_extent)
+ .ok()
+ .filter(|&height| height < atlas.height as usize)
+ .ok_or("invalid Tfnt height")?
+ + 1;
+ let spacing = usize::try_from(font.header.character_spacing)
+ .ok()
+ .filter(|&spacing| spacing < atlas.width as usize)
+ .ok_or("invalid Tfnt spacing")?;
+ let v_span = f32::from_bits(font.header.word_0c_bits);
+ let mut glyphs = [Glyph::default(); 256];
+ for (glyph, record) in glyphs.iter_mut().zip(font.glyphs) {
+ let top_v = f32::from_bits(record.word2);
+ let left = texel(f32::from_bits(record.word0), atlas.width)?;
+ let right = texel(f32::from_bits(record.word1), atlas.width)?;
+ let top = texel(top_v, atlas.height)?;
+ let bottom = texel(top_v + v_span, atlas.height)?;
+ let width = usize::try_from(record.advance)
+ .ok()
+ .filter(|&advance| advance < atlas.width as usize)
+ .ok_or("invalid Tfnt glyph advance")?
+ + 1;
+ *glyph = Glyph {
+ left,
+ top,
+ source_width: right.checked_sub(left).ok_or("reversed Tfnt U interval")?,
+ source_height: bottom.checked_sub(top).ok_or("reversed Tfnt V interval")?,
+ width,
+ };
+ }
+ Ok(Self {
+ atlas,
+ glyphs,
+ glyph_height,
+ line_height: glyph_height + 1,
+ spacing,
+ })
+ }
+
+ /// Draw a CP1251 caption using the atlas, preserving explicit line breaks.
+ /// Returns the occupied height and a fixed-size RGBA image.
+ pub fn caption(&self, text: &str, width: u16, height: u16) -> Result<(u32, Vec<u8>), String> {
+ const PADDING: usize = 12;
+ let (width, height) = (usize::from(width), usize::from(height));
+ if width <= 2 * PADDING || height < 2 * PADDING + self.glyph_height {
+ return Err("caption image is too small".into());
+ }
+ let (bytes, _, unmappable) = WINDOWS_1251.encode(text);
+ if unmappable {
+ return Err("mission caption contains characters outside CP1251".into());
+ }
+ let limit = width - PADDING;
+ let bottom = height - PADDING;
+ let bytes_len = width
+ .checked_mul(height)
+ .and_then(|area| area.checked_mul(4))
+ .filter(|&len| len <= isize::MAX as usize)
+ .ok_or("caption image is too large")?;
+ let mut pixels = vec![0; bytes_len];
+ for pixel in pixels.chunks_exact_mut(4) {
+ pixel[3] = 192;
+ }
+ let mut y = PADDING;
+ let mut occupied = PADDING + self.glyph_height;
+ 'paragraphs: for paragraph in bytes.split(|&byte| byte == b'\n') {
+ let mut x = PADDING;
+ for word in paragraph
+ .split(u8::is_ascii_whitespace)
+ .filter(|word| !word.is_empty())
+ {
+ let advance = word.iter().map(|&byte| self.advance(byte)).sum::<usize>();
+ if x != PADDING {
+ if x + self.advance(b' ') + advance > limit {
+ x = PADDING;
+ y += self.line_height;
+ } else {
+ x += self.advance(b' ');
+ }
+ }
+ for &byte in word {
+ let glyph = self.glyphs[usize::from(byte)];
+ if x + glyph.width > limit && x != PADDING {
+ x = PADDING;
+ y += self.line_height;
+ }
+ if y + self.glyph_height > bottom {
+ break 'paragraphs;
+ }
+ self.draw_glyph(glyph, &mut pixels, width, [x, y], limit - x);
+ x = (x + self.advance(byte)).min(limit);
+ occupied = y + self.glyph_height;
+ }
+ }
+ y += self.line_height;
+ }
+ Ok(((occupied + PADDING) as u32, pixels))
+ }
+
+ fn advance(&self, byte: u8) -> usize {
+ self.glyphs[usize::from(byte)].width - 1 + self.spacing
+ }
+
+ fn draw_glyph(
+ &self,
+ glyph: Glyph,
+ pixels: &mut [u8],
+ stride: usize,
+ [x, y]: [usize; 2],
+ available: usize,
+ ) {
+ if glyph.source_width == 0 || glyph.source_height == 0 {
+ return;
+ }
+ let atlas_width = self.atlas.width as usize;
+ for row in 0..self.glyph_height {
+ let source_y = glyph.top + row * glyph.source_height / self.glyph_height;
+ for col in 0..glyph.width.min(available) {
+ let source_x = glyph.left + col * glyph.source_width / glyph.width;
+ let source = (source_y * atlas_width + source_x) * 4;
+ let dest = ((y + row) * stride + x + col) * 4;
+ let rgb = &self.atlas.rgba8[source..source + 3];
+ for (output, &component) in pixels[dest..dest + 3].iter_mut().zip(rgb) {
+ *output = (*output).max(component);
+ }
+ pixels[dest + 3] = pixels[dest + 3].max(*rgb.iter().max().unwrap());
+ }
+ }
+ }
+}
+
+fn texel(coordinate: f32, extent: u32) -> Result<usize, String> {
+ if !(0.0..=1.0).contains(&coordinate) {
+ return Err("Tfnt coordinate is outside the texture atlas".into());
+ }
+ Ok((coordinate * extent as f32).round() as usize)
+}
diff --git a/crates/fparkan-font/src/lib.rs b/crates/fparkan-font/src/lib.rs
index 770ebb0d..3fdcb554 100644
--- a/crates/fparkan-font/src/lib.rs
+++ b/crates/fparkan-font/src/lib.rs
@@ -4,31 +4,34 @@
use fparkan_texm::{TexmDocument, TexmError};
use std::sync::Arc;
+mod bitmap;
+pub use bitmap::BitmapFont;
+
const PREFIX_LEN: usize = 0x14;
const GLYPH_TABLE_END: usize = 0x1014;
const GLYPH_COUNT: usize = 256;
-/// Confirmed Tfnt metrics and the preserved opaque word at offset `0x0c`.
+/// Tfnt metrics for text measurement and placement in the atlas.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct TfntHeader {
/// Lower bound used by the native fixed-width drawing path.
pub fixed_width_floor: i32,
/// Vertical extent used by native clipping and drawing.
pub vertical_extent: i32,
- /// Raw bits copied from offset `0x0c`; its semantic name is unknown.
+ /// Raw bits of the vertical UV span shared by all glyphs.
pub word_0c_bits: u32,
/// Per-input-byte spacing used by native text measurement.
pub character_spacing: i32,
}
-/// One 16-byte glyph record; the first three words remain opaque.
+/// One 16-byte glyph record.
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct TfntGlyph {
- /// First opaque DWORD.
+ /// Raw bits of the left U coordinate.
pub word0: u32,
- /// Second opaque DWORD.
+ /// Raw bits of the right U coordinate.
pub word1: u32,
- /// Third opaque DWORD.
+ /// Raw bits of the top V coordinate.
pub word2: u32,
/// Signed advance at record offset `0x0c`.
pub advance: i32,
diff --git a/docs/appendices/ui-shell.md b/docs/appendices/ui-shell.md
index 9c32c891..7f5fa1b4 100644
--- a/docs/appendices/ui-shell.md
+++ b/docs/appendices/ui-shell.md
@@ -77,7 +77,7 @@ quirk для `INTERF8.TEX`. В полной GOG-сборке меню отдел
реального font-объекта, но не конкретной NRes-записи при `1280x1024`, её
отрисовку или паритет шрифтов.
-## Фиксированный reader Tfnt
+## Шрифт Tfnt
В подтверждённом пути `World3D.dll` (SHA-256
`17e4a3089b2583a8cf2356c9db0390b1aba138356a09130d79b4e7e4791da61e`)
@@ -98,19 +98,18 @@ Loader font-объекта `FUN_1000fb30` (RVA `0x0fb30`) при флаге `0x4
| `0x00..0x03` | Сигнатура `Tfnt`; reader проверяет её на границе файлового API. В наблюдавшемся native loader проверки сигнатуры не было. |
| `0x04..0x07` | `i32`, нижняя граница ширины в native fixed-width path. |
| `0x08..0x0b` | `i32`, вертикальный размер для native clipping/drawing. |
-| `0x0c..0x0f` | Сырые биты `u32`, скопированные в font object и участвующие в float-сложении при drawing; имя и смысл поля неизвестны. |
+| `0x0c..0x0f` | Вещественный вертикальный размер знака в координатах текстуры. |
| `0x10..0x13` | `i32`, прибавляемый один раз на входной байт при native text measurement. |
-| `0x14..0x1013` | 256 записей по 16 байт: три сырых DWORD и signed `i32` advance по смещению `+0x0c`. |
+| `0x14..0x1013` | 256 записей по 16 байт: левый U, правый U, верхний V и signed `i32` advance по смещению `+0x0c`. |
| `0x1014..конец` | Обычный Texm-документ, передаваемый общему `fparkan-texm::decode_texm`. |
-Первые три слова glyph record имеют разные native consumers, но их общая
-семантика не восстановлена: одно слово загружается как float, другое попадает
-в сформированные vertex data, а третье не прояснилось в исследованных ветвях.
-Поэтому reader сохраняет их как `word0..word2`, а поле заголовка по смещению
-`0x0c` — как неинтерпретированные float-биты. Он не выбирает размер текстуры по разрешению
-дисплея и не задаёт диапазон размеров: в проверенных ресурсах встречаются
-`128×128` и `256×256`, а форматы, mip-цепочку и палитру проверяет общий Texm
-reader.
+Функция рисования `Ngi32.dll` по RVA `0x10e40` строит прямоугольник каждого
+знака по этим координатам и общей высоте текстуры. На экране его ширина
+равна `advance + 1`, а положение следующего знака сдвигается на
+`advance + character_spacing`. Вызов измерения по RVA `0x10de0` для
+`gf_800.tft` дал 8 пикселей для `A` и кириллической `П`, вместе 16.
+В исходном декодере биты остаются сырыми, а при подготовке шрифта
+интерпретируются как координаты. Форматы, размеры и палитру проверяет Texm reader.
```rust
let font = decode_tfnt(Arc::<[u8]>::from(raw_font_payload))?;
@@ -129,6 +128,12 @@ Indexed8, одну mip-ступень и выборочные поля `gf_640.t
briefing/messages и script strings могут требовать ANSI/CP1251 decoding.
Unicode-представление хранит raw bytes для roundtrip и diagnostics.
+Текущая подсказка берёт шрифт из `getIGame()+0x10` в `iron3d.dll` по
+RVA `0x802a0`. В запущенном оригинале при 800×600 размеры и запись знака
+`A` совпали с `gf_800.tft`. FParkan загружает этот профиль через
+`GAME_FONT` из `ui/game_resources.cfg` и адресует знаки байтами CP1251.
+Выбор профиля для других размеров и оформление диалога исхода открыты.
+
`gamefont.rlb` и `sprites.lib` побайтно совпадают в Частях 1 и 2. Во второй
части добавлен `ui_factory.lib` (NRes с шестью Texm) и расширен
`ui/minimap.lib`; при этом пересобранные `iron3d.dll`/`services.dll` требуют
@@ -160,9 +165,8 @@ design resolution. Отдельно хранятся legacy-layout coordinates,
viewport, scale/letterbox policy, mouse-to-layout transform, clipping и
z-order. Cursor, sprite и hit-test обязаны применять одно преобразование.
-Font contract включает glyph image, bearing/offset, line height и fallback
-glyph. `fparkan-font` читает фиксированную таблицу Tfnt и отдаёт signed advance
-и embedded Texm; он не выполняет text measurement/layout или glyph drawing.
+`fparkan-font` отдаёт метрики Tfnt и текстуру. Для текущих сообщений он
+собирает растровый текст из атласа, используя ширины знаков для переноса строк.
`gamefont.rlb` по-прежнему читается общим RsLi reader, но его native consumer не
установлен.