fix(simulation): render screenshot symbol glyphs (#37691)

This commit is contained in:
Kit Langton 2026-07-18 21:36:21 -04:00 committed by GitHub
commit 584fdefe6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 62 additions and 7 deletions

View file

@ -29,6 +29,38 @@ test("renders captured frames with bundled fonts", () => {
expect(image.data.subarray(1, 4).toString()).toBe("PNG")
})
test("renders OpenCode symbols instead of missing-glyph boxes", async () => {
const pixels = async (text: string) => {
const image = SimulationPng.screenshotFrame({
cols: 1,
rows: 1,
cursor: [0, 0],
lines: [
{
spans: [
{
text,
width: 1,
fg: RGBA.fromInts(255, 255, 255),
bg: RGBA.fromInts(0, 0, 0),
attributes: 0,
},
],
},
],
})
const canvas = createCanvas(image.width, image.height)
const context = canvas.getContext("2d")
context.drawImage(await loadImage(image.data), 0, 0)
return [...context.getImageData(0, 0, image.width, image.height).data]
}
const missingGlyph = await pixels("\u{10ffff}")
for (const symbol of ["△", "✱", "⇆", "⠹"]) {
expect(await pixels(symbol)).not.toEqual(missingGlyph)
}
})
test("fills adjacent block elements without glyph gaps", async () => {
const image = SimulationPng.screenshotFrame({
cols: 2,
@ -97,7 +129,5 @@ test("draws heavy vertical box elements on cell boundaries", async () => {
expect([...context.getImageData(4, 0, 2, 30).data]).toEqual(
Array.from({ length: 60 }, () => [255, 255, 255, 255]).flat(),
)
expect([...context.getImageData(4, 30, 2, 10).data]).toEqual(
Array.from({ length: 20 }, () => [0, 0, 0, 255]).flat(),
)
expect([...context.getImageData(4, 30, 2, 10).data]).toEqual(Array.from({ length: 20 }, () => [0, 0, 0, 255]).flat())
})