From 94022a48b6407523c5924e94c86fb2ada0fab301 Mon Sep 17 00:00:00 2001 From: jerry <654896146@qq.com> Date: Fri, 25 Dec 2020 22:50:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8D=A2=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/global/getRowlen.js | 316 ++++++++++++++++++++-------------------- 1 file changed, 154 insertions(+), 162 deletions(-) diff --git a/src/global/getRowlen.js b/src/global/getRowlen.js index 81760d2..441ff49 100644 --- a/src/global/getRowlen.js +++ b/src/global/getRowlen.js @@ -893,154 +893,187 @@ function getCellTextInfo(cell , ctx, option){ } else{ value = value.toString(); - while(i <= value.length){ - let str = value.substring(anchor, i); - let measureText = getMeasureText(str, ctx); - let textWidth = measureText.width; - let textHeight = measureText.actualBoundingBoxAscent+measureText.actualBoundingBoxDescent; - - let width = textWidth * Math.cos(rt*Math.PI/180) + textHeight * Math.sin(rt*Math.PI/180);//consider text box wdith and line height + let splitValue = value.replace(/\r\n/g, "_x000D_").replace(/ /g, "_x000D_").replace(/\r/g, "_x000D_").replace(/\n/g, "_x000D_"); + let splitArr = splitValue.split("_x000D_"); + for(let x=0, len=splitArr.length;xcellHeight && text_all_split[splitIndex]!=null && i!= value.length){ + // console.log("cut",anchor, i , str); - } - // textW_all += textW; - // console.log(str,anchor,i); - if(rt!=0){//rotate - // console.log("all",anchor, i , str); - if((height+space_height)>cellHeight && text_all_split[splitIndex]!=null && i!= value.length){ - // console.log("cut",anchor, i , str); + if(spaceOrTwoByte!=null && spaceOrTwoByte.indexcellWidth && text_all_split[splitIndex]!=null && i!= value.length){ + // console.log(spaceOrTwoByte, i, anchor); + if(spaceOrTwoByte!=null && spaceOrTwoByte.indexcellWidth && text_all_split[splitIndex]!=null && i!= value.length){ - // console.log(spaceOrTwoByte, i, anchor); - if(spaceOrTwoByte!=null && spaceOrTwoByte.index