Skip to content

Commit

Permalink
Merge pull request #1724 from VisActor/fix/multiline-rt-fontSize
Browse files Browse the repository at this point in the history
fix: fix issue with multiline richtext lineHeight
  • Loading branch information
neuqzxy authored Feb 11, 2025
2 parents bcc4950 + 0fb7ce4 commit 67eb9fd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
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 richtext lineHeight",
"type": "none"
}
],
"packageName": "@visactor/vrender-core"
}
13 changes: 12 additions & 1 deletion packages/vrender-core/src/graphic/richtext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,18 @@ export class RichText extends Graphic<IRichTextGraphicAttribute> implements IRic
// 如果有文字内有换行符,将该段文字切为多段,并在后一段加入newLine标记
const textParts = richTextConfig.text.split('\n');
for (let j = 0; j < textParts.length; j++) {
paragraphs.push(new Paragraph(textParts[j], j !== 0, richTextConfig, ascentDescentMode));
if (j === 0) {
paragraphs.push(new Paragraph(textParts[j], false, richTextConfig, ascentDescentMode));
} else if (textParts[j] || i === textConfig.length - 1) {
paragraphs.push(new Paragraph(textParts[j], true, richTextConfig, ascentDescentMode));
} else {
// 空行的话,config应该要和下一行对齐
const nextRichTextConfig = this.combinedStyleToCharacter(
textConfig[i + 1] as IRichTextParagraphCharacter
) as IRichTextParagraphCharacter;
paragraphs.push(new Paragraph(textParts[j], true, nextRichTextConfig, ascentDescentMode));
}
// paragraphs.push(new Paragraph(textParts[j], j !== 0, richTextConfig, ascentDescentMode));
}
} else if (richTextConfig.text) {
paragraphs.push(new Paragraph(richTextConfig.text, false, richTextConfig, ascentDescentMode));
Expand Down

0 comments on commit 67eb9fd

Please sign in to comment.