summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/font_node.cc5
-rw-r--r--src/font_node.h1
-rw-r--r--src/subtitle_asset.cc8
-rw-r--r--src/subtitle_string.cc17
-rw-r--r--src/subtitle_string.h9
-rw-r--r--test/asset_test.cc2
-rw-r--r--test/read_interop_subtitle_test.cc23
-rw-r--r--test/write_subtitle_test.cc2
8 files changed, 59 insertions, 8 deletions
diff --git a/src/font_node.cc b/src/font_node.cc
index 5d857bc1..a5047211 100644
--- a/src/font_node.cc
+++ b/src/font_node.cc
@@ -39,6 +39,7 @@ FontNode::FontNode (cxml::ConstNodePtr node, int tcr, string font_id_attribute)
size = node->optional_number_attribute<int64_t> ("Size").get_value_or (0);
aspect_adjust = node->optional_number_attribute<float> ("AspectAdjust");
italic = node->optional_bool_attribute ("Italic");
+ bold = node->optional_string_attribute("Weight").get_value_or("normal") == "bold";
optional<string> c = node->optional_string_attribute ("Color");
if (c) {
colour = Colour (c.get ());
@@ -71,6 +72,7 @@ FontNode::FontNode (cxml::ConstNodePtr node, int tcr, string font_id_attribute)
FontNode::FontNode (std::list<boost::shared_ptr<FontNode> > const & font_nodes)
: size (0)
, italic (false)
+ , bold (false)
, colour ("FFFFFFFF")
, effect_colour ("FFFFFFFF")
{
@@ -87,6 +89,9 @@ FontNode::FontNode (std::list<boost::shared_ptr<FontNode> > const & font_nodes)
if ((*i)->italic) {
italic = (*i)->italic.get ();
}
+ if ((*i)->bold) {
+ bold = (*i)->bold.get ();
+ }
if ((*i)->colour) {
colour = (*i)->colour.get ();
}
diff --git a/src/font_node.h b/src/font_node.h
index 50815636..b82308fb 100644
--- a/src/font_node.h
+++ b/src/font_node.h
@@ -48,6 +48,7 @@ public:
int size;
boost::optional<float> aspect_adjust;
boost::optional<bool> italic;
+ boost::optional<bool> bold;
boost::optional<Colour> colour;
boost::optional<Effect> effect;
boost::optional<Colour> effect_colour;
diff --git a/src/subtitle_asset.cc b/src/subtitle_asset.cc
index 5074c35b..352aff9a 100644
--- a/src/subtitle_asset.cc
+++ b/src/subtitle_asset.cc
@@ -143,6 +143,7 @@ SubtitleAsset::maybe_add_subtitle (string text, ParseState const & parse_state)
SubtitleString (
effective_font.id,
effective_font.italic.get_value_or (false),
+ effective_font.bold.get_value_or (false),
effective_font.colour.get_value_or (dcp::Colour (255, 255, 255)),
effective_font.size,
effective_font.aspect_adjust.get_value_or (1.0),
@@ -233,10 +234,11 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Stand
string const xmlns = standard == SMPTE ? "dcst" : "";
- /* XXX: script, underlined, weight not supported */
+ /* XXX: script, underlined not supported */
optional<string> font;
bool italic = false;
+ bool bold = false;
Colour colour;
int size = 0;
float aspect_adjust = 1.0;
@@ -261,6 +263,7 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Stand
bool const font_changed =
font != i.font() ||
italic != i.italic() ||
+ bold != i.bold() ||
colour != i.colour() ||
size != i.size() ||
fabs (aspect_adjust - i.aspect_adjust()) > ASPECT_ADJUST_EPSILON ||
@@ -270,6 +273,7 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Stand
if (font_changed) {
font = i.font ();
italic = i.italic ();
+ bold = i.bold ();
colour = i.colour ();
size = i.size ();
aspect_adjust = i.aspect_adjust ();
@@ -300,7 +304,7 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Stand
} else {
font_element->set_attribute ("Underlined", "no");
}
- font_element->set_attribute ("Weight", "normal");
+ font_element->set_attribute ("Weight", bold ? "bold" : "normal");
}
if (!subtitle_element || font_changed ||
diff --git a/src/subtitle_string.cc b/src/subtitle_string.cc
index d565d453..ea24e37f 100644
--- a/src/subtitle_string.cc
+++ b/src/subtitle_string.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -30,6 +30,7 @@ using namespace dcp;
SubtitleString::SubtitleString (
optional<string> font,
bool italic,
+ bool bold,
Colour colour,
int size,
float aspect_adjust,
@@ -47,6 +48,7 @@ SubtitleString::SubtitleString (
)
: _font (font)
, _italic (italic)
+ , _bold (bold)
, _colour (colour)
, _size (size)
, _aspect_adjust (aspect_adjust)
@@ -82,6 +84,7 @@ dcp::operator== (SubtitleString const & a, SubtitleString const & b)
return (
a.font() == b.font() &&
a.italic() == b.italic() &&
+ a.bold() == b.bold() &&
a.colour() == b.colour() &&
a.size() == b.size() &&
fabs (a.aspect_adjust() - b.aspect_adjust()) < ASPECT_ADJUST_EPSILON &&
@@ -107,12 +110,18 @@ dcp::operator<< (ostream& s, SubtitleString const & sub)
<< "font " << sub.font().get_value_or ("[default]") << ", ";
if (sub.italic()) {
- s << "italic";
+ s << "italic, ";
} else {
- s << "non-italic";
+ s << "non-italic, ";
}
- s << ", size " << sub.size() << ", aspect " << sub.aspect_adjust() << ", colour " << sub.colour()
+ if (sub.bold()) {
+ s << "bold, ";
+ } else {
+ s << "normal, ";
+ }
+
+ s << "size " << sub.size() << ", aspect " << sub.aspect_adjust() << ", colour " << sub.colour()
<< ", vpos " << sub.v_position() << ", valign " << ((int) sub.v_align())
<< ", hpos " << sub.h_position() << ", halign " << ((int) sub.h_align())
<< ", effect " << ((int) sub.effect()) << ", effect colour " << sub.effect_colour();
diff --git a/src/subtitle_string.h b/src/subtitle_string.h
index eaea94c0..bd71b8da 100644
--- a/src/subtitle_string.h
+++ b/src/subtitle_string.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -40,6 +40,7 @@ public:
SubtitleString (
boost::optional<std::string> font,
bool italic,
+ bool bold,
Colour colour,
int size,
float aspect_adjust,
@@ -65,6 +66,10 @@ public:
return _italic;
}
+ bool bold () const {
+ return _bold;
+ }
+
Colour colour () const {
return _colour;
}
@@ -163,6 +168,8 @@ private:
boost::optional<std::string> _font;
/** true if the text is italic */
bool _italic;
+ /** true if the weight is bold, false for normal */
+ bool _bold;
/** text colour */
Colour _colour;
/** Size in points as if the screen height is 11 inches, so a 72pt font
diff --git a/test/asset_test.cc b/test/asset_test.cc
index c53aca68..caf5e76c 100644
--- a/test/asset_test.cc
+++ b/test/asset_test.cc
@@ -26,7 +26,7 @@ using boost::shared_ptr;
class DummyAsset : public dcp::Asset
{
protected:
- std::string pkl_type (dcp::Standard standard) const {
+ std::string pkl_type (dcp::Standard) const {
return "none";
}
};
diff --git a/test/read_interop_subtitle_test.cc b/test/read_interop_subtitle_test.cc
index a66327f1..7cbb5803 100644
--- a/test/read_interop_subtitle_test.cc
+++ b/test/read_interop_subtitle_test.cc
@@ -49,6 +49,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test1)
BOOST_CHECK_EQUAL (s.front(), dcp::SubtitleString (
string ("theFontId"),
false,
+ false,
dcp::Colour (255, 255, 255),
39,
1.0,
@@ -70,6 +71,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test1)
BOOST_CHECK_EQUAL (s.front(), dcp::SubtitleString (
string ("theFontId"),
true,
+ false,
dcp::Colour (255, 255, 255),
39,
1.0,
@@ -88,6 +90,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test1)
BOOST_CHECK_EQUAL (s.back(), dcp::SubtitleString (
string ("theFontId"),
false,
+ false,
dcp::Colour (255, 255, 255),
39,
1.0,
@@ -109,6 +112,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test1)
BOOST_CHECK_EQUAL (s.back(), dcp::SubtitleString (
string ("theFontId"),
false,
+ false,
dcp::Colour (255, 255, 255),
39,
1.0,
@@ -130,6 +134,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test1)
BOOST_CHECK_EQUAL (s.back(), dcp::SubtitleString (
string ("theFontId"),
false,
+ false,
dcp::Colour (255, 255, 255),
39,
1.0,
@@ -157,6 +162,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
BOOST_CHECK_EQUAL (s.front(), dcp::SubtitleString (
string ("theFont"),
true,
+ false,
dcp::Colour (255, 255, 255),
42,
1.0,
@@ -175,6 +181,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
BOOST_CHECK_EQUAL (s.back(), dcp::SubtitleString (
string ("theFont"),
true,
+ false,
dcp::Colour (255, 255, 255),
42,
1.0,
@@ -196,6 +203,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
BOOST_CHECK_EQUAL (s.front(), dcp::SubtitleString (
string ("theFont"),
true,
+ false,
dcp::Colour (255, 255, 255),
42,
1.0,
@@ -214,6 +222,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
BOOST_CHECK_EQUAL (s.back(), dcp::SubtitleString (
string ("theFont"),
true,
+ false,
dcp::Colour (255, 255, 255),
42,
1.0,
@@ -235,6 +244,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
BOOST_CHECK_EQUAL (s.front(), dcp::SubtitleString (
string ("theFont"),
true,
+ false,
dcp::Colour (255, 255, 255),
42,
1.0,
@@ -253,6 +263,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
BOOST_CHECK_EQUAL (s.back(), dcp::SubtitleString (
string ("theFont"),
true,
+ false,
dcp::Colour (255, 255, 255),
42,
1.0,
@@ -274,6 +285,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
BOOST_CHECK_EQUAL (s.front(), dcp::SubtitleString (
string ("theFont"),
true,
+ false,
dcp::Colour (255, 255, 255),
42,
1.0,
@@ -292,6 +304,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
BOOST_CHECK_EQUAL (s.back(), dcp::SubtitleString (
string ("theFont"),
true,
+ false,
dcp::Colour (255, 255, 255),
42,
1.0,
@@ -313,6 +326,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
BOOST_CHECK_EQUAL (s.front(), dcp::SubtitleString (
string ("theFont"),
true,
+ false,
dcp::Colour (255, 255, 255),
42,
1.0,
@@ -331,6 +345,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
BOOST_CHECK_EQUAL (s.back(), dcp::SubtitleString (
string ("theFont"),
true,
+ false,
dcp::Colour (255, 255, 255),
42,
1.0,
@@ -352,6 +367,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
BOOST_CHECK_EQUAL (s.front(), dcp::SubtitleString (
string ("theFont"),
false,
+ false,
dcp::Colour (255, 255, 255),
42,
1.0,
@@ -370,6 +386,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
BOOST_CHECK_EQUAL (s.back(), dcp::SubtitleString (
string ("theFont"),
false,
+ false,
dcp::Colour (255, 255, 255),
42,
1.0,
@@ -391,6 +408,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
BOOST_CHECK_EQUAL (s.front(), dcp::SubtitleString (
string ("theFont"),
false,
+ false,
dcp::Colour (255, 255, 255),
42,
1.0,
@@ -409,6 +427,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
BOOST_CHECK_EQUAL (s.back(), dcp::SubtitleString (
string ("theFont"),
false,
+ false,
dcp::Colour (255, 255, 255),
42,
1.0,
@@ -430,6 +449,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
BOOST_CHECK_EQUAL (s.front(), dcp::SubtitleString (
string ("theFont"),
false,
+ false,
dcp::Colour (255, 255, 255),
42,
1.0,
@@ -448,6 +468,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
BOOST_CHECK_EQUAL (s.back(), dcp::SubtitleString (
string ("theFont"),
false,
+ false,
dcp::Colour (255, 255, 255),
42,
1.0,
@@ -469,6 +490,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
BOOST_CHECK_EQUAL (s.front(), dcp::SubtitleString (
string ("theFont"),
true,
+ false,
dcp::Colour (255, 255, 255),
42,
1.0,
@@ -487,6 +509,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
BOOST_CHECK_EQUAL (s.back(), dcp::SubtitleString (
string ("theFont"),
true,
+ false,
dcp::Colour (255, 255, 255),
42,
1.0,
diff --git a/test/write_subtitle_test.cc b/test/write_subtitle_test.cc
index 8b50b0e3..e407b81f 100644
--- a/test/write_subtitle_test.cc
+++ b/test/write_subtitle_test.cc
@@ -38,6 +38,7 @@ BOOST_AUTO_TEST_CASE (write_subtitle_test)
dcp::SubtitleString (
string ("Frutiger"),
false,
+ false,
dcp::Colour (255, 255, 255),
48,
1.0,
@@ -59,6 +60,7 @@ BOOST_AUTO_TEST_CASE (write_subtitle_test)
dcp::SubtitleString (
boost::optional<string> (),
true,
+ false,
dcp::Colour (128, 0, 64),
91,
1.0,