diff --git a/engine/src/flutter/third_party/txt/src/txt/paragraph.cc b/engine/src/flutter/third_party/txt/src/txt/paragraph.cc index e76ecaf5cb..25e7725bbd 100644 --- a/engine/src/flutter/third_party/txt/src/txt/paragraph.cc +++ b/engine/src/flutter/third_party/txt/src/txt/paragraph.cc @@ -439,7 +439,7 @@ void Paragraph::Layout(double width, bool force) { std::vector ellipsized_text; if (ellipsis.length() && !isinf(width_) && !line_range.hard_break && (line_number == line_limit - 1 || - paragraph_style_.max_lines == std::numeric_limits::max())) { + paragraph_style_.unlimited_lines())) { float ellipsis_width = layout.measureText( reinterpret_cast(ellipsis.data()), 0, ellipsis.length(), ellipsis.length(), bidiFlags, font, @@ -471,7 +471,7 @@ void Paragraph::Layout(double width, bool force) { // If there is no line limit, then skip all lines after the ellipsized // line. - if (paragraph_style_.max_lines == std::numeric_limits::max()) { + if (paragraph_style_.unlimited_lines()) { line_limit = line_number + 1; did_exceed_max_lines_ = true; } @@ -666,7 +666,12 @@ void Paragraph::Layout(double width, bool force) { for (double line_width : line_widths_) { max_intrinsic_width_ += line_width; } - min_intrinsic_width_ = std::min(max_word_width, max_intrinsic_width_); + if (paragraph_style_.max_lines == 1 || + (paragraph_style_.unlimited_lines() && paragraph_style_.ellipsized())) { + min_intrinsic_width_ = max_intrinsic_width_; + } else { + min_intrinsic_width_ = std::min(max_word_width, max_intrinsic_width_); + } std::sort(code_unit_runs_.begin(), code_unit_runs_.end(), [](const CodeUnitRun& a, const CodeUnitRun& b) { diff --git a/engine/src/flutter/third_party/txt/src/txt/paragraph_style.cc b/engine/src/flutter/third_party/txt/src/txt/paragraph_style.cc index 0589cc3c83..a7941ad4e5 100644 --- a/engine/src/flutter/third_party/txt/src/txt/paragraph_style.cc +++ b/engine/src/flutter/third_party/txt/src/txt/paragraph_style.cc @@ -27,4 +27,12 @@ TextStyle ParagraphStyle::GetTextStyle() const { return result; } +bool ParagraphStyle::unlimited_lines() const { + return max_lines == std::numeric_limits::max(); +}; + +bool ParagraphStyle::ellipsized() const { + return !ellipsis.empty(); +} + } // namespace txt diff --git a/engine/src/flutter/third_party/txt/src/txt/paragraph_style.h b/engine/src/flutter/third_party/txt/src/txt/paragraph_style.h index b59e83aad3..8c2701768b 100644 --- a/engine/src/flutter/third_party/txt/src/txt/paragraph_style.h +++ b/engine/src/flutter/third_party/txt/src/txt/paragraph_style.h @@ -61,6 +61,9 @@ class ParagraphStyle { minikin::BreakStrategy::kBreakStrategy_Greedy; TextStyle GetTextStyle() const; + + bool unlimited_lines() const; + bool ellipsized() const; }; } // namespace txt