Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Subtitles][ASS] Support both user defined fonts and extracted fonts #19535

Merged
merged 1 commit into from Apr 10, 2021

Conversation

enen92
Copy link
Member

@enen92 enen92 commented Apr 8, 2021

Description

This PR improves font handling for ASS subtitles. In kodi we allow users to add new fonts for subtitles (see 5.1 in https://kodi.wiki/view/Subtitles) by placing them into .kodi/media/Fonts. When using external subtitles that require the use of external fonts, the user should be able to place the fonts there for kodi/libass to find and use.

The main issue here is that libass only supports a single folder for storing additional fonts (see ass_set_fonts_dir) and we currently use the temp folder (.kodi/temp/Fonts) - the demuxer is configured to extract fonts to this directory (for muxed subs).

Due to the limitation, this PR changes the implementation and makes the demuxer extract subtitles to the user font directory by appending a known prefix to the files "tmp.font.*. This prefix is later used to cleanup temporary files, just like today (ClearTempFonts). This way we can support external fonts for subtitles and muxed fonts with libass.

Motivation and Context

Improve font handling for ASS subtitles. Feature pairity between ASS and other subtitle formats (so that we can work towards a future conversion).
Fixes #16209

How Has This Been Tested?

This was runtime tested on Linux, Android (TV), Windows and OSX with the samples available on the team ftp server. Furthermore, external subtitles (with missing fonts) were tested using the sample provided in https://forum.kodi.tv/showthread.php?tid=361545&pid=3024983#pid3024983

Screenshots (if appropriate):

Before (segoeprb.ttf in media/Fonts):
alt text

After (segoeprb.ttf in media/Fonts)
alt text

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Clean up (non-breaking change which removes non-working, unmaintained functionality)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that will cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • None of the above (please explain below)

Checklist:

  • My code follows the Code Guidelines of this project
  • My change requires a change to the documentation, either Doxygen or wiki
  • I have updated the documentation accordingly
  • I have read the Contributing document
  • I have added tests to cover my change
  • All new and existing tests passed

@enen92 enen92 added Type: Fix non-breaking change which fixes an issue Type: Improvement non-breaking change which improves existing functionality v19 Matrix Component: Subtitles labels Apr 8, 2021
@enen92 enen92 added this to the N* 20.0 Alpha 1 milestone Apr 8, 2021
@enen92 enen92 requested a review from phunkyfish April 8, 2021 09:15
@enen92
Copy link
Member Author

enen92 commented Apr 8, 2021

Jenkins build this please

@phunkyfish
Copy link
Contributor

jenkins build this please

Copy link
Contributor

@phunkyfish phunkyfish left a comment

Choose a reason for hiding this comment

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

Just some minors.

xbmc/Util.cpp Outdated Show resolved Hide resolved
xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitlesLibass.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@phunkyfish phunkyfish left a comment

Choose a reason for hiding this comment

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

LGTM

@enen92
Copy link
Member Author

enen92 commented Apr 10, 2021

Jenkins build and merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backport: Done Component: Subtitles Type: Fix non-breaking change which fixes an issue Type: Improvement non-breaking change which improves existing functionality v20 Nexus Wiki: Done
Projects
None yet
Development

Successfully merging this pull request may close these issues.

External ASS subtitles with custom fonts always display with default font
5 participants