Implement native text face selection

This commit is contained in:
gamer147
2026-07-28 14:16:24 -04:00
parent a991d5699c
commit f885ac4189
12 changed files with 270 additions and 33 deletions

View File

@@ -63,11 +63,61 @@ name = "gfx_default_object_slot"
type = "int"
note = "op 0x80 selected slot; op 0x1d9 substitutes it when its explicit object-slot operand is zero"
[[field]]
offset = 0x14e0c
name = "text_primary_font_height"
type = "int"
note = "primary LOGFONTA.lfHeight at text-manager+0x4cc; stored as a negative pixel height and updated by op 0x75"
[[field]]
offset = 0x14e10
name = "text_primary_font_width"
type = "int"
note = "primary LOGFONTA.lfWidth at text-manager+0x4d0; op 0x75 stores negative half the requested font size"
[[field]]
offset = 0x14e1c
name = "text_primary_font_weight"
type = "int"
note = "primary LOGFONTA.lfWeight at text-manager+0x4dc; op 0x2bd writes 700 for enabled or zero for disabled"
[[field]]
offset = 0x14e84
name = "text_antialias_enabled"
type = "int"
note = "text-manager+0x544; message:UseAntiFont selects GGO_GRAY4_BITMAP when nonzero and GGO_BITMAP when zero"
[[field]]
offset = 0x14e88
name = "text_antialias_version"
type = "int"
note = "text-manager+0x548 loaded from set:AntiFontVersion; Himegari SYS4INI supplies version 3"
[[field]]
offset = 0x14e8c
name = "text_primary_color_bgr"
type = "uint"
note = "text-manager+0x54c internal GDI BGR/COLORREF primary glyph color; op 0x76 converts script RGB into it"
[[field]]
offset = 0x14e90
name = "text_effect_color_bgr"
type = "uint"
note = "text-manager+0x550 internal GDI BGR/COLORREF effect glyph color; op 0x77 converts script RGB into it"
[[field]]
offset = 0x14e98
name = "text_render_mode"
type = "int"
note = "text-manager+0x558; op 0x78 selects primary-only, displaced shadow, reduced-coverage repeat, or sampled ellipse outline"
[[field]]
offset = 0x14ea0
name = "text_line_spacing"
type = "int"
note = "extra pixel leading between text lines; defaults to 6, op 0x8b writes it"
[[field]]
offset = 0x14ea4
name = "text_effect_offset_x"
type = "int"
note = "text-manager+0x564; op 0x1a4 horizontal displacement for mode 1 or ellipse radius for mode 3"
[[field]]
offset = 0x14ea8
name = "text_effect_offset_y"
type = "int"
note = "text-manager+0x568; op 0x1a4 vertical displacement for mode 1 or ellipse radius for mode 3"
[[field]]
offset = 0x14f45
name = "script_frame_index"
type = "int"
@@ -448,6 +498,11 @@ name = "save_frame_boundary_index"
type = "int"
note = "highest script-frame index included by numbered-save layouts 2/3; -1 falls back to cur_ctx_index; op 0x1ad marks current frame and op 0x2 clears after unwinding below it"
[[field]]
offset = 0x99290
name = "gfx_draw_mode"
type = "int"
note = "loaded from set:DrawMode during runtime initialization; Himegari uses mode 1, selecting the cached GetGlyphOutline text path"
[[field]]
offset = 0x9b24c
name = "dispatch_table"
type = "void*"

View File

@@ -1116,7 +1116,7 @@ noop_headless = false
source = "investigation"
confidence = "high"
depends_on = []
evidence = "Ghidra /v2: op_0x75_handler@0x41ea10 calls text_set_primary_font_size@0x415bd0 on ctx+0x14940. The worker writes the negated pixel height to both primary LOGFONT states, derives width, and rebuilds font resources. HISTORY.BIN selects 22 pixels while active and restores 24 on exit."
evidence = "Ghidra /v2: op_0x75_set_font_size@0x41ea10 calls text_set_primary_font_size@0x415bd0 on ctx+0x14940. The worker writes the negated pixel height to both primary LOGFONT states, sets lfWidth to negative half the requested size, applies AGE's odd/32/33-pixel height adjustment, and rebuilds both GDI font resources plus glyph buffers. All shipped Himegari sizes are even and avoid the adjustment; HISTORY.BIN selects 22 pixels while active and restores 24 on exit."
[[opcode.semantics.args]]
i = 1
@@ -1175,11 +1175,12 @@ abi_source = "kelebek+decode-validated"
name = "set-text-render-mode"
category = "adv"
summary = "(mode) - select the current text raster/effect mode."
details = "Mode 0 draws only the primary glyph. Mode 1 draws one effect-colored copy displaced by the configured x/y offset, then the primary glyph. Mode 2 adds a reduced-coverage primary-color bitmap pass after the ordinary glyph and is unused by Himegari scripts. Mode 3 repeatedly draws the effect glyph around an ellipse whose radii are the configured x/y extents, then draws the primary glyph; Himegari's (1,1) profile produces its one-pixel outline."
noop_headless = false
source = "investigation"
confidence = "high"
depends_on = []
evidence = "Ghidra /v2: op_0x78_handler@0x41eb10 writes operand 1 to text-manager+0x558 and rebuilds font state. Direct draw and text_history_render_records branch on this field (including a distinct mode-3 offset path). HISTORY.BIN selects mode 3 and restores mode 3 with the normal ADV font preset."
evidence = "Ghidra /v2: op_0x78_set_text_render_mode@0x41eb10 writes operand 1 to text-manager+0x558 and rebuilds font state. Himegari's DrawMode=1 path reaches text_raster_string_cached@0x45b600: mode 1 blits effect color at (+x,+y); mode 2 repeats a quarter-coverage glyph bitmap in primary color; mode 3 samples text_compute_outline_ellipse_offset@0x459860 around 360 degrees before the primary blit. The corpus uses only mode 1 (43 sites) and mode 3 (165 sites)."
[[opcode.semantics.args]]
i = 1
@@ -3577,7 +3578,7 @@ noop_headless = false
source = "investigation"
confidence = "high"
depends_on = []
evidence = "Ghidra /v2: op_0x1a4_handler@0x41f440 writes operands 1/2 to text-manager+0x564/+0x568. Native raster/bounds paths expand or shift text by these values when an effect mode is active; mode 3 subtracts both. HISTORY.BIN uses (1,1)."
evidence = "Ghidra /v2: op_0x1a4_set_text_effect_offset@0x41f440 writes operands 1/2 to text-manager+0x564/+0x568. Mode 1 uses them as a single displaced effect-color shadow. Mode 3 treats them as ellipse radii and samples x=cos(angle)*offset_x, y=sin(angle)*offset_y around the glyph before the primary draw. The Himegari corpus pairs mode 1 with (0,0) at all 43 sites and mode 3 with (1,1) at all 164 paired sites."
[[opcode.semantics.args]]
i = 1
@@ -3597,17 +3598,18 @@ abi_source = "kelebek+decode-validated"
[opcode.semantics]
name = "set-font"
category = "unknown"
summary = ""
category = "adv"
summary = "(face) - select the primary GDI font face, derive its vertical-writing companion, and rebuild the native font/glyph state."
details = "The requested CP932 face is copied into the primary LOGFONT lfFaceName and AGE also constructs an @-prefixed vertical face. Himegari uses only the full-width Windows family names 明朝 (168 sites) and ゴシック (39 sites). This is live raster state, not a declaration/no-op."
noop_headless = false
source = "kelebek"
confidence = "med"
source = "investigation"
confidence = "high"
depends_on = []
evidence = ""
evidence = "Ghidra /v2: op_0x1a5_set_font_face@0x42bbf0 resolves operand 1 and calls text_set_primary_font_face@0x42b1d0 on ctx+0x14940. The worker copies the face to manager+0x4e8, formats @%s into the vertical LOGFONT state at +0x18e74, rebuilds CreateFontIndirectA handles/metrics/glyph buffers through text_rebuild_primary_font_resources@0x44f7f0, and maintains both names in its font-family caches. SYS4INI seeds FONT= 明朝."
[[opcode.semantics.args]]
i = 1
role = ""
role = "CP932 GDI face name"
observed_types = ["string"]
[[opcode]]
@@ -6765,7 +6767,7 @@ noop_headless = false
source = "investigation"
confidence = "high"
depends_on = []
evidence = "Ghidra /v2: op_0x2bd_handler@0x4251c0 writes enabled?700:0 to LOGFONT weight at text-manager+0x4dc and calls the font rebuild worker. It immediately follows set-font throughout the UI corpus; HISTORY.BIN selects the Mincho face with bold enabled."
evidence = "Ghidra /v2: op_0x2bd_set_font_bold@0x4251c0 writes enabled?700:0 to LOGFONT weight at text-manager+0x4dc and calls text_rebuild_primary_font_resources@0x44f7f0. It immediately follows set-font throughout the UI corpus; HISTORY.BIN selects the Mincho face with bold enabled."
[[opcode.semantics.args]]
i = 1