libass Font Setup

WangBin edited this page Jan 13, 2016 · 7 revisions

libass should work for desktop and mobile devices now with the correct font setup.


appFontsDir: QStandardPaths::writableLocation(QStandardPaths::DataLocation)+"/fonts" or QDesktopServices::storageLocation(QDesktopServices::DataLocation)+"/fonts". The value may vary from different Qt versions.

fontsDir: QStandardPaths::standardLocations(QStandardPaths::FontsLocation).first() or QDesktopServices::storageLocation(QDesktopServices::FontsLocation). Usually it's system fonts dir and not writable

Default Font and Fonts Dir Look Up

  • executable_dir/fonts
  • "assets:/fonts" (will copy to appFontsDir to let libass read)
  • qrc ":/fonts" (will copy to appFontsDir to let libass read)
  • appFontsDir
  • fontsDir

If fonts dir contains "default.ttf", it will be the default font if default font is not set.

If fonts dir contains to many font files, the lookup speed will slow down.

WinRT: fonts dir is ignored because calling ass_set_fonts_dir() with an valid fonts dir can cause crash

Disable Font Provider

If there is a default font set, it's able to use the font and disable font provider (for example fontconfig). Disabling font provider will skip font cache generating(fontconfig), font lookup and speed up the font load. The effect is notable on windows and android(no other device tested, but should be the same).

Force Font File

If fonts dir is available or default font is not set, the font lookup may be slow. Set a default font and SubtitleProcessorLibASS.setFontFileForced(true) can speed up font load.

  • QML API:

    Subtitle.fontFile and Subtitle.fontFileForced

  • C++ API:

    SubtitleFilter.setFontFile(const QString&) and SubtitleFilter.setFontFileForced(bool)

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.