Skip to content

fix(player): draw Arabic subtitle text in a face that follows Font family - #1129

Merged
Quick104 merged 2 commits into
mainfrom
fix/arabic-subtitle-fonts
Dec 3, 2026
Merged

Quick104 merged 2 commits into
mainfrom
fix/arabic-subtitle-fonts

Conversation

@Quick104

@Quick104 Quick104 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

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.md records the source, license and steps, and the full license text ships as a raw resource.
  • ArabicSubtitleTypeface loads 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.applyAppearance builds 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 because SubtitleView draws all cues with one style, and Silo strips embedded spans.
  • The phone Settings, TV Settings and TV player-menu previews use the same helper, and the TV-only generic mapping it replaces is removed with its test.

Validation

  • Reproduced on API 36 phone and TV emulators against a Silo dev deployment, with an uploaded Arabic SRT on a generated test video. With the debug build of origin/main, Sans, Serif and Mono drew identical Arabic.
  • With this branch, Serif draws Noto Naskh Arabic UI, and Sans and Mono draw Noto Sans Arabic UI, on phone and TV. The cue box keeps its height and position: 136 px on the phone and 131 px on TV, before and after. With an Arabic app language, the phone Settings preview follows the choice too.
  • ./gradlew testDebugUnitTest and lint for :android-shared, :androidApp and :androidTvApp (debug and vital release) pass. The supply-chain self-test couldn't run locally (it needs Ruby). This change adds no Gradle dependencies.
  • The TV Settings and TV player-menu previews weren't captured. They call the same helper as the phone preview.

Evidence: https://evidence.siloserver.org/r/silo-android/pr-1129/

Risks

  • Latin inside an Arabic cue. The Arabic face has to be the cue's primary typeface; otherwise Android's locale-aware fallback picks the system Arabic font again when the interface is Arabic. Latin letters in an Arabic cue then come from Android's fallback for the app's language. With an English interface they keep the chosen family. With an Arabic interface and Serif or Mono, they draw in a proportional face, and spacing around ASCII punctuation can shift. Before Android 10 they draw in sans-serif. Latin-only cues are unchanged. Follow-up: Latin words in an Arabic subtitle cue lose the chosen font with an Arabic app language #1130.
  • Sans Arabic glyphs are wider than the system Naskh, so long Arabic lines wrap a little sooner.
  • The preview sample now draws at the player's Regular weight in an Arabic interface. The bundled faces have no bold, and before, the system's bold Arabic font answered the preview's SemiBold.
  • Persian, Urdu and other languages written in Arabic script also draw in these faces.

Council review

Background review: 2 rounds, last reviewed 4caccf3

Member Round 1 (9a73c7d) Round 2 (4caccf3)
Sol (gpt-6.2-sol, medium) 7/10 9/10, no findings
Opus (claude-opus-5-5, medium) 8/10 9/10, no findings
Gemini (gemini-4-neon, medium) 9.5/10, no findings 9.5/10, no findings

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

Member Round 1 Round 2
Sol better overall, 7/10 better, 8/10
Opus mixed, 7/10 better, 8/10
Gemini mixed, 6.5/10 better, 8/10

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

  • Harness: Claude Code in T3 Code
  • Tool(s): GitHub CLI; agent-device for emulator control; fontTools (pyftsubset) for the font subsets; ffmpeg for captures
  • Model(s): claude-opus-5-5; review members gpt-6.2-sol, claude-opus-5-5, gemini-4-neon
  • Involvement: Fully AI-generated; human verification pending
  • Adversarial review: a plan round before implementation, an xhigh code review across this and the paired web diff (an unused import removed and a threading note added here), a simplify pass, and the reviews in Council review above.

🤖 Generated with Claude Code

…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-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Dec 3, 2026
@silo-kody

silo-kody Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-03T12:26:46.511901Z 4caccf3 New commits
🔒 Security Review ✅ Completed 2026-12-03T12:28:52.259020Z 4caccf3 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changes add bundled Noto Arabic fonts for subtitle cues and previews. Arabic subtitle cues can use a face selected by the configured font family. Phone and TV previews use the same font-selection logic.

Changes: Arabic Subtitle Fonts

Layer / File(s) Summary
Bundled Arabic font selection
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/player/ArabicSubtitleTypeface.kt, THIRD_PARTY_NOTICES.md
ArabicSubtitleTypeface detects supported Arabic characters and selects a bundled face for Serif, Sans Serif, or Monospace. The notice records font provenance, licensing, subset ranges, and font adjustments.
Arabic subtitle cue styling
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/player/SubtitleManager.kt
SubtitleManager creates regular and optional Arabic caption styles. SubtitleVideoRectSync selects a style for each cue group and reapplies the current cues when its caption styles change.
Phone and TV font previews
androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/settings/SubtitleSettings.kt, androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/player/*, androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/settings/TvSettingsScreen.kt, androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/player/TvSubtitleAppearanceOptionsTest.kt
Phone and TV previews resolve the font family through ArabicSubtitleTypeface using the preview text and configured family. The TV-specific font mapping and its test are removed.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant SubtitleManager
  participant SubtitleVideoRectSync
  participant SubtitleCaptionStyles
  SubtitleManager->>SubtitleVideoRectSync: provide caption styles
  SubtitleVideoRectSync->>SubtitleCaptionStyles: select style for cue group
  SubtitleCaptionStyles-->>SubtitleVideoRectSync: return regular or Arabic style
  SubtitleVideoRectSync->>SubtitleVideoRectSync: apply style before forwarding cues
Loading

Possibly related issues

  • Silo-Server/silo-android#324: The changes use the configured font family for Arabic subtitle cues and previews on TV, which relates to the issue’s font-setting validation case.
  • Silo-Server/silo-android#323: The changes use the configured font family for Arabic subtitle cues and previews on phone, which relates to the issue’s font-setting validation case.

Suggested reviewers: rxwatcher, rhainland

Merge Risk: Minimal · up to 9a73c · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Security architecture risk: Minimal · up to 9a73c

Subtitle text can switch between local caption styles, but it cannot supply a font or change what the app is allowed to access. If a bundled font cannot load, captions still use the existing system font behavior.

Security review details

Security Blast Radius

  • inferred — Subtitle content can influence local rendering for the cue group being displayed, including other cues in a mixed group. It cannot grow the cache or trigger arbitrary font loads. The changed path does not transfer data or authority across accounts, services, or stores.

Trust Boundaries and Controls

  • observed — Cue text supplies only a Unicode-block match. Family settings select one of two fixed resource IDs through a three-value allowlist. Unsupported families return before cache access, and no cue text is used as a font name, path, URL, or cache key.

Data and control flow

  • observed — SubtitleManager builds styles from sanitized appearance settings. The existing cue forwarder checks the remapped group, selects a style, and passes the same group to SubtitleView. Previews instead check localized app sample text.

Resilience and Maintainability Implications

  • observed — Load exceptions or null results leave playback and previews on the generic path. A failed result is cached per family for the process lifetime, so a later preview or player attach does not retry that family; restarting the process permits a new attempt.
  • observed — Normal cue forwarding selects the style again for every group, so a later non-Arabic, empty, or bitmap-only group does not inherit an Arabic text style. Disposal removes the listener and clears the retained group; a replacement sync receives the current styles rather than reusing the disposed sync's cue history.

Rollout and rollback

  • inferred — The font behavior ships with the Android client. The diff adds no server-side enablement, stop control, or permission change. Reverting the client change restores generic font selection without a settings or data migration.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: Arabic subtitle text is drawn in a bundled face that follows the Font family setting. It matches the changeset, which adds ArabicSubtitleTypeface, per-cue-group Arabic…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description is specific and on-topic. It explains the Arabic subtitle font problem on Android, the bundled Noto Naskh and Noto Sans Arabic faces per setting, the per-cue-group switching, the previ…
Full details: Title check

Explanation

The title names the main change: Arabic subtitle text is drawn in a bundled face that follows the Font family setting. It matches the changeset, which adds ArabicSubtitleTypeface, per-cue-group Arabic styling in SubtitleManager, and shared preview font selection. The 'fix(player)' prefix is a conventional commit scope and does not hurt clarity. At 73 characters it is within a reasonable length.

Full details: Description check

Explanation

The description is specific and on-topic. It explains the Arabic subtitle font problem on Android, the bundled Noto Naskh and Noto Sans Arabic faces per setting, the per-cue-group switching, the preview helper, validation on API 36 emulators, and known risks. It matches the changeset files: ArabicSubtitleTypeface, SubtitleManager, the settings and TV previews, and THIRD_PARTY_NOTICES.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f8b2008a-f18f-43a4-acca-e38197ca6e76
Commits

Reviewing files that changed from the base of the PR and between 801955b and 9a73c7d.

Files ignored due to path filters: 2

  • android-shared/src/androidMain/res/font/noto_naskh_arabic_subtitle.ttf is excluded by !**/*.ttf
  • android-shared/src/androidMain/res/font/noto_sans_arabic_subtitle.ttf is excluded by !**/*.ttf
Files selected for processing: 8

  • THIRD_PARTY_NOTICES.md
  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/player/ArabicSubtitleTypeface.kt
  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/player/SubtitleManager.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/settings/SubtitleSettings.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/player/TvPlayerHud.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/player/TvSubtitleAppearanceOptions.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/settings/TvSettingsScreen.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/player/TvSubtitleAppearanceOptionsTest.kt
Files with no reviewable changes: 2

  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/player/TvSubtitleAppearanceOptions.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/player/TvSubtitleAppearanceOptionsTest.kt

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

@macroscopeapp

macroscopeapp Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

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:

  • Arabic subtitle preview in TV Settings (TvSettingsScreen.kt) — Android TV: add before-and-after screenshots of the same preview in the Arabic app locale.
  • Arabic subtitle preview in the TV player HUD (TvPlayerHud.kt) — Android TV: add before-and-after screenshots of the same preview in the Arabic app locale.

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 Quick104 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 =

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adversarial review (gpt-6.2-sol, reviewed 9a73c7d)

Comment thread THIRD_PARTY_NOTICES.md Resolved
Comment thread THIRD_PARTY_NOTICES.md
--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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Quick104 Quick104 Dec 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-triage silo-triage Bot added size/L 200–499 added + deleted lines (all files); change volume, not priority. and removed size/M 50–199 added + deleted lines (all files); change volume, not priority. labels Dec 3, 2026
@silo-kody

silo-kody Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104
Quick104 merged commit b15d2be into main Dec 3, 2026
10 checks passed
@Quick104
Quick104 deleted the fix/arabic-subtitle-fonts branch December 3, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L 200–499 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant