Skip to content

Commit

Permalink
fix: office-viewer excel 去掉字母间距导致显示不正确问题
Browse files Browse the repository at this point in the history
  • Loading branch information
nwind committed Mar 22, 2024
1 parent 3ea2bb6 commit e76d6a0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/amis/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"moment": "^2.19.4",
"moment-timezone": "^0.5.34",
"mpegts.js": "^1.6.10",
"office-viewer": "^0.3.7",
"office-viewer": "^0.3.8",
"prop-types": "^15.6.1",
"qrcode.react": "^3.1.0",
"react-cropper": "^2.1.8",
Expand Down
2 changes: 1 addition & 1 deletion packages/office-viewer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "office-viewer",
"version": "0.3.7",
"version": "0.3.8",
"description": "office 文档在线预览",
"main": "lib/index.js",
"module": "esm/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ export function drawMultiLineText(

const defaultFontHeight = dataProvider.getDefaultFontSize().height;

const latterSpace = defaultFontHeight * 0.1;

const textPositions: Rect[] = [];

const totalLineHeight = lines.reduce((acc, line) => {
Expand All @@ -65,9 +63,6 @@ export function drawMultiLineText(
return acc + (token.w || 0);
}, 0);

// 加上字母间距
totalLineWidth += latterSpace * (tokens.length - 1);

if (horizontal === 'center') {
currentX = x + (width - totalLineWidth) / 2;
} else if (horizontal === 'right') {
Expand Down Expand Up @@ -97,7 +92,7 @@ export function drawMultiLineText(
height: fontHeight
});
// 这里其实不大可能为零
currentX = currentX + (token.w || 0) + latterSpace;
currentX = currentX + (token.w || 0);
}
const lineHeight = line.maxHeight || defaultFontHeight;
textHeight += lineHeight;
Expand Down

0 comments on commit e76d6a0

Please sign in to comment.