Custom Font for subtitles in CLI

Anything and everything to do with DCP-o-matic.
kristophm
Posts: 5
Joined: Mon Jan 29, 2024 8:44 pm

Custom Font for subtitles in CLI

Post by kristophm »

Hi there! I've been using the DCP-O-Matic CLI interface for creating DCPs. Now I'm trying to use `dcpomatic2_create` to create a DCP with subtitles like the following:

```
dcpomatic2_create -o low2 --container-ratio 185 -c FTR -n "Low2" low.mp4 output.ass
```

The output.ass file specifies a font "Courier New" as the `Fontname` property, yet when I render the DCP, it uses the default sans-serif font instead of using the one I specified. Is it possible to define custom styling in the ASS file when using the CLI (not the desktop app)?

I'm on the MacOS X operating system, but was probably going to run this on my Linux machine if I could get this working properly.

Thanks in advance!

- Kristoph

PS. The first few lines of the output.ass file:

```
[Script Info]
; Script generated by FFmpeg/Lavc60.31.102
ScriptType: v4.00+
PlayResX: 384
PlayResY: 288
ScaledBorderAndShadow: yes
YCbCr Matrix: None

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Courier New,24,&H0000FF,&Hffffff,&H000000,&H000000,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,1

[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:17.65,0:00:18.31,Default,,0,0,0,,Hello, Mr.
Dialogue: 0,0:00:18.45,0:00:18.93,Default,,0,0,0,,Snail.
Dialogue: 0,0:00:19.21,0:00:21.73,Default,,0,0,0,,Oh, you cute little corny\Naspersome.
Dialogue: 0,0:00:22.73,0:00:23.33,Default,,0,0,0,,Latin name.
Dialogue: 0,0:00:23.59,0:00:24.47,Default,,0,0,0,,Bonus points.
Dialogue: 0,0:00:27.90,0:00:30.50,Default,,0,0,0,,Oh, I can't believe we got\Nstuck with the tree hugger.
Dialogue: 0,0:00:30.78,0:00:33.21,Default,,0,0,0,,If I have to hear the Latin\Nname for one more animal, I
Dialogue: 0,0:00:33.22,0:00:34.50,Default,,0,0,0,,swear I'm going to kill her.
Dialogue: 0,0:00:34.66,0:00:36.12,Default,,0,0,0,,Relax, Sugar Buns.
Dialogue: 0,0:00:36.24,0:00:39.06,Default,,0,0,0,,While she does all the work,\Nwe'll have all the fun.
Dialogue: 0,0:00:39.32,0:00:41.78,Default,,0,0,0,,Yeah, and get wasted out of our\Nminds.
Dialogue: 0,0:00:42.30,0:00:43.65,Default,,0,0,0,,Way ahead of you, man.
Dialogue: 0,0:00:44.00,0:00:44.82,Default,,0,0,0,,Come on, team.
Dialogue: 0,0:00:44.98,0:00:47.88,Default,,0,0,0,,We mustn't dilly-dally when\Nthere's so much nature to see.
Dialogue: 0,0:00:48.34,0:00:51.87,Default,,0,0,0,,I was thinking we should call\Nour class project Fungi in a
Dialogue: 0,0:00:51.88,0:00:52.66,Default,,0,0,0,,forest!
Dialogue: 0,0:00:53.34,0:00:54.10,Default,,0,0,0,,Get it?
Dialogue: 0,0:00:54.30,0:00:56.96,Default,,0,0,0,,Because we're a group of fun\Nguys and also fungi.
```
kristophm
Posts: 5
Joined: Mon Jan 29, 2024 8:44 pm

Re: Custom Font for subtitles in CLI

Post by kristophm »

I forgot to mention I'm on DoM version 2.16.18.

Bumping this post in case anyone missed this, and I'm a little stuck here. Thanks in advance!
carl
Site Admin
Posts: 2550
Joined: Thu Nov 14, 2013 2:53 pm

Re: Custom Font for subtitles in CLI

Post by carl »

Unless I forgot something I think there is no code to "automatically" try and find Courier New on your system in this case. The easiest fix would probably be to add a command line option so you could say something like

Code: Select all

--font-id="Courier New" --font-file=/foo/bar/courier.ttf
Would that work for you? (that option is not there yet, it's just an idea).

Better still would probably be to search the system for a font of this name when its specified in the .ass file like that.
kristophm
Posts: 5
Joined: Mon Jan 29, 2024 8:44 pm

Re: Custom Font for subtitles in CLI

Post by kristophm »

Carl,

Thank you and sorry for the late reply here. That would be amazing, thank you. I'm on the fence about whether to search the system fonts or not, but all things equal, I would say that being explicit about the font path might be better (I believe ffmpeg works the same way). What other information/help would you need from me?

PS. Side question: As you can see from the ASS file, it has the ability to specify other styling properties like margin left, right, vertical, scaleX|Y, etc. Does DCPOMatic (specifically the CLI) read this information or does it simply put default properties in, based on best practices?
carl
Site Admin
Posts: 2550
Joined: Thu Nov 14, 2013 2:53 pm

Re: Custom Font for subtitles in CLI

Post by carl »

Hi, OK I made a note in the tracker to add something like that.

Some of the ASS styling is supported, but by no means all of it. If there's some property that you need, and which is not supported, let me know.
Luucky
Posts: 1
Joined: Wed May 15, 2024 6:25 am

Re: Custom Font for subtitles in CLI

Post by Luucky »

Hellofont generator, what does that confirmed status mean in the bug detail table?
carl
Site Admin
Posts: 2550
Joined: Thu Nov 14, 2013 2:53 pm

Re: Custom Font for subtitles in CLI

Post by carl »

Hi, for features I usually set them to confirmed when I want to do it (at some point).
mdudzik
Posts: 18
Joined: Wed Mar 02, 2016 7:49 pm

Re: Custom Font for subtitles in CLI

Post by mdudzik »

Hi Carl, by the way - I can see vertical positioning with ASS works fine within DOM, but left/right margins are ignored - do you think it's something you could implement without too much effort?
carl
Site Admin
Posts: 2550
Joined: Thu Nov 14, 2013 2:53 pm

Re: Custom Font for subtitles in CLI

Post by carl »

The left/right margins doesn't look too hard to do - I'll try to get to it soon: https://dcpomatic.com/bugs/view.php?id=2811