Skip to content

Commit 15c33bb

Browse files
jason-simmonschriscraws
authored andcommitted
Initialize max_ascent/descent from the strut only if the strut is valid (flutter#24802)
1 parent 885c905 commit 15c33bb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

third_party/txt/src/txt/paragraph_txt.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,8 @@ bool ParagraphTxt::IsStrutValid() const {
518518
}
519519

520520
void ParagraphTxt::ComputeStrut(StrutMetrics* strut, SkFont& font) {
521-
strut->ascent = std::numeric_limits<SkScalar>::lowest();
522-
strut->descent = std::numeric_limits<SkScalar>::lowest();
521+
strut->ascent = 0;
522+
strut->descent = 0;
523523
strut->leading = 0;
524524
strut->half_leading = 0;
525525
strut->line_height = 0;
@@ -1123,8 +1123,10 @@ void ParagraphTxt::Layout(double width) {
11231123

11241124
// Calculate the amount to advance in the y direction. This is done by
11251125
// computing the maximum ascent and descent with respect to the strut.
1126-
double max_ascent = strut_.ascent + strut_.half_leading;
1127-
double max_descent = strut_.descent + strut_.half_leading;
1126+
double max_ascent = IsStrutValid() ? strut_.ascent + strut_.half_leading
1127+
: std::numeric_limits<double>::lowest();
1128+
double max_descent = IsStrutValid() ? strut_.descent + strut_.half_leading
1129+
: std::numeric_limits<double>::lowest();
11281130
double max_unscaled_ascent = 0;
11291131
for (const PaintRecord& paint_record : paint_records) {
11301132
UpdateLineMetrics(paint_record.metrics(), paint_record.style(),

0 commit comments

Comments
 (0)