Skip to content

Fix font loading when attachments precede tracks in MKV#63

Open
edde746 wants to merge 1 commit intopeerless2012:masterfrom
edde746:master
Open

Fix font loading when attachments precede tracks in MKV#63
edde746 wants to merge 1 commit intopeerless2012:masterfrom
edde746:master

Conversation

@edde746
Copy link

@edde746 edde746 commented Feb 28, 2026

Fixes #19. Font attachments embedded in MKV files were not loaded when the Attachments EBML element appeared before the Tracks element in the file. The Matroska specification does not enforce a fixed order for top-level elements, so parsers must handle either arrangement.

The extractor previously guarded font loading with hasTracks(), which returned false if no subtitle track had been discovered yet. Since ExtractorInput is a streaming interface, skipped font data cannot be re-read — the fonts were permanently lost.

Changes

Fonts encountered before any ASS track are now buffered in AssHandler and flushed to libass when the first track is created. Lazy initialization of the native library is preserved — if no ASS tracks exist, libass is never loaded.

  • AssHandler.kt - added pendingFonts buffer, addFont() method, flush in createTrack()
  • AssMatroskaExtractor.kt - removed hasTracks() guard, delegates to assHandler.addFont()

Before / After

Before After
before after

Ignore overlay on the 2nd image, font difference is especially noticeable on the episode title.

Nyaa ID for example is 1856654.

This PR was developed with AI assistance (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fonts attachments not work when they are at end of mkv

1 participant