Implement native text face selection
This commit is contained in:
@@ -9,6 +9,32 @@ using Xunit;
|
||||
|
||||
public class AdvTextOpsTests
|
||||
{
|
||||
[Fact]
|
||||
public void SetFontFaceFlowsIntoLiveAndRetainedTextStyles()
|
||||
{
|
||||
var table = OpcodeTableJson.Load(Paths.OpcodesJson);
|
||||
static Operand I(long value) => new(0, value);
|
||||
static Operand S(int index) => new(2, index);
|
||||
var script = ScriptAssembler.Assemble(table, "ADV_FONT_FACE",
|
||||
new List<(int, Operand[])>
|
||||
{
|
||||
(0x1a5, new[] { S(0) }),
|
||||
(0x6e, new[] { I(0), S(2) }),
|
||||
(0x1a5, new[] { S(1) }),
|
||||
(0x6e, new[] { I(0), S(3) }),
|
||||
(0x2, Array.Empty<Operand>()),
|
||||
}, new[] { "MS 明朝", "MS ゴシック", "mincho", "gothic" });
|
||||
var host = new RecordingHost();
|
||||
var vm = new VirtualMachine(script, table, host);
|
||||
|
||||
vm.Run();
|
||||
|
||||
Assert.Equal(new[] { "MS 明朝", "MS ゴシック" },
|
||||
host.LiveTextRuns.Select(run => run.Run.Style.FontFace));
|
||||
Assert.Equal(new[] { "MS 明朝", "MS ゴシック" },
|
||||
vm.TextHistory.Records.Select(record => record.Style.FontFace));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TextCursorAndDrawStringReachHostWithLocalStringPointer()
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ public class HistoryPresentationOpsTests
|
||||
history.DefineLayout(1, 640, 160, 80, 430);
|
||||
history.AppendMetadata(9, 2, AdvTextStyle.Default);
|
||||
history.AppendText(0, 10, "retained dialogue", new AdvTextStyle(24, 8, false,
|
||||
0xffffff, 0x606060, 3, 1, 1, 9));
|
||||
0xffffff, 0x606060, 3, 1, 1, 9, "MS 明朝"));
|
||||
history.ResetLayout(1);
|
||||
history.AppendText(0, 11, "next group", AdvTextStyle.Default);
|
||||
history.SetRecordingEnabled(false);
|
||||
@@ -42,9 +42,9 @@ public class HistoryPresentationOpsTests
|
||||
Assert.Equal((4, 0, "retained dialogue"),
|
||||
(render.LayoutSlot, render.FirstRecordIndex, render.Text));
|
||||
Assert.Equal(new AdvTextLayoutSnapshot(4, 600, 150, 65, 150, 45, 42, 600, 150), render.Layout);
|
||||
Assert.Equal((24, 0xffffffL, 0x606060L, 8),
|
||||
Assert.Equal((24, 0xffffffL, 0x606060L, 8, "MS 明朝"),
|
||||
(render.Style.PrimaryFontSize, render.Style.TextColor, render.Style.EffectColor,
|
||||
render.Style.LineSpacing));
|
||||
render.Style.LineSpacing, render.Style.FontFace));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user