From: Carl Hetherington Date: Sat, 21 Jan 2023 22:17:51 +0000 (+0100) Subject: Add override_standard to bounding_box(). X-Git-Tag: v2.16.45~18^2~4 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=45204e57f309bc595841975f7769037e43a0831f;p=dcpomatic.git Add override_standard to bounding_box(). --- diff --git a/src/lib/render_text.cc b/src/lib/render_text.cc index b32bed557..33e0c6a89 100644 --- a/src/lib/render_text.cc +++ b/src/lib/render_text.cc @@ -47,6 +47,7 @@ using std::min; using std::pair; using std::shared_ptr; using std::string; +using boost::optional; using namespace dcpomatic; @@ -436,17 +437,18 @@ render_text (list subtitles, dcp::Size target, DCPTime time, int fra list> -bounding_box(list subtitles, dcp::Size target) +bounding_box(list subtitles, dcp::Size target, optional override_standard) { list pending; list> rects; - auto use_pending = [&pending, &rects, target]() { + auto use_pending = [&pending, &rects, target, override_standard]() { auto const& subtitle = pending.front(); + auto standard = override_standard.get_value_or(subtitle.valign_standard); /* We can provide dummy values for time and frame rate here as they are only used to calculate fades */ auto layout = setup_layout(pending, target, DCPTime(), 24); int const x = x_position(subtitle.h_align(), subtitle.h_position(), target.width, layout.size.width); - int const y = y_position(subtitle.valign_standard, subtitle.v_align(), subtitle.v_position(), target.height, layout.position.y, layout.size.height); + int const y = y_position(standard, subtitle.v_align(), subtitle.v_position(), target.height, layout.position.y, layout.size.height); rects.push_back({Position(x, y), layout.size.width, layout.size.height}); }; diff --git a/src/lib/render_text.h b/src/lib/render_text.h index bceee964e..6d20912a2 100644 --- a/src/lib/render_text.h +++ b/src/lib/render_text.h @@ -34,7 +34,7 @@ namespace dcpomatic { std::string marked_up (std::list subtitles, int target_height, float fade_factor, std::string font_name); std::list render_text (std::list, dcp::Size, dcpomatic::DCPTime, int); -std::list> bounding_box(std::list subtitles, dcp::Size target); +std::list> bounding_box(std::list subtitles, dcp::Size target, boost::optional override_standard = boost::none); class FontMetrics