mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Fix a bug with TTML font styling that displays empty lines.
If the caption line has no text (empty line or only line break), we should not display its background. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=196823319
This commit is contained in:
parent
972304f16b
commit
24b16f3419
@ -20,8 +20,11 @@
|
||||
* Fix playback of livestreams with EXT-X-PROGRAM-DATE-TIME tags
|
||||
([#4239](https://github.com/google/ExoPlayer/issues/4239)).
|
||||
* Caption:
|
||||
* Fix a TTML styling issue when there are multiple regions displayed at the
|
||||
same time that can make text size of each region much smaller than defined.
|
||||
* TTML:
|
||||
* Fix a styling issue when there are multiple regions displayed at the same
|
||||
time that can make text size of each region much smaller than defined.
|
||||
* Fix an issue when the caption line has no text (empty line or only line
|
||||
break), and the line's background is still displayed.
|
||||
|
||||
### 2.8.0 ###
|
||||
|
||||
|
@ -372,14 +372,24 @@ import com.google.android.exoplayer2.util.Util;
|
||||
float previousBottom = layout.getLineTop(0);
|
||||
int lineCount = layout.getLineCount();
|
||||
for (int i = 0; i < lineCount; i++) {
|
||||
lineBounds.left = layout.getLineLeft(i) - textPaddingX;
|
||||
lineBounds.right = layout.getLineRight(i) + textPaddingX;
|
||||
float lineTextBoundLeft = layout.getLineLeft(i);
|
||||
float lineTextBoundRight = layout.getLineRight(i);
|
||||
lineBounds.left = lineTextBoundLeft - textPaddingX;
|
||||
lineBounds.right = lineTextBoundRight + textPaddingX;
|
||||
lineBounds.top = previousBottom;
|
||||
lineBounds.bottom = layout.getLineBottom(i);
|
||||
previousBottom = lineBounds.bottom;
|
||||
float lineTextWidth = lineTextBoundRight - lineTextBoundLeft;
|
||||
if (lineTextWidth > 0) {
|
||||
// Do not draw a line's background color if it has no text.
|
||||
// For some reason, calculating the width manually is more reliable than
|
||||
// layout.getLineWidth().
|
||||
// Sometimes, lineTextBoundRight == lineTextBoundLeft, and layout.getLineWidth() still
|
||||
// returns non-zero value.
|
||||
canvas.drawRoundRect(lineBounds, cornerRadius, cornerRadius, paint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (edgeType == CaptionStyleCompat.EDGE_TYPE_OUTLINE) {
|
||||
textPaint.setStrokeJoin(Join.ROUND);
|
||||
|
Loading…
x
Reference in New Issue
Block a user