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: "", image: "",
artist: "", artist: "",
author: "Dylan", author: "Dylan",
version: "0.1", version: "0.2",
cost: "$3", cost: "$3",
preview: "$?", preview: "$?",
expansionIcon, expansionIcon,

View File

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