@@ -273,27 +273,120 @@ var textAlignSketch = function(p) {
273273 } ;
274274} ;
275275
276+
276277var textLeadingSketch = function ( p ) {
277278 var font ;
278279 p . preload = function ( ) {
279280 font = p . loadFont ( "../SourceSansPro-Regular.otf" ) ;
280281 } ;
281282 p . setup = function ( ) {
282- p . createCanvas ( 240 , 160 ) ;
283+ p . createCanvas ( 400 , 200 ) ;
284+ p . textFont ( font ) ;
285+ p . fill ( 0 ) ;
286+ p . textSize ( 12 ) ;
287+
288+ p . line ( 0 , 100 , p . width , 100 ) ;
289+ p . textAlign ( p . LEFT , p . TOP ) ;
290+ p . strokeWeight ( 0 ) ;
291+
292+ var s10 = 'LEFT/TOP@10px' ,
293+ s20 = s10 . replace ( '1' , '2' ) ,
294+ s30 = s10 . replace ( '1' , '3' ) ;
295+
296+ p . textLeading ( 10 ) ; // Set leading to 10
297+ p . text ( s10 + '\n' + s10 + '\n' + s10 , 10 , 100 ) ;
298+ p . textLeading ( 20 ) ; // Set leading to 20
299+ p . text ( s20 + '\n' + s20 + '\n' + s20 , 140 , 100 ) ;
300+ p . textLeading ( 30 ) ; // Set leading to 30
301+ p . text ( s30 + '\n' + s30 + '\n' + s30 , 270 , 100 ) ;
302+ } ;
303+ } ;
304+
305+ var textLeadingSketch2 = function ( p ) {
306+ var font ;
307+ p . preload = function ( ) {
308+ font = p . loadFont ( "../SourceSansPro-Regular.otf" ) ;
309+ } ;
310+ p . setup = function ( ) {
311+ p . createCanvas ( 400 , 200 ) ;
312+ p . textFont ( font ) ;
313+ p . fill ( 0 ) ;
314+ p . textSize ( 12 ) ;
315+
316+ p . line ( 0 , 100 , p . width , 100 ) ;
317+ p . textAlign ( p . LEFT , p . CENTER ) ;
318+ p . strokeWeight ( 0 ) ;
319+
320+ var s10 = 'LEFT/CENTER@10px' ,
321+ s20 = s10 . replace ( '1' , '2' ) ,
322+ s30 = s10 . replace ( '1' , '3' ) ;
323+
324+ p . textLeading ( 10 ) ; // Set leading to 10
325+ p . text ( s10 + '\n' + s10 + '\n' + s10 , 10 , 100 ) ;
326+ p . textLeading ( 20 ) ; // Set leading to 20
327+ p . text ( s20 + '\n' + s20 + '\n' + s20 , 140 , 100 ) ;
328+ p . textLeading ( 30 ) ; // Set leading to 30
329+ p . text ( s30 + '\n' + s30 + '\n' + s30 , 270 , 100 ) ;
330+ } ;
331+ } ;
332+
333+ var textLeadingSketch3 = function ( p ) {
334+ var font ;
335+ p . preload = function ( ) {
336+ font = p . loadFont ( "../SourceSansPro-Regular.otf" ) ;
337+ } ;
338+ p . setup = function ( ) {
339+ p . createCanvas ( 400 , 200 ) ;
283340 p . textFont ( font ) ;
284341 p . fill ( 0 ) ;
342+ p . textSize ( 12 ) ;
343+
344+ p . line ( 0 , 100 , p . width , 100 ) ;
345+ p . textAlign ( p . LEFT , p . BASELINE ) ;
285346 p . strokeWeight ( 0 ) ;
347+
348+ var s10 = 'LEFT/BASELINE@10px' ,
349+ s20 = s10 . replace ( '1' , '2' ) ,
350+ s30 = s10 . replace ( '1' , '3' ) ;
351+
352+ p . textLeading ( 10 ) ; // Set leading to 10
353+ p . text ( s10 + '\n' + s10 + '\n' + s10 , 10 , 100 ) ;
354+ p . textLeading ( 20 ) ; // Set leading to 20
355+ p . text ( s20 + '\n' + s20 + '\n' + s20 , 140 , 100 ) ;
356+ p . textLeading ( 30 ) ; // Set leading to 30
357+ p . text ( s30 + '\n' + s30 + '\n' + s30 , 270 , 100 ) ;
358+ } ;
359+ } ;
360+
361+ var textLeadingSketch4 = function ( p ) {
362+ var font ;
363+ p . preload = function ( ) {
364+ font = p . loadFont ( "../SourceSansPro-Regular.otf" ) ;
365+ } ;
366+ p . setup = function ( ) {
367+ p . createCanvas ( 400 , 200 ) ;
368+ p . textFont ( font ) ;
369+ p . fill ( 0 ) ;
286370 p . textSize ( 12 ) ;
287- //leadig
371+
372+ p . line ( 0 , 100 , p . width , 100 ) ;
373+ p . textAlign ( p . LEFT , p . BOTTOM ) ;
374+ p . strokeWeight ( 0 ) ;
375+
376+ var s10 = 'LEFT/BOTTOM@10px' ,
377+ s20 = s10 . replace ( '1' , '2' ) ,
378+ s30 = s10 . replace ( '1' , '3' ) ;
379+
288380 p . textLeading ( 10 ) ; // Set leading to 10
289- p . text ( "Leading10px\nLeading10px\nLeading10px" , 10 , 30 ) ;
381+ p . text ( s10 + '\n' + s10 + '\n' + s10 , 10 , 100 ) ;
290382 p . textLeading ( 20 ) ; // Set leading to 20
291- p . text ( "Leading20px\nLeading20px\nLeading20px" , 90 , 30 ) ;
383+ p . text ( s20 + '\n' + s20 + '\n' + s20 , 140 , 100 ) ;
292384 p . textLeading ( 30 ) ; // Set leading to 30
293- p . text ( "Leading30px\nLeading30px\nLeading30px" , 170 , 30 ) ;
385+ p . text ( s30 + '\n' + s30 + '\n' + s30 , 270 , 100 ) ;
294386 } ;
295387} ;
296388
389+
297390var textSizeSketch = function ( p ) {
298391 var font ;
299392 p . preload = function ( ) {
@@ -310,8 +403,6 @@ var textSizeSketch = function(p) {
310403 p . text ( "Font Size 14" , 10 , 60 ) ;
311404 p . textSize ( 16 ) ;
312405 p . text ( "Font Size 16" , 10 , 90 ) ;
313- p . textSize ( 32 ) ;
314- p . text ( "Font Size 32" , 10 , 130 ) ;
315406 } ;
316407} ;
317408
@@ -603,6 +694,9 @@ new p5(textLineSketch, 'textLineSketch');
603694new p5 ( textWrapSketch , 'textWrapSketch' ) ;
604695new p5 ( textAlignSketch , 'textAlignSketch' ) ;
605696new p5 ( textLeadingSketch , 'textLeadingSketch' ) ;
697+ new p5 ( textLeadingSketch2 , 'textLeadingSketch2' ) ;
698+ new p5 ( textLeadingSketch3 , 'textLeadingSketch3' ) ;
699+ new p5 ( textLeadingSketch4 , 'textLeadingSketch4' ) ;
606700new p5 ( textSizeSketch , 'textSizeSketch' ) ;
607701new p5 ( textBoundsSketch , 'textBoundsSketch' ) ;
608702new p5 ( textStyleSketch , 'textStyleSketch' ) ;
0 commit comments