Skip to content

Commit 96c616a

Browse files
committed
Fix backgrounds not getting cleared, image sizes, alignment
1 parent b43b652 commit 96c616a

File tree

39 files changed

+21
-8
lines changed

39 files changed

+21
-8
lines changed

test/unit/visual/cases/typography.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ visualSuite("Typography", function () {
6363
document.head.appendChild(link);
6464
try {
6565
await document.fonts.ready;
66+
await new Promise((res) => setTimeout(res, 500))
6667

6768
p5.createCanvas(100, 100);
6869
p5.textFont(`italic bold 32px "EB Garamond"`);
@@ -152,16 +153,18 @@ visualSuite("Typography", function () {
152153
{ alignX: p5.RIGHT, alignY: p5.BOTTOM },
153154
];
154155

155-
p5.createCanvas(300, 80);
156+
p5.createCanvas(300, 300);
156157
p5.textSize(60);
157158
alignments.forEach((alignment) => {
158159
p5.background(255);
159160
p5.textAlign(alignment.alignX, alignment.alignY);
160-
p5.text("Single Line", 0, 0);
161-
const bb = p5.textBounds("Single Line", 0, 0);
161+
p5.text("Single Line", p5.width / 2, p5.height / 2);
162+
const bb = p5.textBounds("Single Line", p5.width / 2, p5.height / 2);
163+
p5.push();
162164
p5.noFill();
163165
p5.stroke("red");
164166
p5.rect(bb.x, bb.y, bb.w, bb.h);
167+
p5.pop();
165168
screenshot();
166169
})
167170
});
@@ -179,16 +182,18 @@ visualSuite("Typography", function () {
179182
{ alignX: p5.RIGHT, alignY: p5.BOTTOM },
180183
];
181184

182-
p5.createCanvas(300, 80);
183-
p5.textSize(60);
185+
p5.createCanvas(300, 300);
186+
p5.textSize(45);
184187
alignments.forEach((alignment) => {
185188
p5.background(255);
186189
p5.textAlign(alignment.alignX, alignment.alignY);
187-
p5.text("Single Line", 0, 0);
188-
const bb = p5.textBounds("Single Line", 0, 0);
190+
p5.text("Single Line", p5.width / 2, p5.height / 2);
191+
const bb = p5.textBounds("Single Line", p5.width / 2, p5.height / 2);
192+
p5.push();
189193
p5.noFill();
190194
p5.stroke("red");
191195
p5.rect(bb.x, bb.y, bb.w, bb.h);
196+
p5.pop();
192197
screenshot();
193198
});
194199
});
@@ -218,6 +223,7 @@ visualSuite("Typography", function () {
218223

219224
alignments.forEach((alignment, i) => {
220225
p5.background(255);
226+
p5.push();
221227
p5.textAlign(alignment.alignX, alignment.alignY);
222228

223229
p5.noFill();
@@ -242,6 +248,7 @@ visualSuite("Typography", function () {
242248
p5.noFill();
243249
p5.stroke("red");
244250
p5.rect(bb.x, bb.y, bb.w, bb.h);
251+
p5.pop();
245252

246253
screenshot();
247254
});
@@ -273,6 +280,8 @@ visualSuite("Typography", function () {
273280
const boxHeight = 60;
274281

275282
alignments.forEach((alignment, i) => {
283+
p5.background(255);
284+
p5.push();
276285
p5.textAlign(alignment.alignX, alignment.alignY);
277286

278287
p5.noFill();
@@ -297,6 +306,7 @@ visualSuite("Typography", function () {
297306
p5.noFill();
298307
p5.stroke("red");
299308
p5.rect(bb.x, bb.y, bb.w, bb.h);
309+
p5.pop();
300310

301311
screenshot();
302312
});
@@ -327,6 +337,8 @@ visualSuite("Typography", function () {
327337
const boxHeight = 60;
328338

329339
alignments.forEach((alignment, i) => {
340+
p5.background(255);
341+
p5.push();
330342
p5.textAlign(alignment.alignX, alignment.alignY);
331343

332344
p5.noFill();
@@ -345,6 +357,7 @@ visualSuite("Typography", function () {
345357
p5.noFill();
346358
p5.stroke("red");
347359
p5.rect(bb.x, bb.y, bb.w, bb.h);
360+
p5.pop();
348361

349362
screenshot();
350363
});
-677 Bytes
Loading
-2.48 KB
Loading
-4.04 KB
Loading
-6.01 KB
Loading
-6.9 KB
Loading
-7.79 KB
Loading
-8.68 KB
Loading
-8.85 KB
Loading
-8.83 KB
Loading

0 commit comments

Comments
 (0)