diff --git a/library/src/main/java/com/google/android/exoplayer/text/CuePainter.java b/library/src/main/java/com/google/android/exoplayer/text/CuePainter.java index 28ff5bc0b4..a1832b2774 100644 --- a/library/src/main/java/com/google/android/exoplayer/text/CuePainter.java +++ b/library/src/main/java/com/google/android/exoplayer/text/CuePainter.java @@ -216,6 +216,9 @@ import android.util.Log; for (int i = 0; i < lineCount; i++) { textWidth = Math.max((int) Math.ceil(textLayout.getLineWidth(i)), textWidth); } + if (cueSize != Cue.DIMEN_UNSET && textWidth < availableWidth) { + textWidth = availableWidth; + } textWidth += textPaddingX * 2; int textLeft; diff --git a/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlNode.java b/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlNode.java index abf9a4643c..691f69c1ae 100644 --- a/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlNode.java +++ b/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlNode.java @@ -180,7 +180,7 @@ import java.util.TreeSet; List cues = new ArrayList<>(); for (Entry entry : regionOutputs.entrySet()) { TtmlRegion region = regionMap.get(entry.getKey()); - cues.add(new Cue(cleanUpText(entry.getValue()), null, region.line, Cue.TYPE_UNSET, + cues.add(new Cue(cleanUpText(entry.getValue()), null, region.line, region.lineType, Cue.TYPE_UNSET, region.position, Cue.TYPE_UNSET, region.width)); } return cues; diff --git a/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlParser.java b/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlParser.java index 527bd533ae..43f55c49af 100644 --- a/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlParser.java +++ b/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlParser.java @@ -218,8 +218,8 @@ public final class TtmlParser extends SimpleSubtitleParser { } } } - return position != Cue.DIMEN_UNSET ? new Pair<>(regionId, new TtmlRegion(position, line, width)) - : null; + return position != Cue.DIMEN_UNSET ? new Pair<>(regionId, new TtmlRegion(position, line, + Cue.LINE_TYPE_FRACTION, width)) : null; } private String[] parseStyleIds(String parentStyleIds) { diff --git a/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlRegion.java b/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlRegion.java index 135018a861..a3ea9790a1 100644 --- a/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlRegion.java +++ b/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlRegion.java @@ -24,15 +24,17 @@ import com.google.android.exoplayer.text.Cue; public final float position; public final float line; + public final int lineType; public final float width; public TtmlRegion() { - this(Cue.DIMEN_UNSET, Cue.DIMEN_UNSET, Cue.DIMEN_UNSET); + this(Cue.DIMEN_UNSET, Cue.DIMEN_UNSET, Cue.TYPE_UNSET, Cue.DIMEN_UNSET); } - public TtmlRegion(float position, float line, float width) { + public TtmlRegion(float position, float line, int lineType, float width) { this.position = position; this.line = line; + this.lineType = lineType; this.width = width; }