Skip to content

Commit 52c4266

Browse files
committed
Add visual tests for vertical alignment
1 parent dacb940 commit 52c4266

File tree

17 files changed

+54
-0
lines changed

17 files changed

+54
-0
lines changed

test/unit/visual/cases/typography.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,36 @@ visualSuite('Typography', function () {
145145
});
146146
});
147147

148+
visualSuite('vertical centering', function() {
149+
const fonts = {
150+
Inter: 'https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfMZhrib2Bg-4.ttf',
151+
Raleway: 'https://fonts.gstatic.com/s/raleway/v36/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvaooCPNLA3JC9c.ttf',
152+
'Inknut Antiqua': 'https://fonts.gstatic.com/s/inknutantiqua/v16/Y4GRYax7VC4ot_qNB4nYpBdaKU2_xbj5bBoIYJNf.ttf',
153+
Oswald: 'https://fonts.gstatic.com/s/oswald/v57/TK3_WkUHHAIjg75cFRf3bXL8LICs1_FvgUFoZAaRliE.ttf',
154+
};
155+
for (const mode of ['2d', 'webgl']) {
156+
for (const fontName in fonts) {
157+
visualTest(`${fontName} in ${mode} mode`, async function (p5, screenshot) {
158+
p5.createCanvas(200, 50, mode === 'webgl' ? p5.WEBGL : p5.P2D);
159+
p5.background(255);
160+
const font = await p5.loadFont(fonts[fontName]);
161+
if (mode === '2d') p5.translate(p5.width/2, p5.height/2);
162+
p5.textFont(font);
163+
164+
p5.stroke('red');
165+
p5.line(-p5.width/2, 0, p5.width/2, 0);
166+
167+
p5.noStroke();
168+
p5.fill(0);
169+
p5.textSize(20);
170+
p5.textAlign(p5.CENTER, p5.CENTER);
171+
p5.text('Vertical align', 0, 0);
172+
screenshot();
173+
});
174+
}
175+
}
176+
});
177+
148178
visualSuite('textAlign', function () {
149179
for (const mode of ['2d', 'webgl']) {
150180
visualSuite(`${mode} mode`, () => {
3.85 KB
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"numScreenshots": 1
3+
}
3.67 KB
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"numScreenshots": 1
3+
}
3.21 KB
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"numScreenshots": 1
3+
}
3 KB
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"numScreenshots": 1
3+
}
2.8 KB
Loading

0 commit comments

Comments
 (0)