fix: userInfo position

This commit is contained in:
zzc
2026-02-01 17:44:15 +08:00
parent 068f18a708
commit 3f4fff3584

View File

@@ -1207,13 +1207,16 @@ function drawUserBubble(ctx, options) {
// 3⃣ 绘制文字 // 3⃣ 绘制文字
const textX = avatarX + avatarSize + padding; const textX = avatarX + avatarSize + padding;
const textY = drawY + padding; const totalTextHeight = fontSizeName + fontSizeDesc + 4;
const textStartY = drawY + (bubbleHeight - totalTextHeight) / 2;
ctx.fillStyle = textColor; ctx.fillStyle = textColor;
ctx.font = `${fontSizeName}px 'PingFang SC'`; ctx.font = `${fontSizeName}px 'PingFang SC'`;
ctx.fillText(username, textX, textY); ctx.fillText(username, textX, textStartY);
ctx.font = `${fontSizeDesc}px 'PingFang SC'`; ctx.font = `${fontSizeDesc}px 'PingFang SC'`;
ctx.globalAlpha = 0.6; ctx.globalAlpha = 0.6;
ctx.fillText(desc, textX, textY + fontSizeName + 4); ctx.fillText(desc, textX, textStartY + fontSizeName + 4);
ctx.globalAlpha = 1; ctx.globalAlpha = 1;
} }