+struct Layout
+{
+ Position<int> position;
+ dcp::Size size;
+ Glib::RefPtr<Pango::Layout> pango;
+};
+
+
+/** @param subtitles A list of subtitles that are all on the same line,
+ * at the same time and with the same fade in/out.
+ */
+static Layout
+setup_layout(list<StringText> subtitles, dcp::Size target, DCPTime time, int frame_rate)
+{
+ DCPOMATIC_ASSERT(!subtitles.empty());
+ auto const& first = subtitles.front();
+
+ auto const font_name = setup_font(first.font);
+ auto const fade_factor = calculate_fade_factor(first, time, frame_rate);
+ auto const markup = marked_up(subtitles, target.height, fade_factor, font_name);
+ auto layout = create_layout(font_name, markup);
+ auto ink = layout->get_ink_extents();
+ return { { ink.get_x() / Pango::SCALE, ink.get_y() / Pango::SCALE }, { ink.get_width() / Pango::SCALE, ink.get_height() / Pango::SCALE }, layout };
+}
+
+