feat(chat): retail text style — two-plane glyph outlines, authored SpewBox/chat styles

Campaign CH round 4, user-gate items 1+2. Root cause: retail ships a
second (background) glyph atlas per font, dilated 2px on every side,
plus two border-pixel scalars (Font.NumHorizontalBorderPixels/
NumVerticalBorderPixels) that acdream's font reader never read — so
even the pre-existing outline parameter drew almost nothing once
enabled. Landed together (either half alone is a no-op or a
regression):

- UiDatFont carries BorderX/BorderY from the DAT font resource.
- UiRenderContext.DrawStringDat inflates the background blit's source
  and destination rect by that margin and restructures into retail's
  exact two-pass whole-string outline-then-fill model
  (UIElement_Text::DrawSelf), plus the 8-neighbour +-1px fallback for
  fonts with no background atlas. Corrects the stale "property 0xd"
  comment to the real ids, 0x21 (Outline) / 0x22 (OutlineColor).
- LayoutDesc property 0x21/0x22 import (ElementInfo.Outline/
  OutlineColor, LayoutImporter.ReadState, ElementReader.Merge/
  ApplyCanonicalLegacyProjection, DatWidgetFactory.BuildText) so every
  authored-outline element across the DAT set is correct at once.
- SpewBox: RetailFontId corrected from a round-3 heuristic
  (0x40000025) to the actually-authored 0x40000001 (18px bold serif),
  Outline=true set on the controller's UiText. Fill colour stays the
  user-gate-round-1-pinned yellow — font atlases are alpha-only
  (PFID_A8), so there is no baked shading that could explain the
  screenshot's gold as anything other than the outline itself.
- Chat transcript: default fill now seeds from its authored
  ARGB(255,204,204,204) instead of an unrelated color-table slot
  (ChatTranscriptRenderer.BuildLines takes the transcript's own
  DefaultColor as a parameter); the 34-entry LogTextType table is
  untouched, and every existing CH1 conformance test stays green
  unmodified.

Regenerated the committed chat_2100006f.json fixture from the real
installed DAT, confirming end to end (not by missing-field default)
that the transcript carries no outline.

Tests: font-reader border fields + inflation math pinned against the
real DAT font, two-pass draw ordering/tint/inflation via a new
TextRenderer.DebugSpriteSegmentVerts test seam, property 0x21/0x22
import at both the ElementReader.Merge and StateDesc-property layers,
SpewBox font/outline, and the chat default-shade seed with the color
table proven untouched.

Full Release suite: 12,610 passed / 4 skipped / 0 failed
(AcDream.slnx, complete solution).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-10 19:28:34 +02:00
parent 5b54387b8e
commit bcc34ee301
22 changed files with 1995 additions and 105 deletions

View file

@ -272,4 +272,82 @@ public class ElementReaderTests
var merged = ElementReader.Merge(base_, derived);
Assert.Null(merged.FontColor);
}
// ── Outline / OutlineColor — property 0x21/0x22 (Campaign CH round 4) ──────
/// <summary>
/// A derived element that authors 0x21=true wins over an un-outlined base —
/// same "derived wins" convention as FontDid. This is the SpewBox line
/// template's own shape: its base style (0x10000377) authors no outline; the
/// line template's own state does.
/// </summary>
[Fact]
public void Merge_DerivedOutlineTrue_OverridesBaseFalse()
{
var base_ = new ElementInfo { Outline = false };
var derived = new ElementInfo { Outline = true };
var merged = ElementReader.Merge(base_, derived);
Assert.True(merged.Outline);
}
/// <summary>
/// A derived element that does NOT author 0x21 (stays at the false default)
/// inherits an outlined base rather than clobbering it — the same "false/zero
/// derived never overrides a set base" rule HJustify/FontDid already use.
/// </summary>
[Fact]
public void Merge_DerivedOutlineFalse_InheritsOutlinedBase()
{
var base_ = new ElementInfo { Outline = true };
var derived = new ElementInfo { Outline = false };
var merged = ElementReader.Merge(base_, derived);
Assert.True(merged.Outline);
}
/// <summary>
/// Neither base nor derived authors 0x21 — the chat transcript's own shape
/// (style 0x10000372 authors no outline anywhere in its chain).
/// </summary>
[Fact]
public void Merge_NeitherOutlines_MergedStaysFalse()
{
var base_ = new ElementInfo { Outline = false };
var derived = new ElementInfo { Outline = false };
var merged = ElementReader.Merge(base_, derived);
Assert.False(merged.Outline);
}
/// <summary>
/// OutlineColor follows the exact same "non-null derived wins" rule as
/// FontColor — property 0x22 is authored on only 9 elements in the whole DAT
/// set, so most outlined elements inherit null here and fall back to the
/// widget's own black default.
/// </summary>
[Fact]
public void Merge_DerivedOutlineColor_OverridesBaseNull()
{
var base_ = new ElementInfo { OutlineColor = null };
var derived = new ElementInfo { OutlineColor = new Vector4(0f, 0f, 0.4f, 1f) };
var merged = ElementReader.Merge(base_, derived);
Assert.Equal(new Vector4(0f, 0f, 0.4f, 1f), merged.OutlineColor);
}
[Fact]
public void Merge_DerivedOutlineColorNull_InheritsBaseColor()
{
var authored = new Vector4(17f / 255f, 15f / 255f, 7f / 255f, 1f);
var base_ = new ElementInfo { OutlineColor = authored };
var derived = new ElementInfo { OutlineColor = null };
var merged = ElementReader.Merge(base_, derived);
Assert.Equal(authored, merged.OutlineColor);
}
[Fact]
public void Merge_BothOutlineColorNull_MergedIsNull()
{
var base_ = new ElementInfo { OutlineColor = null };
var derived = new ElementInfo { OutlineColor = null };
var merged = ElementReader.Merge(base_, derived);
Assert.Null(merged.OutlineColor);
}
}