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] Add support to font collection (.ttc) #23429

Merged
merged 1 commit into from Jun 26, 2023

Conversation

CastagnaIT
Copy link
Collaborator

@CastagnaIT CastagnaIT commented Jun 22, 2023

Description

This PR add support to use font collection (.ttc) to subtitles
since .ttc contains more fonts, we need to inspect the file to get family name of each font

this format is already supported in to libass renderer but we have not allowed his use
that lead to the problem with mkv's where user opened issue

this code change

  • fix the problem that mkv was not extracting .ttc files
  • allow load .ttc from the "fonts" folder to allow show each font contained, in the subtitles fonts list setting menu

the results in the fontcache.xml will be as follow:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<fonts>
    <font>
        <filename>DFMrg9.ttc</filename>
        <familyname>DFGMaruGothic-SB</familyname>
        <familyname>DFMaruGothic-SB</familyname>
        <familyname>DFPMaruGothic-SB</familyname>
    </font>
    <font>
        <filename>Helvetica.ttc</filename>
        <familyname>.Helvetica Light</familyname>
        <familyname>Helvetica</familyname>
    </font>
    <font>
        <filename>wqy-microhei.ttc</filename>
        <familyname>WenQuanYi Micro Hei</familyname>
        <familyname>WenQuanYi Micro Hei Mono</familyname>
    </font>
</fonts>

NOTE 1: the DFMrg9.ttc file on zip below contains multiple font familynames for different architectures on each font,
but for some reason to me unknown with this particular fonts kodi is not able to convert the familyname enoceded "macintosh" to uft8, i tried use fontforge to check fonts, but i have not found problems and i have no idea where is the problem (could be also on freetype library). So for now i prioritized the family name set for MS/APPLE platforms then use MAC as fallback, in this way we can workaround it.

NOTE 2: i add fontfamily name selection from "english" field that should be always filled, this for two reasons, prevent possible problems of "tofu" chars appears in the GUI font list, kodi dont support multilanguage GUI, and avoid add a encoding mapping to decode each language with iconv, if there will be problems on particular use cases it will be addressed when reported

Motivation and context

fix #23402

How has this been tested?

tested mkv provided in the issue that embed an ass subtitle + fonts
tested .ttc fonts with srt subtitles by using fonts on zip Fonts.zip

What is the effect on users?

Allow users to use .ttc files and display font correctly

Screenshots (if appropriate):

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

@CastagnaIT CastagnaIT added Type: Feature non-breaking change which adds functionality Type: Fix non-breaking change which fixes an issue Component: Subtitles v21 Omega labels Jun 22, 2023
@CastagnaIT CastagnaIT added this to the Omega 21.0 Alpha 3 milestone Jun 22, 2023
@scott967
Copy link
Contributor

From what I can find in specs there isn't a difference in tables between .ttc and .otc font collections. Any reason not to include .otc?

@CastagnaIT
Copy link
Collaborator Author

for me no problem add it, but are you able to find at least one .otc file to make test?

Copy link
Member

@enen92 enen92 left a comment

Choose a reason for hiding this comment

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

Codewise I can't figure out anything to nitpick now, the versioning was my only concern.

Copy link
Member

@neo1973 neo1973 left a comment

Choose a reason for hiding this comment

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

Looks good, just some minor suggestions.

xbmc/guilib/GUIFontManager.cpp Outdated Show resolved Hide resolved
xbmc/utils/FontUtils.h Outdated Show resolved Hide resolved
@scott967
Copy link
Contributor

I did some hunting for ".otc" collections, and it seems like using the ".ttc" extension appears to be the convention. Per Adobe, the tables in the collection need to be checked to determine if the fonts are ttf or otf (ttf will have 'glyf' tables). So I don't think it is worth the effort to worry about otc. I did build a couple of otf font collections using Adobe Font Development Kit for OpenType following the 2 examples provided, but not sure it's worth looking at them. If you are interested anyway here are the files:

https://mega.nz/file/PapUxRRL#Y_Fv9nIUldgPJ43XOHvbfbjp7sESg6SQDfrS2x5sJpA
https://mega.nz/file/yXQghaxI#c6atA700EKcJlO5Oh6mXwFENuK-MkfI37tdNaLYTS94

@CastagnaIT
Copy link
Collaborator Author

out of curiosity i tried both .otc attached but fontforge and also libass are not able to load glyphs

@CastagnaIT
Copy link
Collaborator Author

please wait to merge this
i want try investigate better also for #23300 that if needed i will improve some code

@CastagnaIT
Copy link
Collaborator Author

all ok ready to merge

@enen92 enen92 linked an issue Jun 26, 2023 that may be closed by this pull request
7 tasks
@enen92 enen92 merged commit 6e76825 into xbmc:master Jun 26, 2023
2 checks passed
@CastagnaIT CastagnaIT deleted the ttc_support branch June 27, 2023 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Subtitles Type: Feature non-breaking change which adds functionality Type: Fix non-breaking change which fixes an issue v21 Omega
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A font that doesn't work in 20.1 but works in 19.5 (Android)
4 participants