Browse Source

fix(bug): 文本自动换行bug

master
break-wave 5 years ago
parent
commit
bc926e5c49
  1. 21
      src/global/getRowlen.js

21
src/global/getRowlen.js

@ -903,6 +903,8 @@ function getCellTextInfo(cell , ctx, option){
let height = textWidth * Math.sin(rt*Math.PI/180) + textHeight * Math.cos(rt*Math.PI/180);//consider text box wdith and line height
let lastWord = str.substr(str.length-1,1);
let isSpace = lastWord.replace(/\r\n/g, "_x000D_").replace(/
/g, "_x000D_").replace(/\r/g, "_x000D_").replace(/\n/g, "_x000D_");
isSpace = isSpace === '_x000D_'
if(lastWord==" " || checkWordByteLength(lastWord)==2){
if(preMeasureText!=null){
spaceOrTwoByte = {
@ -1054,6 +1056,25 @@ function getCellTextInfo(cell , ctx, option){
splitIndex +=1;
}
}
else if(isSpace && text_all_split[splitIndex]!=null && i!= value.length) {
spaceOrTwoByte = null;
anchor = i;
text_all_split[splitIndex].push({
content:str,
style:fontset,
width:preTextWidth,
height:preTextHeight,
left:0,
top:0,
splitIndex:splitIndex,
asc:measureText.actualBoundingBoxAscent,
desc:measureText.actualBoundingBoxDescent,
fs:fontSize,
});
splitIndex +=1;
}
else if(i== value.length){
if(text_all_split[splitIndex]==null){
text_all_split[splitIndex]= [];

Loading…
Cancel
Save