-
-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add subtitles font size and background configurations (#1303)
* Add subtitles font size and background configurations Added seekbar for choosing subtitles font size (18-38 range, keeping 28 by default) Added text outlining for better legibility and an option to disable the subtitles black background. * Fixes
- Loading branch information
1 parent
480a71d
commit eadf7b9
Showing
5 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
app/src/main/java/org/jellyfin/androidtv/ui/shared/OutlineSpan.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.jellyfin.androidtv.ui.shared | ||
|
||
import android.graphics.Canvas | ||
import android.graphics.Color | ||
import android.graphics.Paint | ||
import android.text.style.ReplacementSpan | ||
|
||
/** | ||
* A class that draws the outlines of a text | ||
*/ | ||
class OutlineSpan : ReplacementSpan() { | ||
override fun getSize( | ||
paint: Paint, | ||
text: CharSequence, | ||
start: Int, | ||
end: Int, | ||
fm: Paint.FontMetricsInt? | ||
): Int { | ||
if (fm != null) { | ||
fm.ascent = paint.fontMetricsInt.ascent | ||
fm.bottom = paint.fontMetricsInt.bottom | ||
fm.descent = paint.fontMetricsInt.descent | ||
fm.leading = paint.fontMetricsInt.leading | ||
fm.top = paint.fontMetricsInt.top | ||
} | ||
|
||
return paint.measureText(text, start, end).toInt() | ||
} | ||
|
||
override fun draw( | ||
canvas: Canvas, | ||
text: CharSequence, | ||
start: Int, | ||
end: Int, | ||
x: Float, | ||
top: Int, | ||
y: Int, | ||
bottom: Int, | ||
paint: Paint | ||
) { | ||
|
||
val strokePaint = paint.apply { | ||
color = Color.BLACK | ||
style = Paint.Style.STROKE | ||
strokeWidth = 4f | ||
} | ||
canvas.drawText(text, start, end, x, y.toFloat(), strokePaint) | ||
|
||
val fillPaint = paint.apply { | ||
color = Color.WHITE | ||
style = Paint.Style.FILL | ||
} | ||
canvas.drawText(text, start, end, x, y.toFloat(), fillPaint) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters