From 6680a134252a65b346b0a99142998ced277e8adf Mon Sep 17 00:00:00 2001 From: liuyang Date: Sat, 26 Sep 2020 19:44:24 +0800 Subject: [PATCH] fix(rotate text position mistake, when sheet zoom): fix zoom bug, fix strike and underline bug --- src/global/draw.js | 8 ++--- src/index.html | 80 +++++++++++++++++++++++----------------------- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/global/draw.js b/src/global/draw.js index 2938120..beca55a 100644 --- a/src/global/draw.js +++ b/src/global/draw.js @@ -2140,9 +2140,9 @@ function cellTextRender(textInfo, ctx, option){ if(textInfo.rotate!=0 && textInfo.type!="verticalWrap"){ ctx.save(); - ctx.translate(pos_x+textInfo.textLeftAll, pos_y+textInfo.textTopAll); + ctx.translate((pos_x+textInfo.textLeftAll)/Store.zoomRatio, (pos_y+textInfo.textTopAll)/Store.zoomRatio); ctx.rotate(-textInfo.rotate * Math.PI / 180); - ctx.translate(-(textInfo.textLeftAll+pos_x), -(pos_y+textInfo.textTopAll)); + ctx.translate(-(textInfo.textLeftAll+pos_x)/Store.zoomRatio, -(pos_y+textInfo.textTopAll)/Store.zoomRatio); } // ctx.fillStyle = "rgb(0,0,0)"; @@ -2169,7 +2169,7 @@ function cellTextRender(textInfo, ctx, option){ Math.floor((pos_x +c.endX)/Store.zoomRatio)+0.5 , Math.floor((pos_y+c.endY)/Store.zoomRatio)+0.5 , ); - ctx.lineWidth = 1; + ctx.lineWidth = Math.floor(c.fs/9); ctx.strokeStyle = ctx.fillStyle; ctx.stroke(); ctx.closePath(); @@ -2188,7 +2188,7 @@ function cellTextRender(textInfo, ctx, option){ Math.floor((pos_x +item.endX)/Store.zoomRatio)+0.5, Math.floor((pos_y+ item.endY)/Store.zoomRatio)+0.5 ); - ctx.lineWidth = 1; + ctx.lineWidth = Math.floor(item.fs/9); ctx.strokeStyle = ctx.fillStyle; ctx.stroke(); ctx.closePath(); diff --git a/src/index.html b/src/index.html index 37042a1..2a39f6c 100644 --- a/src/index.html +++ b/src/index.html @@ -81,46 +81,46 @@ forceCalculation:false, plugins: ['chart'], data: - [sheetCell,sheetFormula,sheetConditionFormat,sheetSparkline,sheetTable,sheetComment,sheetPivotTableData,sheetPivotTable,sheetChart,sheetPicture,sheetDataVerification] - // [{"name":"Sheet1","config":{"columnlen":{"0":241},"rowlen":{"0":81}},"index":"1","status":"1","order":"0","luckysheet_select_save":[{"row":[0,0],"column":[4,4],"sheetIndex":1}],"zoomRatio":1,"showGridLines":"1","defaultColWidth":72,"defaultRowHeight":18,"celldata":[ - // {"r":0,"c":0, - // "v":{ - // "ct":{ - // "fa":"General", - // "t":"inlineStr", - // "s":[ - // { - // "ff":"Arial", //font family - // "fc":"#fff000",//font color - // "fs":12,//font size - // "cl":0,//strike - // "un":0,//underline - // "bl":0,//blod - // "it":0,//italic - // v:"我在马路\r\n边捡到\r\n\r\n一分钱" - // }, - // { - // "ff":"Arial", //font family - // "fc":"#ff0000",//font color - // "fs":14,//font size - // "cl":"1",//strike - // "un":"1",//underline - // "bl":"1",//blod - // "it":"0",//italic - // v:"交给警\r\n察叔叔\r\n" - // }, - // ] - // }, - // "fs":11, - // "ff":"等线", - // "vt":0, - // "tb":2, - // "v":"", - // "qp":1, - // } - // }, - // {"r":17,"c":2,"v":{"v":"Luckysheet","ct":{"fa":"General","t":"g"},"bg":null,"bl":0,"it":0,"ff":0,"fs":"11","fc":"rgb(51, 51, 51)","ht":1,"vt":1,"m":"Luckysheet"}} - // ],"calcChain":[]}] + // [sheetCell,sheetFormula,sheetConditionFormat,sheetSparkline,sheetTable,sheetComment,sheetPivotTableData,sheetPivotTable,sheetChart,sheetPicture,sheetDataVerification] + [{"name":"Sheet1","config":{"columnlen":{"0":241},"rowlen":{"0":81}},"index":"1","status":"1","order":"0","luckysheet_select_save":[{"row":[0,0],"column":[4,4],"sheetIndex":1}],"zoomRatio":1,"showGridLines":"1","defaultColWidth":72,"defaultRowHeight":18,"celldata":[ + {"r":0,"c":0, + "v":{ + "ct":{ + "fa":"General", + "t":"inlineStr", + "s":[ + { + "ff":"Arial", //font family + "fc":"#fff000",//font color + "fs":12,//font size + "cl":0,//strike + "un":0,//underline + "bl":0,//blod + "it":0,//italic + v:"我在马路\r\n边捡到\r\n\r\n一分钱" + }, + { + "ff":"Arial", //font family + "fc":"#ff0000",//font color + "fs":14,//font size + "cl":"1",//strike + "un":"1",//underline + "bl":"1",//blod + "it":"0",//italic + v:"交给警\r\n察叔叔\r\n" + }, + ] + }, + "fs":11, + "ff":"等线", + "vt":0, + "tb":2, + "v":"", + "qp":1, + } + }, + {"r":17,"c":2,"v":{"v":"Luckysheet","ct":{"fa":"General","t":"g"},"bg":null,"bl":0,"it":0,"ff":0,"fs":"11","fc":"rgb(51, 51, 51)","ht":1,"vt":1,"m":"Luckysheet"}} + ],"calcChain":[]}] }) })