Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
feat(bottom alignment of english letters): fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tubiaoge committed Nov 10, 2020
1 parent bbdfb09 commit a596d2f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
35 changes: 33 additions & 2 deletions src/global/getRowlen.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ function getMeasureText(value, ctx, fontset){
}

let measureText = ctx.measureText(value), cache = {};
var regu = "^[ ]+$";
var re = new RegExp(regu);
// var regu = "^[ ]+$";
// var re = new RegExp(regu);
// if(measureText.actualBoundingBoxRight==null || re.test(value)){
// cache.width = measureText.width;
// }
Expand Down Expand Up @@ -235,6 +235,37 @@ function getMeasureText(value, ctx, fontset){

//console.log(value, oneLineTextHeight, measureText.actualBoundingBoxDescent+measureText.actualBoundingBoxAscent,ctx.font);
}

if(ctx.textBaseline == 'alphabetic'){
let descText = "gjpqy", matchText="abcdABCD";
let descTextMeasure = Store.measureTextCache[descText + "_" + ctx.font];
if(fontset!=null){
descTextMeasure = Store.measureTextCache[descText + "_" + fontset];
}

let matchTextMeasure = Store.measureTextCache[matchText + "_" + ctx.font];
if(fontset!=null){
matchTextMeasure = Store.measureTextCache[matchText + "_" + fontset];
}

if(descTextMeasure == null){
descTextMeasure = ctx.measureText(descText);
}

if(matchTextMeasure == null){
matchTextMeasure = ctx.measureText(matchText);
}

if(cache.actualBoundingBoxDescent<=matchTextMeasure.actualBoundingBoxDescent){
cache.actualBoundingBoxDescent = descTextMeasure.actualBoundingBoxDescent;
if(cache.actualBoundingBoxDescent==null){
cache.actualBoundingBoxDescent = 0;
}
}


}

cache.width *= Store.zoomRatio;
cache.actualBoundingBoxDescent *= Store.zoomRatio;
cache.actualBoundingBoxAscent *= Store.zoomRatio;
Expand Down
9 changes: 9 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@
},
data:
[sheetCell,sheetFormula,sheetConditionFormat,sheetSparkline,sheetTable,sheetComment,sheetPivotTableData,sheetPivotTable,sheetChart,sheetPicture,sheetDataVerification]
/*[{
"index": "0",
"zoomRatio": 1,
"order": "0",
"column": 3,
"row": 4,
"status": 1,
celldata:[{"r":0,"c":0,"v":{"bg":null,"bl":0,"it":0,"ff":0,"fs":11,"fc":"rgb(51, 51, 51)","ht":1,"vt":1,"v":1,"ct":{"fa":"General","t":"n"},"m":"1"}},{"r":0,"c":1,"v":{"bg":null,"bl":0,"it":0,"ff":0,"fs":11,"fc":"rgb(51, 51, 51)","ht":1,"vt":1,"v":2,"ct":{"fa":"General","t":"n"},"m":"2"}}]
}]*/
/*[{"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":{
Expand Down

0 comments on commit a596d2f

Please sign in to comment.