From daceaad12cc73404f93d5aae0dd896fcb7b9d3b9 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 7 Mar 2026 23:48:43 +0100 Subject: wip: ruby --- src/text_string.h | 83 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 69 insertions(+), 14 deletions(-) (limited to 'src/text_string.h') diff --git a/src/text_string.h b/src/text_string.h index 78788786..bd668a0d 100644 --- a/src/text_string.h +++ b/src/text_string.h @@ -45,6 +45,7 @@ #include "ruby.h" #include "text.h" #include +#include #include @@ -52,7 +53,7 @@ namespace dcp { /** @class TextString - * @brief A single line of subtitle text with all the associated attributes. + * @brief A single piece of subtitle text with all the associated attributes. */ class TextString : public Text { @@ -103,8 +104,57 @@ public: Colour effect_colour, Time fade_up_time, Time fade_down_time, - float space_before, - std::vector rubies + float space_before + ); + + TextString( + boost::optional font, + bool italic, + bool bold, + bool underline, + Colour colour, + int size, + float aspect_adjust, + Time in, + Time out, + float h_position, + HAlign h_align, + float v_position, + VAlign v_align, + float z_position, + std::vector variable_z_positions, + Direction direction, + Ruby text, + Effect effect, + Colour effect_colour, + Time fade_up_time, + Time fade_down_time, + float space_before + ); + + TextString( + boost::optional font, + bool italic, + bool bold, + bool underline, + Colour colour, + int size, + float aspect_adjust, + Time in, + Time out, + float h_position, + HAlign h_align, + float v_position, + VAlign v_align, + float z_position, + std::vector variable_z_positions, + Direction direction, + boost::variant text, + Effect effect, + Colour effect_colour, + Time fade_up_time, + Time fade_down_time, + float space_before ); /** @return font ID */ @@ -128,10 +178,24 @@ public: return _colour; } - std::string text () const { + boost::variant text() const { return _text; } + boost::optional string_text() const { + if (_text.which() != 0) { + return {}; + } + return boost::get(_text); + } + + boost::optional ruby_text() const { + if (_text.which() != 1) { + return {}; + } + return boost::get(_text); + } + Direction direction () const { return _direction; } @@ -162,10 +226,6 @@ public: return _aspect_adjust; } - std::vector const& rubies() const { - return _rubies; - } - void set_font (std::string id) { _font = id; } @@ -198,10 +258,6 @@ public: _effect_colour = c; } - void set_rubies(std::vector rubies) { - _rubies = std::move(rubies); - } - bool equals(std::shared_ptr other_sub, EqualityOptions const& options, NoteHandler node) const override; private: @@ -221,11 +277,10 @@ private: int _size; float _aspect_adjust; Direction _direction; - std::string _text; + boost::variant _text; Effect _effect; Colour _effect_colour; float _space_before; - std::vector _rubies; }; -- cgit v1.2.3