summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-01-21 23:17:51 +0100
committerCarl Hetherington <cth@carlh.net>2023-02-27 14:47:25 +0100
commit45204e57f309bc595841975f7769037e43a0831f (patch)
tree4242dccda5380f38122c3eeef908a9d6969fb52a /src/lib
parent9f90d2db337787ebb4da73b909776d5b13a1d520 (diff)
Add override_standard to bounding_box().
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/render_text.cc8
-rw-r--r--src/lib/render_text.h2
2 files changed, 6 insertions, 4 deletions
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<StringText> subtitles, dcp::Size target, DCPTime time, int fra
list<dcpomatic::Rect<int>>
-bounding_box(list<StringText> subtitles, dcp::Size target)
+bounding_box(list<StringText> subtitles, dcp::Size target, optional<dcp::SubtitleStandard> override_standard)
{
list<StringText> pending;
list<dcpomatic::Rect<int>> 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<int>(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<StringText> subtitles, int target_height, float fade_factor, std::string font_name);
std::list<PositionImage> render_text (std::list<StringText>, dcp::Size, dcpomatic::DCPTime, int);
-std::list<dcpomatic::Rect<int>> bounding_box(std::list<StringText> subtitles, dcp::Size target);
+std::list<dcpomatic::Rect<int>> bounding_box(std::list<StringText> subtitles, dcp::Size target, boost::optional<dcp::SubtitleStandard> override_standard = boost::none);
class FontMetrics