Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vrender-core",
"comment": "fix: fix issue with multiline text render pos",
"type": "none"
}
],
"packageName": "@visactor/vrender-core"
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ export class CanvasTextLayout {
}

// line.topOffset = lineHeight * 0.79 + origin[1]; // 渲染默认使用alphabetic
line.topOffset = (lineHeight - this.textOptions.fontSize) / 2 + this.textOptions.fontSize * 0.79 + origin[1];
// 0.79在中文会超出,使用0.82
line.topOffset = (lineHeight - this.textOptions.fontSize) / 2 + this.textOptions.fontSize * 0.82 + origin[1];
origin[1] += lineHeight;

return line;
Expand Down
18 changes: 18 additions & 0 deletions packages/vrender/__tests__/browser/src/pages/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,24 @@ export const page = () => {
});
graphics.push(circle);

const wt = createText({
text: ['省/自治区字段信息jfkdlafjkdag'],
ellipsis: '...',
fill: 'red',
fontSize: 68,
fontWeight: 'bold',
textAlign: 'center',
textBaseline: 'top',
width: 1628,
maxLineWidth: 1628,
x: 814,
y: 100,
_debug_bounds: true,
wrap: true
});
graphics.push(wt);
console.log('wt', wt);

const rect = createRect({
x: t.AABBBounds.x1,
y: t.AABBBounds.y1,
Expand Down