Commit 2426907f by olly Committed by Oliver Woodman

Fix positioning issues with ttml regions.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=126790829
parent d3cd0c2e
...@@ -216,6 +216,9 @@ import android.util.Log; ...@@ -216,6 +216,9 @@ import android.util.Log;
for (int i = 0; i < lineCount; i++) { for (int i = 0; i < lineCount; i++) {
textWidth = Math.max((int) Math.ceil(textLayout.getLineWidth(i)), textWidth); textWidth = Math.max((int) Math.ceil(textLayout.getLineWidth(i)), textWidth);
} }
if (cueSize != Cue.DIMEN_UNSET && textWidth < availableWidth) {
textWidth = availableWidth;
}
textWidth += textPaddingX * 2; textWidth += textPaddingX * 2;
int textLeft; int textLeft;
......
...@@ -180,7 +180,7 @@ import java.util.TreeSet; ...@@ -180,7 +180,7 @@ import java.util.TreeSet;
List<Cue> cues = new ArrayList<>(); List<Cue> cues = new ArrayList<>();
for (Entry<String, SpannableStringBuilder> entry : regionOutputs.entrySet()) { for (Entry<String, SpannableStringBuilder> entry : regionOutputs.entrySet()) {
TtmlRegion region = regionMap.get(entry.getKey()); 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)); Cue.TYPE_UNSET, region.position, Cue.TYPE_UNSET, region.width));
} }
return cues; return cues;
......
...@@ -218,8 +218,8 @@ public final class TtmlParser extends SimpleSubtitleParser { ...@@ -218,8 +218,8 @@ public final class TtmlParser extends SimpleSubtitleParser {
} }
} }
} }
return position != Cue.DIMEN_UNSET ? new Pair<>(regionId, new TtmlRegion(position, line, width)) return position != Cue.DIMEN_UNSET ? new Pair<>(regionId, new TtmlRegion(position, line,
: null; Cue.LINE_TYPE_FRACTION, width)) : null;
} }
private String[] parseStyleIds(String parentStyleIds) { private String[] parseStyleIds(String parentStyleIds) {
......
...@@ -24,15 +24,17 @@ import com.google.android.exoplayer.text.Cue; ...@@ -24,15 +24,17 @@ import com.google.android.exoplayer.text.Cue;
public final float position; public final float position;
public final float line; public final float line;
public final int lineType;
public final float width; public final float width;
public TtmlRegion() { 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.position = position;
this.line = line; this.line = line;
this.lineType = lineType;
this.width = width; this.width = width;
} }
......
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