Merge remote-tracking branch 'origin/main' into v2.17.x
authorCarl Hetherington <cth@carlh.net>
Fri, 28 Jun 2024 11:04:30 +0000 (13:04 +0200)
committerCarl Hetherington <cth@carlh.net>
Fri, 28 Jun 2024 11:04:30 +0000 (13:04 +0200)
1  2 
cscript
src/lib/font_id_allocator.cc
test/data
test/subtitle_font_id_test.cc

diff --combined cscript
index baece29e1b2f458bf12ef1ed61c82052a8403352,1695985694bccb52490eebc9ca34b24f016995c6..c5e2df9e914fc88d34520bca17a0fe5681fcbde6
+++ b/cscript
  #
  
  from __future__ import print_function
 +import datetime
  import glob
  import shutil
  import os
  import copy
  import json
  
 +def dmg_prefix(variant):
 +    return 'DCP-o-matic'
 +
 +def debian_name(variant):
 +    return 'dcpomatic'
 +
  deb_build_depends = dict()
  
  deb_build_depends_base = ['debhelper', 'g++', 'pkg-config', 'libsndfile1-dev', 'libgtk2.0-dev', 'libx264-dev']
@@@ -360,9 -353,9 +360,9 @@@ def packages(name, packages, f)
          s += str(p) + ', '
      print(s[:-2], file=f)
  
 -def make_control(debian_version, bits, filename, debug, gui):
 +def make_control(debian_version, bits, filename, debug, gui, name):
      f = open(filename, 'w')
 -    print('Source: dcpomatic', file=f)
 +    print(f'Source: {name}', file=f)
      print('Section: video', file=f)
      print('Priority: extra', file=f)
      print('Maintainer: Carl Hetherington <carl@dcpomatic.com>', file=f)
      print('Homepage: https://dcpomatic.com/', file=f)
      print('', file=f)
      suffix = '' if gui else '-cli'
 -    print(f'Package: dcpomatic{suffix}', file=f)
 +    print(f'Package: {name}{suffix}', file=f)
      if gui:
 -        print('Replaces: dcpomatic-cli', file=f)
 +        print(f'Replaces: {name}-cli', file=f)
      if bits == 32:
          print('Architecture: i386', file=f)
      else:
  
      if debug:
          print('', file=f)
 -        print(f'Package: dcpomatic{suffix}-dbg', file=f)
 +        print(f'Package: {name}{suffix}-dbg', file=f)
          if bits == 32:
              print('Architecture: i386', file=f)
          else:
          print('Section: debug', file=f)
          print('Priority: extra', file=f)
          packages('Depends', pkg, f)
 -        print('Description: debugging symbols for dcpomatic', file=f)
 -        print('  This package contains the debugging symbols for dcpomatic.', file=f)
 +        print(f'Description: debugging symbols for {name}', file=f)
 +        print(f'  This package contains the debugging symbols for {name}.', file=f)
          print('', file=f)
  
  def make_spec(filename, version, target, options, requires=None):
      print('%{_bindir}/dcpomatic2_playlist', file=f)
      print('%{_bindir}/dcpomatic2_openssl', file=f)
      print('%{_bindir}/dcpomatic2_combiner', file=f)
 -    print('%{_bindir}/dcpomatic2_verify', file=f)
 +    print('%{_bindir}/dcpomatic2_verify_cli', file=f)
 +    print('%{_bindir}/dcpomatic2_verifier', file=f)
      print('%{_bindir}/dcpomatic2_kdm_inspect', file=f)
      print('%{_bindir}/dcpomatic2_map', file=f)
      if can_build_disk(target):
      print('%{_datadir}/applications/dcpomatic2.desktop', file=f)
      print('%{_datadir}/applications/dcpomatic2_batch.desktop', file=f)
      print('%{_datadir}/applications/dcpomatic2_editor.desktop', file=f)
 +    print('%{_datadir}/applications/dcpomatic2_verifier.desktop', file=f)
      print('%{_datadir}/applications/dcpomatic2_server.desktop', file=f)
      print('%{_datadir}/applications/dcpomatic2_kdm.desktop', file=f)
      print('%{_datadir}/applications/dcpomatic2_player.desktop', file=f)
          print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2.png' % r, file=f)
          print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_batch.png' % r, file=f)
          print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_editor.png' % r, file=f)
 +        print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_verifier.png' % r, file=f)
          print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_kdm.png' % r, file=f)
          print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_server.png' % r, file=f)
          print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_player.png' % r, file=f)
      print('/bin/cp -r %s/src/libdcp/tags %%{buildroot}/usr/share/libdcp' % target.directory, file=f)
      print('/bin/cp -r %s/src/libdcp/xsd %%{buildroot}/usr/share/libdcp' % target.directory, file=f)
      print('/bin/cp %s/src/libdcp/ratings %%{buildroot}/usr/share/libdcp' % target.directory, file=f)
 -    print('/bin/mv %s/bin/dcpverify %%{buildroot}/usr/bin/dcpomatic2_verify' % target.directory, file=f)
 +    print('/bin/mv %s/bin/dcpverify %%{buildroot}/usr/bin/dcpomatic2_verify_cli' % target.directory, file=f)
      print('/bin/mv %s/bin/dcpkdm %%{buildroot}/usr/bin/dcpomatic2_kdm_inspect' % target.directory, file=f)
      print('', file=f)
      print('%post', file=f)
      print('/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
  
  def dependencies(target, options):
-     deps = [('libdcp', 'v1.9.9', {'c++17': target.platform == 'osx'})]
 -
 -    if target.platform == 'linux':
 -        ffmpeg_options = { 'shared': False }
 -    else:
 -        ffmpeg_options = {}
 -
 -    if target.platform != 'linux' or target.distro != 'arch':
 -        deps = [('ffmpeg', '7276e269a93c2ae30e302c34708e8095ac5475e8', ffmpeg_options)]
 -    else:
 -        # Use distro-provided FFmpeg on Arch
 -        deps = []
 -
 -    deps.append(('libdcp', 'v1.8.101'))
++    deps = [('libdcp', 'v1.9.10', {'c++17': target.platform == 'osx'})]
      deps.append(('libsub', 'v1.6.49'))
      deps.append(('leqm-nrt', '30dcaea1373ac62fba050e02ce5b0c1085797a23'))
      deps.append(('rtaudio', 'f619b76'))
      deps.append(('openssl', '54298369cacfe0ae01c5aa42ace8a463fd2e7a2e'))
      if can_build_disk(target):
          deps.append(('lwext4', 'ab082923a791b58478d1d9939d65a0583566ac1f'))
 -    deps.append(('ffcmp', '53c853d2935de3f2b0d53777529e48c102afd237'))
 +    deps.append(('ffcmp', '5ab6ed3b75d8ca7cf1f66bb9fb08792b92f4b419'))
  
      return deps
  
@@@ -576,7 -578,7 +576,7 @@@ def configure_options(target, options, 
      if not options['gui']:
          opt += ' --disable-gui'
  
 -    if options['variant'] is not None:
 +    if options['variant']:
          opt += ' --variant=%s' % options['variant']
  
      # Build Windows debug versions with static linking as I think gdb works better then
      if can_build_disk(target):
          opt += ' --enable-disk'
  
 -    if target.platform == 'osx' and target.arch == 'arm64':
 -        opt += ' --wx-config=%s/wx-config' % target.bin
 +    if target.platform == 'osx':
 +        opt += ' --c++17'
 +        if target.arch == 'arm64':
 +            opt += ' --wx-config=%s/wx-config' % target.bin
 +
 +    if target.platform == 'linux' and target.distro == 'ubuntu' and target.version in ['22.04']:
 +        opt += ' --enable-grok'
  
      return opt
  
@@@ -717,11 -714,13 +717,11 @@@ def build(target, options, for_package)
          target.command('./waf install')
  
  def package_windows(target):
 -    identifier = ''
 -    if target.version is not None:
 -        identifier = '%s.' % target.version
 -    identifier += '%d' % target.bits
 +    identifier = '%d' % target.bits
      shutil.copyfile('build/platform/windows/installer.%s.nsi' % identifier, 'build/platform/windows/installer2.%s.nsi' % identifier)
      target.command('sed -i "s~%%resources%%~%s/platform/windows~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
      target.command('sed -i "s~%%graphics%%~%s/graphics~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
 +    target.command('sed -i "s~%%web%%~%s/web~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
      target.command('sed -i "s~%%static_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.windows_prefix, identifier))
      target.command('sed -i "s~%%cdist_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.directory, identifier))
      target.command('sed -i "s~%%mingw%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.environment_prefix, identifier))
      return os.path.abspath(glob.glob('build/platform/windows/*%s*.exe' % target.bits)[0])
  
  def package_debian(target, cpu, version, options):
 -    make_control(target.version, target.bits, 'debian/control', target.debug, options['gui'])
 +    name = debian_name(options['variant'])
 +    make_control(target.version, target.bits, 'debian/control', target.debug, options['gui'], name)
      if target.version != '9' and target.version != '16.04' and options['gui']:
          with open('debian/postinst', 'w') as f:
              print('#!/bin/sh', file=f)
      target.command('./waf dist')
      f = open('debian/files', 'w')
      suffix = '' if options['gui'] else '-cli'
 -    print(f'dcpomatic{suffix}_{version}-1_{cpu}.deb video extra', file=f)
 +    print(f'{name}{suffix}_{version}-1_{cpu}.deb video extra', file=f)
      shutil.rmtree('build/deb', ignore_errors=True)
  
      os.makedirs('build/deb')
      os.chdir('build/deb')
 -    shutil.move('../../dcpomatic-%s.tar.bz2' % version, 'dcpomatic_%s.orig.tar.bz2' % version)
 -    target.command('tar xjf dcpomatic_%s.orig.tar.bz2' % version)
 -    os.chdir('dcpomatic-%s' % version)
 -    target.set('EMAIL', 'carl@dcpomatic.com')
 -    target.command('dch -b -v %s-1 "New upstream release."' % version)
 +    shutil.move(f'../../dcpomatic-{version}.tar.bz2', f'{name}_1+{version}.orig.tar.bz2')
 +    target.command(f'tar xjf {name}_1+{version}.orig.tar.bz2')
 +    os.chdir(f'dcpomatic-{version}')
 +
 +    with open('debian/changelog', 'w') as f:
 +        print(f'{name} (1+{version}-1) unstable; urgency=medium', file=f)
 +        print('', file=f)
 +        print('  * New upstream release.', file=f)
 +        print('', file=f)
 +        print(f" -- Carl Hetherington <carl@dcpomatic.com>  {datetime.datetime.now().astimezone().strftime('%a, %d %b %Y %H:%M:%S %z')}", file=f)
 +
      target.set('CDIST_LINKFLAGS', target.get('LINKFLAGS'))
      target.set('CDIST_CXXFLAGS', target.get('CXXFLAGS'))
      target.set('CDIST_PKG_CONFIG_PATH', target.get('PKG_CONFIG_PATH'))
      target.set('CDIST_DIRECTORY', target.directory)
  
      target.set('CDIST_CONFIGURE', '"' + configure_options(target, options, for_package=True) + '"')
 -    target.set('CDIST_PACKAGE', f'dcpomatic{suffix}')
 +    target.set('CDIST_PACKAGE', f'{name}{suffix}')
      target.set('CDIST_WX_VERSION', "3.2" if target.version in ("23.04", "23.10", "24.04") else "3.1")
      if not target.debug:
          target.set('CDIST_DEBUG_PACKAGE_FLAG', '--no-ddebs')
@@@ -817,7 -809,7 +817,7 @@@ def make_appimage(target, nice_name, in
      os.makedirs(f'{appdir}/usr/bin')
      target.command(f'cp {target.directory}/bin/{internal_name} {appdir}/usr/bin')
      target.command(f'cp {target.directory}/src/openssl/apps/openssl {appdir}/usr/bin/dcpomatic2_openssl')
 -    target.command(f'cp {target.directory}/bin/dcpverify {appdir}/usr/bin/dcpomatic2_verify')
 +    target.command(f'cp {target.directory}/bin/dcpverify {appdir}/usr/bin/dcpomatic2_verify_cli')
      target.command(f'cp {target.directory}/bin/dcpkdm {appdir}/usr/bin/dcpomatic2_kdm_inspect')
      if extra_binaries:
          for bin in extra_binaries:
@@@ -879,7 -871,6 +879,7 @@@ def package(target, version, options)
              out.append(make_appimage(target, 'DCP-o-matic Encode Server', 'dcpomatic2_server', version))
              out.append(make_appimage(target, 'DCP-o-matic Combiner', 'dcpomatic2_combiner', version))
              out.append(make_appimage(target, 'DCP-o-matic Editor', 'dcpomatic2_editor', version))
 +            out.append(make_appimage(target, 'DCP-o-matic Verifier', 'dcpomatic2_verifier', version))
              return out
          else:
              if target.bits == 32:
          cmd = 'bash platform/osx/make_dmg.sh -e %s -r %s -i %s -p %s %s' % (target.environment_prefix, target.directory, target.apple_id, target.apple_password, archs)
          if 'part' in options:
              cmd += ' -b ' + options['part']
 +        if options['variant']:
 +            cmd += ' -v ' + options['variant']
          target.command(cmd)
 -        return glob.glob('build/platform/osx/DCP-o-matic*.dmg')
 +        return glob.glob('build/platform/osx/' + dmg_prefix(options['variant']) + '*.dmg')
      elif target.platform == 'docker':
          shutil.copyfile(target.deb, 'build/platform/docker')
          f = open('build/platform/docker/Dockerfile', 'w')
index 76b52e730c15afafd7d5ffee3ce277b4afa81217,5e4ae9c0f2d1d4bd8b3426d3009c5a550a735c71..d5430e8584907f94856cd7f2033ff3a0052748d7
@@@ -76,23 -76,37 +76,23 @@@ FontIDAllocator::add_font(int reel_inde
        if (!_default_font) {
                _default_font = font;
        }
 -      _map[font] = 0;
 +      _map[font] = {};
  }
  
  
  void
  FontIDAllocator::allocate()
  {
 -      /* We'll first try adding <reel>_ to the start of the font ID, but if a reel has multiple
 -       * identical font IDs we will need to use some number that is not a reel ID.  Find the
 -       * first such number (1 higher than the highest reel index)
 -       */
 -      auto next_unused = std::max_element(
 -              _map.begin(),
 -              _map.end(),
 -              [] (std::pair<Font, int> const& a, std::pair<Font, int> const& b) {
 -                      return a.first.reel_index < b.first.reel_index;
 -              })->first.reel_index + 1;
 -
        std::set<string> used_ids;
  
        for (auto& font: _map) {
 -              auto const proposed = String::compose("%1_%2", font.first.reel_index, font.first.font_id);
 -              if (used_ids.find(proposed) != used_ids.end()) {
 -                      /* This ID was already used; we need to disambiguate it.  Do so by using
 -                       * one of our unused prefixes.
 -                       */
 -                      font.second = next_unused++;
 -              } else {
 -                      /* This ID was not yet used */
 -                      font.second = font.first.reel_index;
 +              auto proposed = font.first.font_id;
 +              int prefix = 0;
 +              while (used_ids.find(proposed) != used_ids.end()) {
 +                      proposed = String::compose("%1_%2", prefix++, font.first.font_id);
 +                      DCPOMATIC_ASSERT(prefix < 128);
                }
 +              font.second = proposed;
                used_ids.insert(proposed);
        }
  }
@@@ -102,8 -116,10 +102,10 @@@ strin
  FontIDAllocator::font_id(int reel_index, string asset_id, string font_id) const
  {
        auto iter = _map.find(Font(reel_index, asset_id, font_id));
-       DCPOMATIC_ASSERT(iter != _map.end());
+       if (iter == _map.end()) {
+               return default_font_id();
+       }
 -      return String::compose("%1_%2", iter->second, font_id);
 +      return iter->second;
  }
  
  
diff --combined test/data
index 02050bb9632658f0ce85ace219302b534f81eecc,6a4fa8b7c13e4f09fcee995191a2c86e1eff9d6d..3a3b29c0f1e9e2654ddee2028be623e1e1b3a33f
+++ b/test/data
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 02050bb9632658f0ce85ace219302b534f81eecc
 -Subproject commit 6a4fa8b7c13e4f09fcee995191a2c86e1eff9d6d
++Subproject commit 3a3b29c0f1e9e2654ddee2028be623e1e1b3a33f
index 49ad4ea05ddf3a5c6550c8e4c609c1f19db64636,12d804d20a23b0de9eb31f68bf485a317b349d7d..8ced35108552d6b716c71a4d536fe0c784df2983
@@@ -19,7 -19,6 +19,7 @@@
  */
  
  
 +#include "lib/check_content_job.h"
  #include "lib/content_factory.h"
  #include "lib/dcp_content.h"
  #include "lib/film.h"
@@@ -42,7 -41,7 +42,7 @@@ using std::make_shared
  BOOST_AUTO_TEST_CASE(full_dcp_subtitle_font_id_test)
  {
        auto dcp = make_shared<DCPContent>(TestPaths::private_data() / "JourneyToJah_TLR-1_F_EN-DE-FR_CH_51_2K_LOK_20140225_DGL_SMPTE_OV");
 -      auto film = new_test_film2("full_dcp_subtitle_font_id_test", { dcp });
 +      auto film = new_test_film("full_dcp_subtitle_font_id_test", { dcp });
  
        auto content = film->content();
        BOOST_REQUIRE_EQUAL(content.size(), 1U);
@@@ -51,7 -50,7 +51,7 @@@
  
        BOOST_REQUIRE_EQUAL(text->fonts().size(), 1U);
        auto font = text->fonts().front();
 -      BOOST_CHECK_EQUAL(font->id(), "0_theFontId");
 +      BOOST_CHECK_EQUAL(font->id(), "theFontId");
        BOOST_REQUIRE(font->data());
        BOOST_CHECK_EQUAL(font->data()->size(), 367112);
  }
@@@ -60,7 -59,7 +60,7 @@@
  BOOST_AUTO_TEST_CASE(dcp_subtitle_font_id_test)
  {
        auto subs = content_factory(TestPaths::private_data() / "JourneyToJah_TLR-1_F_EN-DE-FR_CH_51_2K_LOK_20140225_DGL_SMPTE_OV" / "8b48f6ae-c74b-4b80-b994-a8236bbbad74_sub.mxf");
 -      auto film = new_test_film2("dcp_subtitle_font_id_test", subs);
 +      auto film = new_test_film("dcp_subtitle_font_id_test", subs);
  
        auto content = film->content();
        BOOST_REQUIRE_EQUAL(content.size(), 1U);
@@@ -69,7 -68,7 +69,7 @@@
  
        BOOST_REQUIRE_EQUAL(text->fonts().size(), 1U);
        auto font = text->fonts().front();
 -      BOOST_CHECK_EQUAL(font->id(), "0_theFontId");
 +      BOOST_CHECK_EQUAL(font->id(), "theFontId");
        BOOST_REQUIRE(font->data());
        BOOST_CHECK_EQUAL(font->data()->size(), 367112);
  }
@@@ -78,7 -77,7 +78,7 @@@
  BOOST_AUTO_TEST_CASE(make_dcp_with_subs_from_interop_dcp)
  {
        auto dcp = make_shared<DCPContent>("test/data/Iopsubs_FTR-1_F_XX-XX_MOS_2K_20220710_IOP_OV");
 -      auto film = new_test_film2("make_dcp_with_subs_from_interop_dcp", { dcp });
 +      auto film = new_test_film("make_dcp_with_subs_from_interop_dcp", { dcp });
        dcp->text.front()->set_use(true);
        make_and_verify_dcp(
                film,
@@@ -95,7 -94,7 +95,7 @@@ BOOST_AUTO_TEST_CASE(make_dcp_with_subs
        Cleanup cl;
  
        auto dcp = make_shared<DCPContent>(TestPaths::private_data() / "JourneyToJah_TLR-1_F_EN-DE-FR_CH_51_2K_LOK_20140225_DGL_SMPTE_OV");
 -      auto film = new_test_film2("make_dcp_with_subs_from_smpte_dcp", { dcp }, &cl);
 +      auto film = new_test_film("make_dcp_with_subs_from_smpte_dcp", { dcp }, &cl);
        dcp->text.front()->set_use(true);
        make_and_verify_dcp(film);
  
  BOOST_AUTO_TEST_CASE(make_dcp_with_subs_from_mkv)
  {
        auto subs = content_factory(TestPaths::private_data() / "clapperboard_with_subs.mkv");
 -      auto film = new_test_film2("make_dcp_with_subs_from_mkv", subs);
 +      auto film = new_test_film("make_dcp_with_subs_from_mkv", subs);
        subs[0]->text.front()->set_use(true);
        subs[0]->text.front()->set_language(dcp::LanguageTag("en"));
        make_and_verify_dcp(film, { dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_RATE_FOR_2K });
  BOOST_AUTO_TEST_CASE(make_dcp_with_subs_without_font_tag)
  {
        auto subs = content_factory("test/data/no_font.xml");
 -      auto film = new_test_film2("make_dcp_with_subs_without_font_tag", { subs });
 +      auto film = new_test_film("make_dcp_with_subs_without_font_tag", { subs });
        subs[0]->text.front()->set_use(true);
        subs[0]->text.front()->set_language(dcp::LanguageTag("de"));
        make_and_verify_dcp(
@@@ -140,7 -139,7 +140,7 @@@ BOOST_AUTO_TEST_CASE(make_dcp_with_subs
  {
        /* Make a DCP with some subs in */
        auto source_subs = content_factory("test/data/short.srt");
 -      auto source = new_test_film2("make_dcp_with_subs_in_dcp_without_font_tag_source", { source_subs });
 +      auto source = new_test_film("make_dcp_with_subs_in_dcp_without_font_tag_source", { source_subs });
        source->set_interop(true);
        source_subs[0]->only_text()->set_language(dcp::LanguageTag("de"));
        make_and_verify_dcp(
  
        /* Now make a project which imports that DCP and makes another DCP from it */
        auto dcp_content = make_shared<DCPContent>(source->dir(source->dcp_name()));
 -      auto film = new_test_film2("make_dcp_with_subs_without_font_tag", { dcp_content });
 +      auto film = new_test_film("make_dcp_with_subs_without_font_tag", { dcp_content });
        BOOST_REQUIRE(!dcp_content->text.empty());
        dcp_content->text.front()->set_use(true);
        make_and_verify_dcp(
@@@ -204,7 -203,7 +204,7 @@@ BOOST_AUTO_TEST_CASE(filler_subtitle_re
        auto video1 = content_factory("test/data/flat_red.png")[0];
        auto video2 = content_factory("test/data/flat_red.png")[0];
  
 -      auto film = new_test_film2(name, { video1, video2, subs });
 +      auto film = new_test_film(name, { video1, video2, subs });
        film->set_reel_type(ReelType::BY_VIDEO_CONTENT);
  
        make_and_verify_dcp(
@@@ -226,7 -225,7 +226,7 @@@ BOOST_AUTO_TEST_CASE(subtitle_with_no_f
        auto video2 = content_factory("test/data/flat_red.png")[0];
        auto subs = content_factory("test/data/short.srt")[0];
  
 -      auto bad_film = new_test_film2(name_base + "_bad", { video1, video2, subs });
 +      auto bad_film = new_test_film(name_base + "_bad", { video1, video2, subs });
        bad_film->set_reel_type(ReelType::BY_VIDEO_CONTENT);
        video2->set_position(bad_film, video1->end(bad_film));
        subs->set_position(bad_film, video1->end(bad_film));
        BOOST_REQUIRE_EQUAL(check_subs->subtitles().size(), 1U);
        BOOST_CHECK(!std::dynamic_pointer_cast<const dcp::SubtitleString>(check_subs->subtitles()[0])->font().has_value());
  
 -      auto check_film = new_test_film2(name_base + "_check", { make_shared<DCPContent>(bad_film->dir(bad_film->dcp_name())) });
 +      auto check_film = new_test_film(name_base + "_check", { make_shared<DCPContent>(bad_film->dir(bad_film->dcp_name())) });
        make_and_verify_dcp(check_film);
  }
  
  BOOST_AUTO_TEST_CASE(load_dcp_with_empty_font_id_test)
  {
        auto dcp = std::make_shared<DCPContent>(TestPaths::private_data() / "kr_vf");
 -      auto film = new_test_film2("load_dcp_with_empty_font_id_test", { dcp });
 +      auto film = new_test_film("load_dcp_with_empty_font_id_test", { dcp });
  }
  
  
  BOOST_AUTO_TEST_CASE(use_first_loadfont_as_default)
  {
        auto dcp = std::make_shared<DCPContent>("test/data/use_default_font");
 -      auto film = new_test_film2("use_first_loadfont_as_default", { dcp });
 +      auto film = new_test_film("use_first_loadfont_as_default", { dcp });
        dcp->only_text()->set_use(true);
        dcp->only_text()->set_language(dcp::LanguageTag("de"));
        make_and_verify_dcp(
  BOOST_AUTO_TEST_CASE(no_error_with_ccap_that_mentions_no_font)
  {
        auto dcp = make_shared<DCPContent>("test/data/ccap_only");
 -      auto film = new_test_film2("no_error_with_ccap_that_mentions_no_font", { dcp });
 +      auto film = new_test_film("no_error_with_ccap_that_mentions_no_font", { dcp });
        auto player = Player(film, film->playlist());
        while (!player.pass()) {}
  }
  
  
 -                      dcp::VerificationNote::Code::MISSING_CPL_METADATA,
 +BOOST_AUTO_TEST_CASE(subtitle_font_ids_survive_project_save)
 +{
 +      std::string const name = "subtitle_font_ids_survive_project_save";
 +
 +      auto subs = content_factory("test/data/short.srt")[0];
 +      auto film = new_test_film(name + "_film", { subs });
 +      film->set_interop(false);
 +      make_and_verify_dcp(
 +              film,
 +              {
 +                      dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
 +                      dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
 +                      dcp::VerificationNote::Code::MISSING_CPL_METADATA
 +              });
 +
 +      auto dcp = std::make_shared<DCPContent>(film->dir(film->dcp_name()));
 +      auto film2 = new_test_film(name + "_film2", { dcp });
 +      film2->write_metadata();
 +
 +      auto film3 = std::make_shared<Film>(film2->dir("."));
 +      film3->read_metadata();
 +      BOOST_REQUIRE(!film3->content().empty());
 +      auto check_dcp = std::dynamic_pointer_cast<DCPContent>(film3->content()[0]);
 +      BOOST_REQUIRE(check_dcp);
 +
 +      check_dcp->check_font_ids();
 +}
 +
++
+ BOOST_AUTO_TEST_CASE(cope_with_unloaded_font_id)
+ {
+       /* This file has a <Font> with an ID that corresponds to no <LoadFont> */
+       auto subs = content_factory("test/data/unloaded_font.xml")[0];
+       auto film = new_test_film2("cope_with_unloaded_font_id", { subs });
++
+       make_and_verify_dcp(
+               film,
+               {
+                       dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
++                      dcp::VerificationNote::Code::MISSING_CPL_METADATA
+               });
+ }