X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Futil.cc;h=a80f86c3ec7fb6e9333511d002a4fe55d3dd2ad7;hb=91c86d50eb8a4a92e30736564c13bc4d11878f7f;hp=8c570059821d35ca3290dd250524d3f682b2c6f9;hpb=1c73379ed8483dcf71c5ccfc459c2c22516a9aef;p=dcpomatic.git diff --git a/src/lib/util.cc b/src/lib/util.cc index 8c5700598..a80f86c3e 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -54,6 +54,7 @@ #include "video_content.h" #include #include +#include #include #include #include @@ -99,27 +100,20 @@ LIBDCP_ENABLE_WARNINGS #include "i18n.h" -using std::bad_alloc; using std::cout; using std::endl; -using std::istream; using std::list; using std::make_pair; using std::make_shared; -using std::map; +using std::max; using std::min; -using std::ostream; using std::pair; using std::set_terminate; using std::shared_ptr; using std::string; using std::vector; using std::wstring; -using boost::thread; using boost::optional; -using boost::lexical_cast; -using boost::bad_lexical_cast; -using boost::scoped_array; using dcp::Size; using dcp::raw_convert; using dcp::locale_convert; @@ -407,7 +401,6 @@ ffmpeg_log_callback(void* ptr, int level, const char* fmt, va_list vl) } -static void capture_ffmpeg_logs() { @@ -448,7 +441,13 @@ LIBDCP_ENABLE_WARNINGS #ifdef DCPOMATIC_WINDOWS putenv ("PANGOCAIRO_BACKEND=fontconfig"); - putenv (String::compose("FONTCONFIG_PATH=%1", resources_path().string()).c_str()); + if (boost::filesystem::exists(resources_path() / "fonts.conf")) { + /* The actual application after installation */ + putenv(String::compose("FONTCONFIG_PATH=%1", resources_path().string()).c_str()); + } else { + /* The place where fonts.conf is during tests */ + putenv("FONTCONFIG_PATH=build\\fonts"); + } #endif #ifdef DCPOMATIC_OSX @@ -461,7 +460,7 @@ LIBDCP_ENABLE_WARNINGS #if defined(DCPOMATIC_WINDOWS) || defined(DCPOMATIC_OSX) /* Render something to fontconfig to create its cache */ - list subs; + vector subs; dcp::SubtitleString ss( optional(), false, false, false, dcp::Colour(), 42, 1, dcp::Time(), dcp::Time(), 0, dcp::HAlign::CENTER, 0, dcp::VAlign::CENTER, 0, dcp::Direction::LTR, "Hello dolly", dcp::Effect::NONE, dcp::Colour(), dcp::Time(), dcp::Time(), 0 @@ -983,19 +982,25 @@ copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, std::fun dcp::Size scale_for_display (dcp::Size s, dcp::Size display_container, dcp::Size film_container, PixelQuanta quanta) { - /* Now scale it down if the display container is smaller than the film container */ - if (display_container != film_container) { - float const scale = min ( - float (display_container.width) / film_container.width, - float (display_container.height) / film_container.height + if (std::abs(display_container.ratio() - film_container.ratio()) < 0.01) { + /* The display ratio is very close to what it should be, but it might not be exactly the same. + * Allow the image to stretch slightly (differently in x and y) so that we are less likely + * to get single pixel gaps in the preview. + */ + return quanta.round( + static_cast(s.width) * display_container.width / film_container.width, + static_cast(s.height) * display_container.height / film_container.height ); - - s.width = lrintf (s.width * scale); - s.height = lrintf (s.height * scale); - s = quanta.round (s); + } else { + /* The display ratio is quite different to the film, so scale it so that the dimension + * that needs to fit does fit. + */ + auto const scale = min( + static_cast(display_container.width) / film_container.width, + static_cast(display_container.height) / film_container.height + ); + return quanta.round(s.width * scale, s.height * scale); } - - return s; }