From 2b793cd6eac56b06a2d694591cddecb3ae2b099d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 16 Oct 2021 22:17:24 +0200 Subject: [PATCH] Move some functions up the file so we can use them. --- src/lib/render_text.cc | 54 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/lib/render_text.cc b/src/lib/render_text.cc index 94b412856..989bc7dfe 100644 --- a/src/lib/render_text.cc +++ b/src/lib/render_text.cc @@ -55,6 +55,33 @@ static FcConfig* fc_config = nullptr; static list> fc_config_fonts; +/** Create a Pango layout using a dummy context which we can use to calculate the size + * of the text we will render. Then we can transfer the layout over to the real context + * for the actual render. + */ +static Glib::RefPtr +create_layout() +{ + auto c_font_map = pango_cairo_font_map_new (); + DCPOMATIC_ASSERT (c_font_map); + auto font_map = Glib::wrap (c_font_map); + auto c_context = pango_font_map_create_context (c_font_map); + DCPOMATIC_ASSERT (c_context); + auto context = Glib::wrap (c_context); + return Pango::Layout::create (context); +} + + +static void +setup_layout (Glib::RefPtr layout, string font_name, string markup) +{ + layout->set_alignment (Pango::ALIGN_LEFT); + Pango::FontDescription font (font_name); + layout->set_font_description (font); + layout->set_markup (markup); +} + + string marked_up (list subtitles, int target_height, float fade_factor) { @@ -259,33 +286,6 @@ y_position (StringText const& first, int target_height, int layout_height) } -static void -setup_layout (Glib::RefPtr layout, string font_name, string markup) -{ - layout->set_alignment (Pango::ALIGN_LEFT); - Pango::FontDescription font (font_name); - layout->set_font_description (font); - layout->set_markup (markup); -} - - -/** Create a Pango layout using a dummy context which we can use to calculate the size - * of the text we will render. Then we can transfer the layout over to the real context - * for the actual render. - */ -static Glib::RefPtr -create_layout() -{ - auto c_font_map = pango_cairo_font_map_new (); - DCPOMATIC_ASSERT (c_font_map); - auto font_map = Glib::wrap (c_font_map); - auto c_context = pango_font_map_create_context (c_font_map); - DCPOMATIC_ASSERT (c_context); - auto context = Glib::wrap (c_context); - return Pango::Layout::create (context); -} - - /** @param subtitles A list of subtitles that are all on the same line, * at the same time and with the same fade in/out. */ -- 2.30.2