From b978d1fb46c1ae4f9bdfed1aa10c594d1f8b1876 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Fri, 5 Mar 2021 15:44:01 -0800 Subject: [PATCH] Initialize max_ascent/descent from the strut only if the strut is valid (flutter/engine#24802) --- .../flutter/third_party/txt/src/txt/paragraph_txt.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/engine/src/flutter/third_party/txt/src/txt/paragraph_txt.cc b/engine/src/flutter/third_party/txt/src/txt/paragraph_txt.cc index 81f34ec8f4..3dbb38deda 100644 --- a/engine/src/flutter/third_party/txt/src/txt/paragraph_txt.cc +++ b/engine/src/flutter/third_party/txt/src/txt/paragraph_txt.cc @@ -518,8 +518,8 @@ bool ParagraphTxt::IsStrutValid() const { } void ParagraphTxt::ComputeStrut(StrutMetrics* strut, SkFont& font) { - strut->ascent = std::numeric_limits::lowest(); - strut->descent = std::numeric_limits::lowest(); + strut->ascent = 0; + strut->descent = 0; strut->leading = 0; strut->half_leading = 0; strut->line_height = 0; @@ -1123,8 +1123,10 @@ void ParagraphTxt::Layout(double width) { // Calculate the amount to advance in the y direction. This is done by // computing the maximum ascent and descent with respect to the strut. - double max_ascent = strut_.ascent + strut_.half_leading; - double max_descent = strut_.descent + strut_.half_leading; + double max_ascent = IsStrutValid() ? strut_.ascent + strut_.half_leading + : std::numeric_limits::lowest(); + double max_descent = IsStrutValid() ? strut_.descent + strut_.half_leading + : std::numeric_limits::lowest(); double max_unscaled_ascent = 0; for (const PaintRecord& paint_record : paint_records) { UpdateLineMetrics(paint_record.metrics(), paint_record.style(),