diff --git a/src/global/getRowlen.js b/src/global/getRowlen.js index f0566e4..66197e1 100644 --- a/src/global/getRowlen.js +++ b/src/global/getRowlen.js @@ -416,7 +416,7 @@ function getCellTextInfo(cell , ctx, option){ textContent.rotate = rt; rt = Math.abs(rt); - let anchor = 0, preHeight = 0, preWidth=0, preStr, preTextHeight; + let anchor = 0, preHeight = 0, preWidth=0, preStr, preTextHeight, preTextWidth; for(let i = 1; i <= value.length; i++){ let str = value.substring(anchor, i); let measureText = getMeasureText(str, ctx); @@ -434,7 +434,7 @@ function getCellTextInfo(cell , ctx, option){ } if(rt!=0){//rotate - if(height>cellHeight){ + if((height+space_height)>cellHeight){ anchor = i-1; text_all_split[splitIndex].push({ @@ -445,7 +445,10 @@ function getCellTextInfo(cell , ctx, option){ left:0, top:0, splitIndex:splitIndex, - textHeight:preTextHeight + textHeight:preTextHeight, + textWidth:preTextWidth, + asc:measureText.actualBoundingBoxAscent, + desc:measureText.actualBoundingBoxDescent }); splitIndex +=1; @@ -460,12 +463,15 @@ function getCellTextInfo(cell , ctx, option){ left:0, top:0, splitIndex:splitIndex, - textHeight:textHeight + textHeight:textHeight, + textWidth:textWidth, + asc:measureText.actualBoundingBoxAscent, + desc:measureText.actualBoundingBoxDescent }); } } else{//plain - if(width>cellWidth){ + if((width+space_width)>cellWidth){ anchor = i-1; @@ -477,6 +483,8 @@ function getCellTextInfo(cell , ctx, option){ left:0, top:0, splitIndex:splitIndex, + asc:measureText.actualBoundingBoxAscent, + desc:measureText.actualBoundingBoxDescent }); splitIndex +=1; @@ -491,6 +499,8 @@ function getCellTextInfo(cell , ctx, option){ left:0, top:0, splitIndex:splitIndex, + asc:measureText.actualBoundingBoxAscent, + desc:measureText.actualBoundingBoxDescent }); } } @@ -499,15 +509,21 @@ function getCellTextInfo(cell , ctx, option){ preHeight = height; preStr = str; preTextHeight = textHeight; + preTextWidth = textWidth; } let split_all_size = []; - for(let i = 0; i <= splitIndex; i++){ + console.log(splitIndex, text_all_split); + let splitLen = Object.keys(text_all_split).length; + for(let i = 0; i < splitLen; i++){ let splitLists = text_all_split[i]; + if(splitLists==null){ + continue; + } let sWidth = 0, sHeight=0, textHeight=0; for(let s=0;s