feat(font): add memory font registry and fallback support - #67
Conversation
f8b65bf to
d4e849e
Compare
Shinokawa
left a comment
There was a problem hiding this comment.
Found one correctness issue in ASS memory-font cache invalidation.
Shinokawa
left a comment
There was a problem hiding this comment.
The memory-font revision fix looks right, and the regression test covers it. Thanks.
Blocking on something else: the Merge branch 'main' commit (303ddb4) resolved conflicts in favour of the branch and dropped code that is on main. e2e2099 put the debug_hud field and its two accessors back so erika_capi compiles, but the features themselves are gone — git diff origin/main...HEAD -- crates/erika/src/presenter.rs is +423/-1047, and none of these exist anywhere in the branch any more:
debug_hud_snapshotand the HUD render path (d408842) —debug_hudis now a dead field, enabling the HUD draws nothingrefresh_video_decoder_status(d3e45aa)trace_current_danmaku_motion,danmaku_motion_backstep,DanmakuMotionSample(dc64ae8)retain_danmaku_state_for_config_change,danmaku_viewport_requires_relayout,bump_danmaku_generation_for_config_change,invalidate_current_danmaku_plan,set_paint_config(7e27c80)- roughly 11 tests that went with them, including
screenshot_capture_context_omits_danmakuandCaptureCompositionProbe
CI is green because the call sites were removed along with the definitions, so nothing fails to compile.
Could you redo the merge from current main and reapply only the font changes on top? A quick check before pushing: git diff origin/main...HEAD -- crates/erika/src/presenter.rs should contain no deletions outside the font/subtitle paths.
The subtitle style and memory font registry work reintroduced platform cfg lists without `target_env = "ohos"`, which OpenHarmony needs (its `target_os` is `linux`). That left the whole new API surface — `set_subtitle_font`, `set_subtitle_style`, the `*_subtitle_memory_font*` entry points, their `*_to_c` helpers and `set_output_headroom` — either undefined on OpenHarmony or defined twice alongside its stub. Restores the predicate so every impl/stub pair is an exact complement again. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…clear() After memory fonts are installed, switching to another ASS track calls clear() which left memory_font_revision unchanged. process_frame() then created a new renderer without memory fonts, while render() saw the old revision as current and skipped the rebuild. Reset memory_font_revision to 0 in clear() so render() detects the mismatch and rebuilds with the current memory-font snapshot.
… ass_set_fonts Extended LibassFontSelection with memory_family so configure_style can cache the full font selection (family, default_font, memory_family) and skip ass_set_fonts when nothing changed. This prevents redundant font selector rebuilds on every play_res_height / font_scale / style change.
a52cf11 to
78bd1a5
Compare
Important
This PR is stacked on top of the subtitle style PR and is not ready to merge independently.
Please review and merge the feat/subtitle-style PR first. Once that lands, this branch will be rebased onto the target repository's latest default branch so this PR contains only the font registry and danmaku changes.
Summary
This PR splits the font registry and danmaku font work out of the subtitle style PR.
It adds validated custom font loading, preserves TTC/OTC face indices, and introduces a per-presenter in-memory font registry shared by subtitle and danmaku rendering.
The base branch is
feat/subtitle-style, so this PR only contains the two font-specific commits:d880c71 fix(font): validate custom fonts and preserve face indexf8b65bf feat(font): add memory font registry and fallbacksCustom font validation
TTC/OTC support
fontdb.Memory font registry
Each presenter now owns an isolated memory font registry.
The registry supports:
Resource limits:
Subtitle integration
ass_add_font.Danmaku integration
C API
Adds APIs for:
The status and info APIs include matching release functions for dynamically allocated result data.
Flutter
Adds:
The APIs are bridged on Android, iOS, macOS, and Windows. This allows fonts from Flutter assets or application-managed storage to be registered without exposing a platform-private font path to the Rust core.
Apple platforms
This PR does not change the Apple/libass font-provider strategy.
On recent Apple systems, applications cannot access system-private font directories directly. The memory registry supplements the existing behavior with fonts supplied by the application, such as Flutter assets, user-installed fonts, downloaded fonts, and fonts stored in the application bundle or sandbox.
Verification
cargo fmt --all -- --checkcargo test -p erika --libcargo test -p erika_capi --libcargo check -p erika --no-default-features --features libass,wgpuflutter testflutter analyzegit diff --checkAdditional regression coverage includes: