|
|
|
@ -169,7 +169,7 @@ const mappings: [filter: (status: GameStatus) => boolean, selector: string, hit: |
|
|
|
|
[dead(), '#characterFaceImage', removeElement] |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
export async function renderStatus(svgTemplate: string, status: GameStatusWithPortrait): Promise<Buffer> { |
|
|
|
|
export async function renderStatus(svgTemplate: string, status: GameStatusWithPortrait, fontDir: string): Promise<Buffer> { |
|
|
|
|
const dom = new JSDOM(svgTemplate, { |
|
|
|
|
contentType: 'image/svg+xml', |
|
|
|
|
pretendToBeVisual: false, |
|
|
|
@ -183,7 +183,12 @@ export async function renderStatus(svgTemplate: string, status: GameStatusWithPo |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
const resvg = new Resvg(dom.window.document.documentElement.outerHTML, {}); |
|
|
|
|
const resvg = new Resvg(dom.window.document.documentElement.outerHTML, { |
|
|
|
|
font: { |
|
|
|
|
fontDirs: [fontDir], |
|
|
|
|
loadSystemFonts: false, |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
resvg.resolveImage('https://invalid.invalid/face.png', status.portrait); |
|
|
|
|
return resvg.render().asPng(); |
|
|
|
|
} |
|
|
|
|