@@ -106,7 +106,7 @@ var Text = new Class({
106106 }
107107
108108 // Here is where the crazy starts.
109- //
109+ //
110110 // Due to browser implementation issues, you cannot fillText BiDi text to a canvas
111111 // that is not part of the DOM. It just completely ignores the direction property.
112112
@@ -420,6 +420,18 @@ var Text = new Class({
420420 return this . style . setShadowFill ( enabled ) ;
421421 } ,
422422
423+ // Set to null to remove
424+ setWordWrapWidth : function ( width , useAdvancedWrap )
425+ {
426+ return this . style . setWordWrapWidth ( width , useAdvancedWrap ) ;
427+ } ,
428+
429+ // Set to null to remove
430+ setWordWrapCallback : function ( callback , scope )
431+ {
432+ return this . style . setWordWrapCallback ( callback , scope ) ;
433+ } ,
434+
423435 setAlign : function ( align )
424436 {
425437 return this . style . setAlign ( align ) ;
@@ -488,12 +500,14 @@ var Text = new Class({
488500 var style = this . style ;
489501 var size = style . metrics ;
490502
503+ style . syncFont ( canvas , context ) ;
504+
491505 var outputText = this . text ;
492506
493- // if (style.wordWrap )
494- // {
495- // outputText = this.runWordWrap(this.text);
496- // }
507+ if ( style . wordWrapWidth || style . wordWrapCallback )
508+ {
509+ outputText = this . runWordWrap ( this . text ) ;
510+ }
497511
498512 // Split text into lines
499513 var lines = outputText . split ( this . splitRegExp ) ;
@@ -524,6 +538,7 @@ var Text = new Class({
524538 {
525539 canvas . width = w ;
526540 canvas . height = h ;
541+ style . syncFont ( canvas , context ) ; // Resizing resets the context
527542 }
528543 else
529544 {
@@ -538,7 +553,7 @@ var Text = new Class({
538553 context . fillRect ( 0 , 0 , w , h ) ;
539554 }
540555
541- style . syncFont ( canvas , context ) ;
556+ style . syncStyle ( canvas , context ) ;
542557
543558 context . textBaseline = 'alphabetic' ;
544559
0 commit comments