@ -797,14 +797,15 @@ class Label {
let words = blocks [ j ] . text . split ( " " ) ;
let words = blocks [ j ] . text . split ( " " ) ;
let atStart = true
let atStart = true
let text = "" ;
let text = "" ;
let measure ;
let measure = { width : 0 } ;
let lastMeasure ;
let lastMeasure ;
let w = 0 ;
let w = 0 ;
while ( w < words . length ) {
while ( w < words . length ) {
let pre = atStart ? "" : " " ;
let pre = atStart ? "" : " " ;
lastMeasure = measure ;
lastMeasure = measure ;
measure = ctx . measureText ( text + pre + words [ w ] ) ;
measure = ctx . measureText ( text + pre + words [ w ] ) ;
if ( lineWidth + measure . width > this . fontOptions . maxWdt ) {
if ( ( lineWidth + measure . width > this . fontOptions . maxWdt ) &&
( lastMeasure . width != 0 ) ) {
lineHeight = ( values . height > lineHeight ) ? values . height : lineHeight ;
lineHeight = ( values . height > lineHeight ) ? values . height : lineHeight ;
lines . add ( k , text , values . font , values . color , lastMeasure . width , values . height , values . vadjust , blocks [ j ] . mod , values . strokeWidth , values . strokeColor ) ;
lines . add ( k , text , values . font , values . color , lastMeasure . width , values . height , values . vadjust , blocks [ j ] . mod , values . strokeWidth , values . strokeColor ) ;
lines . accumulate ( k , lastMeasure . width , lineHeight ) ;
lines . accumulate ( k , lastMeasure . width , lineHeight ) ;
@ -850,14 +851,14 @@ class Label {
if ( this . fontOptions . maxWdt > 0 ) {
if ( this . fontOptions . maxWdt > 0 ) {
let words = nlLines [ i ] . split ( " " ) ;
let words = nlLines [ i ] . split ( " " ) ;
let text = "" ;
let text = "" ;
let measure ;
let measure = { width : 0 } ;
let lastMeasure ;
let lastMeasure ;
let w = 0 ;
let w = 0 ;
while ( w < words . length ) {
while ( w < words . length ) {
let pre = ( text === "" ) ? "" : " " ;
let pre = ( text === "" ) ? "" : " " ;
lastMeasure = measure ;
lastMeasure = measure ;
measure = ctx . measureText ( text + pre + words [ w ] ) ;
measure = ctx . measureText ( text + pre + words [ w ] ) ;
if ( measure . width > this . fontOptions . maxWdt ) {
if ( ( measure . width > this . fontOptions . maxWdt ) && ( lastMeasure . width != 0 ) ) {
lines . addAndAccumulate ( k , text , values . font , values . color , lastMeasure . width , values . size , values . vadjust , "normal" , values . strokeWidth , values . strokeColor )
lines . addAndAccumulate ( k , text , values . font , values . color , lastMeasure . width , values . size , values . vadjust , "normal" , values . strokeWidth , values . strokeColor )
width = lines [ k ] . width > width ? lines [ k ] . width : width ;
width = lines [ k ] . width > width ? lines [ k ] . width : width ;
height += lines [ k ] . height ;
height += lines [ k ] . height ;