account for preview when sizing the title

This commit is contained in:
Dylan Pizzo 2025-01-08 19:19:21 -08:00
parent 055e42ecf7
commit dc49eb961f
2 changed files with 9 additions and 3 deletions

View File

@ -103,7 +103,7 @@ export const cards: DominionCard[] = [
image: "",
artist: "",
author: "Dylan",
version: "0.1",
version: "0.2",
cost: "$3",
preview: "$?",
expansionIcon,

View File

@ -290,10 +290,16 @@ const drawStandardCard = async (
context.drawImage(colorImage(getImage("card-brown"), "#ff9911"), 0, 0);
// Draw the name
context.fillStyle = colors.titleText;
context.font = "90pt DominionText";
const previewMeasure = await measureDominionText(
context,
parse(card.preview ?? "")
);
size = 78;
context.font = `${size}pt DominionTitle`;
while (
(await measureDominionText(context, parse(card.title))).width > 1050
(await measureDominionText(context, parse(card.title))).width >
1050 - previewMeasure.width * 1.5
) {
size -= 1;
context.font = `${size}pt DominionTitle`;
@ -356,7 +362,7 @@ const drawStandardCard = async (
await renderDominionText(context, parse(card.preview), 200, 210);
await renderDominionText(context, parse(card.preview), w - 200, 210);
}
// Draw the icon
// Draw the expansion icon
// Draw the author credit
context.fillStyle = "white";
context.font = "31pt DominionText";