Skip to content

Commit

Permalink
Initialize max_ascent/descent from the strut only if the strut is val…
Browse files Browse the repository at this point in the history
…id (#24802)
  • Loading branch information
jason-simmons committed Mar 5, 2021
1 parent b52b2f3 commit f751d04
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions third_party/txt/src/txt/paragraph_txt.cc
Expand Up @@ -518,8 +518,8 @@ bool ParagraphTxt::IsStrutValid() const {
}

void ParagraphTxt::ComputeStrut(StrutMetrics* strut, SkFont& font) {
strut->ascent = std::numeric_limits<SkScalar>::lowest();
strut->descent = std::numeric_limits<SkScalar>::lowest();
strut->ascent = 0;
strut->descent = 0;
strut->leading = 0;
strut->half_leading = 0;
strut->line_height = 0;
Expand Down Expand Up @@ -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<double>::lowest();
double max_descent = IsStrutValid() ? strut_.descent + strut_.half_leading
: std::numeric_limits<double>::lowest();
double max_unscaled_ascent = 0;
for (const PaintRecord& paint_record : paint_records) {
UpdateLineMetrics(paint_record.metrics(), paint_record.style(),
Expand Down

0 comments on commit f751d04

Please sign in to comment.