@@ -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` , ( ) => {
0 commit comments