mpv icon indicating copy to clipboard operation
mpv copied to clipboard

`sub-fonts-dir` doesn't work correctly

Open akiirui opened this issue 1 year ago • 4 comments

mpv Information

mpv v0.39.0 Copyright © 2000-2024 mpv/MPlayer/mplayer2 projects
 built on Nov 27 2024 18:31:26
libplacebo version: v7.349.0
FFmpeg version: n7.1
FFmpeg library versions:
   libavcodec      61.19.100
   libavdevice     61.3.100
   libavfilter     10.4.100
   libavformat     61.7.100
   libavutil       59.39.100
   libswresample   5.3.100
   libswscale      8.3.100

Other Information

- Linux version: Arch Linux
- Kernel Version: Linux akii 6.12.3-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 06 Dec 2024 11:15:43 +0000 x86_64 GNU/Linux
- GPU Model: AMD Radeon RX 7900XTX
- Mesa/GPU Driver Version: 24.3.1
- Window Manager and Version: GNOME mutter 47.3
- Source of mpv: Arch Linux repository
- Latest known working version: 0.38.0
- Issue started after the following happened: Update mpv to 0.39.0

Reproduction Steps

  1. Save a subtitle file to the folder Subs, it in the same directory as the video file.
  2. Save some fonts to the folder Fonts, it in the same directory as the video file.
  3. Run mpv --no-config --sub-auto=fuzzy --sub-file-paths=Subs --sub-fonts-dir=Fonts 'VIDEO_PATH' in terminal (pwd doesn't in the directory of the video file)
  4. MPV doesn't load fonts from the Fonts folder.

Expected Behavior

MPV loads fonts from the folder Fonts like loads subtitles from the folder Subs.

Actual Behavior

MPV loads subtitles from the folder Subs, but it doesn't load fonts from the folder Fonts

Log File

in-video-folder.txt not-in-video-folder.txt

Sample Files

No response

I carefully read all instruction and confirm that I did the following:

  • [X] I tested with the latest mpv version to validate that the issue is not already fixed.
  • [X] I provided all required information including system and mpv version.
  • [X] I produced the log file with the exact same set of files, parameters, and conditions used in "Reproduction Steps", with the addition of --log-file=output.txt.
  • [X] I produced the log file while the behaviors described in "Actual Behavior" were actively observed.
  • [X] I attached the full, untruncated log file.
  • [X] I attached the backtrace in the case of a crash.

akiirui avatar Dec 08 '24 13:12 akiirui

Looks like libass loads it according to the in-video-folder log.

[   0.059][v][sub/ass] Loading font file 'Fonts/FOT-DNPShueiGoGinStd-B.otf'
[   0.060][v][sub/ass] Loading font file 'Fonts/FOT-MatisseProN-B.otf'
[   0.063][v][sub/ass] Loading font file 'Fonts/FOT-NewCezanneProN-DB.otf'
[   0.064][v][sub/ass] Loading font file 'Fonts/FOT-SeuratProN-B.otf'
[   0.066][v][sub/ass] Loading font file 'Fonts/FOT-SkipProN-B.otf'
[   0.068][v][sub/ass] Loading font file 'Fonts/FOT-TsukuMinPr6N-D.otf'
[   0.073][v][sub/ass] Loading font file 'Fonts/FZLanTingHei-DB-GBK.TTF'
[   0.075][v][sub/ass] Loading font file 'Fonts/FZLanTingHei-DB1-GBK.TTF'
[   0.076][v][sub/ass] Loading font file 'Fonts/FZLanTingHei-H-GBK.TTF'
[   0.077][v][sub/ass] Loading font file 'Fonts/FZLanTingYuan-DB1-GBK.ttf'
[   0.081][v][sub/ass] Loading font file 'Fonts/FZZhengHei-DB-GBK.ttf'
[   0.081][v][sub/ass] Loading font file 'Fonts/HYQiHei-65S.ttf'
[   0.083][v][sub/ass] Loading font file 'Fonts/HYXuanSong55S.ttf'
[   0.091][v][sub/ass] Loading font file 'Fonts/HYXuanSong65S.ttf'
[   0.099][v][sub/ass] Loading font file 'Fonts/HYXuanSong75S.ttf'
[   0.107][v][sub/ass] Loading font file 'Fonts/HYXuanSong85S.ttf'

What's the problem exactly?

Dudemanguy avatar Jan 26 '25 04:01 Dudemanguy

@Dudemanguy I cannot reproduce this issue now, thanks for the reply.

akiirui avatar Jan 26 '25 04:01 akiirui

@Dudemanguy Sorry, I forgot a condition when reproducing this problem. The problem can still be reproduced in my environment.

When the working folder of the shell doesn't in-video-folder, I cannot load fonts from the "Fonts" folder, like this:

$ pwd
/home/rui

$ mpv --no-config --sub-auto=fuzzy --sub-file-paths=Subs --sub-fonts-dir=Fonts /run/media/temp/Anime/Isekai\ Ojisan\ \[Ma10p_1080p\]/*.mkv
Playing: /run/media/temp/Anime/Isekai Ojisan [Ma10p_1080p]/Isekai Ojisan [01][Ma10p_1080p][x265_flac_aac].mkv
 ● Video  --vid=1               (hevc 1920x1080 23.976 fps) [default]
 ● Audio  --aid=1  --alang=jpn  'Main Audio' (flac 2ch 48000 Hz) [default]
 ○ Audio  --aid=2  --alang=jpn  'Commentary' (aac 2ch 48000 Hz)
 ● Subs   --sid=1  --slang=sc   'Isekai Ojisan [01][Ma10p_1080p][x265_flac_aac].sc.ass' (ass) [external]
 ○ Subs   --sid=2  --slang=tc   'Isekai Ojisan [01][Ma10p_1080p][x265_flac_aac].tc.ass' (ass) [external]
AO: [pipewire] 48000Hz stereo 2ch s32
VO: [gpu] 1920x1080 yuv420p10
[sub/ass] fontselect: Using default font family: (Droid Sans Fallback, 700, 0) -> /usr/share/fonts/TTF/Roboto-Bold.ttf, 0, Roboto-Bold
[sub/ass] fontselect: Using default font family: (方正基础像素, 700, 0) -> /usr/share/fonts/TTF/Roboto-Bold.ttf, 0, Roboto-Bold
AV: 00:07:26 / 00:23:42 (31%) A-V: -0.001
Exiting... (Quit)

$ eza -l /run/media/temp/Anime/Isekai\ Ojisan\ \[Ma10p_1080p\]/Fonts/
.rwxr-xr-x 3.2M rui 16 Apr  2019 'Droid Sans Fallback.ttf'
.rwxr-xr-x  10M rui 30 Oct  2013 'FOT-Matisse ProN DB.otf'
.rwxr-xr-x 3.5M rui 11 Oct  2020 'FZFW ZhenZhuTiJF L.TTF'
.rwxr-xr-x 9.9M rui 14 Feb  2020 FZYaSong-H-GBK.ttf
.rwxr-xr-x  17M rui 11 Oct  2018 '微软雅黑 Semibold & Microsoft YaHei UI Semibold.ttc'
.rwxr-xr-x  16M rui 29 Mar  2012 方正像素字体.ttf
.rwxr-xr-x 7.6M rui  3 Mar  2018 方正兰亭中黑_GBK.ttf
.rwxr-xr-x 7.7M rui  3 Mar  2018 方正兰亭粗黑_GBK.ttf
.rwxr-xr-x 7.7M rui  4 Jan  2021 方正兰亭细黑_GBK.ttf
.rwxr-xr-x 7.7M rui  3 Mar  2018 方正兰亭黑_GBK.ttf
.rwxr-xr-x 9.9M rui  4 Apr  2006 方正准圆_GBK.TTF
.rwxr-xr-x  11M rui  4 Mar  2018 方正准雅宋_GBK.ttf
.rwxr-xr-x  14M rui  3 Mar  2018 方正楷体_GBK.ttf
.rwxr-xr-x  19M rui  5 Mar  2018 方正硬笔楷书_GBK.ttf
.rwxr-xr-x 3.7M rui 10 Mar  2018 方正粗倩_GBK.ttf
.rwxr-xr-x 9.7M rui 19 May  2020 方正粗圆_GBK.TTF
.rwxr-xr-x  11M rui  4 Mar  2018 方正粗雅宋_GBK.ttf
.rwxr-xr-x 7.7M rui  6 Mar  2018 方正行楷_GBK.ttf
.rwxr-xr-x  14M rui  3 Mar  2018 方正隶变_GBK.ttf

But I haven't permission to reopen this issue.

akiirui avatar Jan 26 '25 04:01 akiirui

I can confirm this behavior is still present.

I encountered this issue while using Celluloid 0.29 (Flathub version, based on libmpv 0.40.0).

The Setup

  • I have sub-fonts-dir=fonts defined in my mpv.conf.
  • The directory containing the video file definitely has a fonts subdirectory.
  • This subdirectory contains all the specific fonts referenced by the video's .ass subtitle tracks.
  • I am opening the entire parent directory (not just the individual file) to ensure the path context is correct.

The Issue

Despite this configuration, playback falls back to the system's default fonts. This indicates that the sub-fonts-dir=fonts parameter is failing to take effect entirely. My logs confirm this diagnosis: mpv fails to locate the specific fonts required by the .ass file and defaults to system fonts instead.

The Workaround

Interestingly, I was able to solve this by adding the following Lua script to my player. It forces the .ass subtitles to correctly identify and load fonts from the fonts folder:

https://github.com/fbriere/mpv-scripts/blob/master/scripts/sub-fonts-dir-auto.lua

Since this issue has been open for nearly a year without an upstream fix or response regarding the broken sub-fonts-dir parameter, I wanted to share this script as a temporary workaround for anyone else struggling with this problem.

NekoCompiler avatar Dec 17 '25 07:12 NekoCompiler