Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e0c39ade
authored
Apr 30, 2021
by
bachinger
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Merge pull request #8877 from dlafayet:textAlign
PiperOrigin-RevId: 371306900
parent
92253e1a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
10 deletions
RELEASENOTES.md
library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlNode.java
library/core/src/test/java/com/google/android/exoplayer2/text/ttml/TtmlDecoderTest.java
testdata/src/test/assets/media/ttml/text_align.xml
RELEASENOTES.md
View file @
e0c39ade
...
@@ -116,6 +116,8 @@
...
@@ -116,6 +116,8 @@
*
Fix lines overlapping when using
`SubtitleView.VIEW_TYPE_WEB`
.
*
Fix lines overlapping when using
`SubtitleView.VIEW_TYPE_WEB`
.
*
Parse SSA/ASS underline & strikethrough info in
`Style:`
lines
*
Parse SSA/ASS underline & strikethrough info in
`Style:`
lines
(
[
#8435
](
https://github.com/google/ExoPlayer/issues/8435
)
).
(
[
#8435
](
https://github.com/google/ExoPlayer/issues/8435
)
).
*
Ensure TTML
`tts:textAlign`
is correctly propagated from
`<p>`
nodes to
child nodes.
*
MediaSession extension: Remove dependency to core module and rely on common
*
MediaSession extension: Remove dependency to core module and rely on common
only. The
`TimelineQueueEditor`
uses a new
`MediaDescriptionConverter`
for
only. The
`TimelineQueueEditor`
uses a new
`MediaDescriptionConverter`
for
this purpose and does not rely on the
`ConcatenatingMediaSource`
anymore.
this purpose and does not rely on the
`ConcatenatingMediaSource`
anymore.
...
...
library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlNode.java
View file @
e0c39ade
...
@@ -409,17 +409,21 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -409,17 +409,21 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
if
(
resolvedStyle
!=
null
)
{
if
(
resolvedStyle
!=
null
)
{
TtmlRenderUtil
.
applyStylesToSpan
(
TtmlRenderUtil
.
applyStylesToSpan
(
text
,
start
,
end
,
resolvedStyle
,
parent
,
globalStyles
,
verticalType
);
text
,
start
,
end
,
resolvedStyle
,
parent
,
globalStyles
,
verticalType
);
if
(
resolvedStyle
.
getShearPercentage
()
!=
TtmlStyle
.
UNSPECIFIED_SHEAR
&&
TAG_P
.
equals
(
tag
))
{
if
(
TAG_P
.
equals
(
tag
))
{
// Shear style should only be applied to P nodes
if
(
resolvedStyle
.
getShearPercentage
()
!=
TtmlStyle
.
UNSPECIFIED_SHEAR
)
{
// https://www.w3.org/TR/2018/REC-ttml2-20181108/#style-attribute-shear
// Shear style should only be applied to P nodes
// The spec doesn't specify the coordinate system to use for block shear
// https://www.w3.org/TR/2018/REC-ttml2-20181108/#style-attribute-shear
// however the spec shows examples of how different values are expected to be rendered.
// The spec doesn't specify the coordinate system to use for block shear
// See: https://www.w3.org/TR/2018/REC-ttml2-20181108/#style-attribute-shear
// however the spec shows examples of how different values are expected to be rendered.
// https://www.w3.org/TR/2018/REC-ttml2-20181108/#style-attribute-fontShear
// See: https://www.w3.org/TR/2018/REC-ttml2-20181108/#style-attribute-shear
// This maps the shear percentage to shear angle in graphics coordinates
// https://www.w3.org/TR/2018/REC-ttml2-20181108/#style-attribute-fontShear
regionOutput
.
setShearDegrees
((
resolvedStyle
.
getShearPercentage
()
*
-
90
)
/
100
);
// This maps the shear percentage to shear angle in graphics coordinates
regionOutput
.
setShearDegrees
((
resolvedStyle
.
getShearPercentage
()
*
-
90
)
/
100
);
}
if
(
resolvedStyle
.
getTextAlign
()
!=
null
)
{
regionOutput
.
setTextAlignment
(
resolvedStyle
.
getTextAlign
());
}
}
}
regionOutput
.
setTextAlignment
(
resolvedStyle
.
getTextAlign
());
}
}
}
}
...
...
library/core/src/test/java/com/google/android/exoplayer2/text/ttml/TtmlDecoderTest.java
View file @
e0c39ade
...
@@ -607,6 +607,14 @@ public final class TtmlDecoderTest {
...
@@ -607,6 +607,14 @@ public final class TtmlDecoderTest {
Cue
seventhCue
=
getOnlyCueAtTimeUs
(
subtitle
,
70_000_000
);
Cue
seventhCue
=
getOnlyCueAtTimeUs
(
subtitle
,
70_000_000
);
assertThat
(
seventhCue
.
text
.
toString
()).
isEqualTo
(
"No textAlign property"
);
assertThat
(
seventhCue
.
text
.
toString
()).
isEqualTo
(
"No textAlign property"
);
assertThat
(
seventhCue
.
textAlignment
).
isNull
();
assertThat
(
seventhCue
.
textAlignment
).
isNull
();
Cue
eighthCue
=
getOnlyCueAtTimeUs
(
subtitle
,
80_000_000
);
assertThat
(
eighthCue
.
text
.
toString
()).
isEqualTo
(
"Ancestor start alignment"
);
assertThat
(
eighthCue
.
textAlignment
).
isEqualTo
(
Layout
.
Alignment
.
ALIGN_NORMAL
);
Cue
ninthCue
=
getOnlyCueAtTimeUs
(
subtitle
,
90_000_000
);
assertThat
(
ninthCue
.
text
.
toString
()).
isEqualTo
(
"Not a P node"
);
assertThat
(
ninthCue
.
textAlignment
).
isNull
();
}
}
@Test
@Test
...
...
testdata/src/test/assets/media/ttml/text_align.xml
View file @
e0c39ade
...
@@ -24,5 +24,11 @@
...
@@ -24,5 +24,11 @@
<div>
<div>
<p
begin=
"70s"
end=
"78s"
>
No textAlign property
</p>
<p
begin=
"70s"
end=
"78s"
>
No textAlign property
</p>
</div>
</div>
<div>
<p
begin=
"80s"
end=
"88s"
tts:textAlign=
"start"
><span
tts:fontSize=
"50%"
>
Ancestor start
</span>
alignment
</p>
</div>
<div>
<p
begin=
"90s"
end=
"98s"
><span
tts:textAlign=
"start"
>
Not a P node
</span></p>
</div>
</body>
</body>
</tt>
</tt>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment