[skottie] Clip overflowing paragraph lines
AE discards lines with baselines outside the paragraph box. This aligns Skottie's behavior with AE for default/top-alignment (but not for any of the custom vertical alignment modes). Bug: skia:9933 Change-Id: Id0318f0744bf89580774e89494faf19bfb6f6d14 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/272376 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
This commit is contained in:
parent
5e5e848770
commit
0de01c05b7
@ -144,9 +144,7 @@ public:
|
||||
fResult.fFragments.push_back({fBuilder.make(), {fBox.x(), fBox.y()}, 0, false});
|
||||
}
|
||||
|
||||
// Use the explicit ascent, when specified.
|
||||
// Note: ascent values are negative (relative to the baseline).
|
||||
const auto ascent = fDesc.fAscent ? fDesc.fAscent : fFirstLineAscent;
|
||||
const auto ascent = this->ascent();
|
||||
|
||||
// For visual VAlign modes, we use a hybrid extent box computed as the union of
|
||||
// actual visual bounds and the vertical typographical extent.
|
||||
@ -228,6 +226,16 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
// In default paragraph mode (VAlign::kTop), AE clips out lines when the baseline
|
||||
// goes below the box lower edge.
|
||||
if (fDesc.fVAlign == Shaper::VAlign::kTop) {
|
||||
// fOffset is relative to the first line baseline.
|
||||
const auto max_offset = fBox.height() + this->ascent(); // NB: ascent is negative
|
||||
if (fOffset.y() > max_offset) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// When no text box is present, text is laid out on a single infinite line
|
||||
// (modulo explicit line breaks).
|
||||
const auto shape_width = fBox.isEmpty() ? SK_ScalarMax
|
||||
@ -297,6 +305,12 @@ private:
|
||||
return 0.0f; // go home, msvc...
|
||||
}
|
||||
|
||||
SkScalar ascent() const {
|
||||
// Use the explicit ascent, when specified.
|
||||
// Note: ascent values are negative (relative to the baseline).
|
||||
return fDesc.fAscent ? fDesc.fAscent : fFirstLineAscent;
|
||||
}
|
||||
|
||||
static constexpr SkGlyphID kMissingGlyphID = 0;
|
||||
|
||||
const Shaper::TextDesc& fDesc;
|
||||
|
1
resources/skottie/skottie-text-vertical-clip.json
Normal file
1
resources/skottie/skottie-text-vertical-clip.json
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user