Repository navigation
fix(player): draw Arabic subtitle text in a face that follows Font family - #1129
Conversation
…mily Media3 drew text cues in the system generic for the Font choice, and the generics carry no Arabic, so Arabic letters always came from the device's own Arabic fallback: the same face for Sans, Serif and Mono, and a different one per device. A cue group with Arabic letters now draws in a bundled face for the choice (Noto Naskh Arabic for Serif, Noto Sans Arabic otherwise); other cues keep the generic and its line height. The phone and TV settings previews and the TV player preview use the same face when their sample line is Arabic. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
The PR now links private evidence, which counts as evidence; I cannot inspect the page. It should let reviewers verify playback on Android phone, tablet, foldable folded and open, and Android TV; the phone Settings preview on phone, tablet, and foldable folded and open; and both TV previews on Android TV. The description says the TV previews were not captured, so these visible changes still lack evidence:
Suggested fix: add these two screenshot pairs to the linked evidence page. Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence Posted via Macroscope — Visible change evidence |
Quick104
left a comment
There was a problem hiding this comment.
Adversarial review (claude-opus-5-5, reviewed 9a73c7d)
One finding, inline. I checked the rest and it holds up: both callers of applyAppearance (phone PlayerScreen, TvPlayerScreen) pass through the sync that picks the style per cue group. A sync built later inherits captionStyles. The appearance-then-styles re-forward ends on the right style. Load failures fall back to the generic. The three previews pass their own sample text. I found nothing to cut: setApplyEmbeddedStyles(false) strips spans, so switching styles per group is the smallest route Media3 allows.
| val text: CaptionStyleCompat, | ||
| val arabic: CaptionStyleCompat?, | ||
| ) { | ||
| fun forCues(cues: List<Cue>): CaptionStyleCompat = |
There was a problem hiding this comment.
O1 (low, test coverage). Nothing tests the new behavior. The diff adds no tests and deletes the TV preview-mapping test without a replacement, so "unit tests pass" only says that existing behavior is unchanged.
Trigger: a later change to forCues, appliesTo's ranges, or the captionStyles re-forward, for example comparing with == or dropping the setStyle before setCues.
Impact: Arabic cues would quietly go back to the system fallback, or a Latin cue after an Arabic one would keep the Arabic face. No test would fail. This is the bug the PR fixes.
Evidence: git grep at head finds no test that references ArabicSubtitleTypeface, forCues or captionStyles.
Repair: in SubtitleManagerAppearanceTest, add a Robolectric case that sends an Arabic cue group and then a Latin one. Assert that the SubtitleView style's typeface is the Arabic face and then the generic. Add a pure test for appliesTo (Arabic, Persian letter, Latin, null) and one that maps previewFontFamily to the three generics for Latin text, which replaces the deleted TV test.
There was a problem hiding this comment.
Leaving this without new tests. silo-android AGENTS.md says "Do not add tests for small changes or UI changes unless requested", and limits shared-logic tests to critical or high-risk behavior. This change picks a typeface for drawing, and the phone and TV captures linked in the description show it, cue by cue, for all three Font choices. The deleted test covered a three-way constant mapping that now lives in the shared helper.
| --layout-features='*' --name-IDs='*' --name-languages='*' --output-file=<name>.ttf | ||
| ``` | ||
|
|
||
| The subsets then have their line metrics set to the Android system generics' (hhea and OS/2 typo ascender 928, descender −244, line gap 0) and their `head` bounds to yMax 1056, yMin −271 (saved without recalculating bounds), so an Arabic subtitle keeps the line height it had when the system's Arabic font drew it. |
There was a problem hiding this comment.
S2 [P2] Preserve the fonts’ actual glyph bounds. The new headers declare yMin −271 and yMax 1056, but the Sans outline for U+0777 descends to −512 and the Naskh outline for U+06DD reaches 1191. Media3 sizes the Box background from the padded text layout, so glyphs can extend outside the advertised bounds even when the measured box height stays the same. Recalculate the head bounds and check Box rendering with tall and deep glyphs before choosing the line metrics.
There was a problem hiding this comment.
Keeping this. Before the change, the same Arabic glyphs came from the system fallback and were laid out with the system generic's bounds (Roboto: 1056/−271), with the same tall marks reaching past them. The new header reproduces that layout on purpose. With the line metrics already matched but the fonts' real bounds, the phone's Arabic cue box measured 149 px against 136 px before, because Media3 pads the text layout from the font bounds. With these bounds it is 136 px on the phone and 131 px on TV, before and after. The before and after captures show the same rendering, with no clipped glyphs. head bounds only feed that padding; glyph outlines still draw in full.
…yles The OFL requires its full text with each copy of the fonts, so both apps now carry it as a raw resource the shrinker keeps. The cue forwarding sets the caption style only when the group needs a different one, since setStyle re-renders the cues on screen. The Arabic check counts the reversed comma and semicolon the fonts draw, and no longer lets a lone Arabic Letter Mark switch a Latin cue's face. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Problem
Subtitle style › Font (Sans, Serif, Mono) makes no difference to Arabic SRT and WebVTT subtitles on Android phones and Android TV. Media3 draws text cues in the system generic for the choice, and none of the generics carries Arabic, so every choice draws Arabic letters in the device's own Arabic fallback font. On stock Android that is Noto Naskh Arabic for all three choices; other manufacturers ship different faces, so the same setting looks different on each phone and TV box. The settings previews have the same problem when the app language is Arabic, because their sample line is then Arabic.
This change bundles an Arabic face for each choice: Noto Naskh Arabic for Serif, Noto Sans Arabic for Sans and Mono (Arabic has no monospaced style). A cue group with Arabic letters draws in that face; every other cue keeps the system generic.
Pairs with Silo-Server/silo-server#5822 (the same change in the web player).
Validation tasks: changes #323 C1, C4; changes #324 C1, C4 (not run yet)
Other clients: Web Silo-Server/silo-server#5822; Apple Silo-Server/silo-apple#1348; Roku N/A (Roku draws subtitles with the system caption style)
Approach
android-shared/res/font/gets subsets of Noto Sans Arabic UI 2.011 and Noto Naskh Arabic UI 2.017 (about 285 KB together). Each is cut to the Arabic code points the web player uses, so it carries no Latin glyphs. Their line metrics and bounds are set to the system generics', so an Arabic cue keeps exactly the height it had.THIRD_PARTY_NOTICES.mdrecords the source, license and steps, and the full license text ships as a raw resource.ArabicSubtitleTypefaceloads the face for a family, cached, and falls back to the system generic if loading fails. From Android 10 the face falls back to the chosen generic, so Latin words inside an Arabic cue keep that family. Before Android 10 they fall back to the system sans.SubtitleManager.applyAppearancebuilds the normal caption style and an Arabic variant. The cue forwarding picks the Arabic variant for any cue group with Arabic letters, so Latin-only cues keep the generic's glyphs and line height. A per-group choice is needed becauseSubtitleViewdraws all cues with one style, and Silo strips embedded spans.Validation
origin/main, Sans, Serif and Mono drew identical Arabic../gradlew testDebugUnitTestand lint for:android-shared,:androidAppand:androidTvApp(debug and vital release) pass. The supply-chain self-test couldn't run locally (it needs Ruby). This change adds no Gradle dependencies.Evidence: https://evidence.siloserver.org/r/silo-android/pr-1129/
Risks
Council review
Background review: 2 rounds, last reviewed 4caccf3
Fixed after round 1: the full OFL text now ships with the fonts; the caption style is set only when it changes; the Arabic check counts the two reversed punctuation marks the fonts draw and ignores a lone Arabic Letter Mark. Answered: the fonts' bounds match the system generic's on purpose, so Arabic cue height is unchanged; no new tests, per AGENTS.md.
Visual review: 2 rounds, captures before on 801955b and after on this branch
Fixed after round 1: Arabic cue boxes grew about 20% taller (line metrics now match the generics), and the preview pill grew with them. Answered: wide word gaps under Mono are unchanged from before. The mixed-cue behavior under an Arabic interface is the limitation under Risks, accepted by the maintainer. Plan round (Sol, Opus, Gemini on 801955b): per-group switching instead of one Arabic-first typeface for all cues, so Latin cues keep their line height; the three previews added; font load failures fall back to the system font.
AI Disclosure
pyftsubset) for the font subsets; ffmpeg for capturesclaude-opus-5-5; review membersgpt-6.2-sol,claude-opus-5-5,gemini-4-neon🤖 Generated with Claude Code