Commit ad857852 by olly Committed by Oliver Woodman

Discard subtitles with invalid positions

textWidth can be negative if textLeft extends parentRight (i.e.
the subtitle is positioned entirely off the screen to the RHS).
We should just discard and log a warning in this case.

Issue: #2497

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=148481310
parent 129334d2
......@@ -266,6 +266,12 @@ import com.google.android.exoplayer2.util.Util;
textRight = textLeft + textWidth;
}
textWidth = textRight - textLeft;
if (textWidth <= 0) {
Log.w(TAG, "Skipped drawing subtitle cue (invalid horizontal positioning)");
return;
}
int textTop;
if (cueLine != Cue.DIMEN_UNSET) {
int anchorPosition;
......@@ -292,8 +298,6 @@ import com.google.android.exoplayer2.util.Util;
textTop = parentBottom - textHeight - (int) (parentHeight * bottomPaddingFraction);
}
textWidth = textRight - textLeft;
// Update the derived drawing variables.
this.textLayout = new StaticLayout(cueText, textPaint, textWidth, textAlignment, spacingMult,
spacingAdd, true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment