未验证 提交 c7477c91 编写于 作者: J Jason Simmons 提交者: GitHub

libtxt: exclude soft break whitespace from line widths for right justification (#5166)

If a line has a soft break due to word wrap, the line width should not include
the width of the whitespace characters within the soft break.
上级 9e4c5d0e
......@@ -787,7 +787,12 @@ double Paragraph::GetLineXOffset(size_t line_number,
if (align == TextAlign::right ||
(align == TextAlign::start && direction == TextDirection::rtl) ||
(align == TextAlign::end && direction == TextDirection::ltr)) {
return width_ - line_total_advance;
// If this line has a soft break, then use the line width calculated by the
// line breaker because that width excludes the soft break's whitespace.
double text_width = line_ranges_[line_number].hard_break
? line_total_advance
: line_widths_[line_number];
return width_ - text_width;
} else if (paragraph_style_.text_align == TextAlign::center) {
return (width_ - line_widths_[line_number]) / 2;
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册