start on making a text framework

This commit is contained in:
Dylan Pizzo
2025-01-06 12:26:18 -05:00
parent 1e6e336f73
commit 8e7bcc185c
2 changed files with 155 additions and 4 deletions

View File

@@ -94,7 +94,7 @@ const wrapText = (
return text.split("\n").flatMap((paragraph) => {
const lines: string[] = [];
let words = 0;
let remainingText = paragraph.trim().replace(/\s+/g, " ");
let remainingText = paragraph.trim().replace(/ +/g, " ");
let oldLine = "";
let countdown = 100;
while (remainingText.length > 0) {
@@ -131,7 +131,7 @@ const measureText = (
allowWrap: boolean | undefined
) => {
const measure = context.measureText(text);
const lineHeight = measure.emHeightAscent + measure.emHeightDescent;
const lineHeight = 1.2 * (measure.emHeightAscent + measure.emHeightDescent);
if (!allowWrap || !maxWidth) {
return {
width: measure.width,
@@ -193,7 +193,7 @@ const drawTextCentered = (
}
}
const measure = context.measureText(text);
const lineHeight = measure.emHeightAscent + measure.emHeightDescent;
const lineHeight = 1.2 * (measure.emHeightAscent + measure.emHeightDescent);
context.textAlign = "center";
context.textBaseline = "middle";
if (allowWrap && maxWidth) {
@@ -235,7 +235,7 @@ const drawStandardCard = async (
// Draw the description
drawTextCentered(
context,
"You may play an Action card from your hand.",
"You may play an Action card from your hand costing up to \u202f◯\u202f.",
w / 2,
1520,
{