break;
}
- if (c >= 0x80 && c <= 0x83) {
- /* Italic or underline control code */
+ if (c <= 0x07 || (c >= 0x80 && c <= 0x83)) {
+ /* Colour, italic or underline control code */
sub.text = utf_to_utf<char> (iso6937_to_utf16 (text.c_str()));
_subs.push_back (sub);
text.clear ();
}
switch (c) {
+ case 0x0:
+ /* Black */
+ sub.colour = Colour(0, 0, 0);
+ break;
+ case 0x1:
+ /* Red */
+ sub.colour = Colour(1, 0, 0);
+ break;
+ case 0x2:
+ /* Lime */
+ sub.colour = Colour(0, 1, 0);
+ break;
+ case 0x3:
+ /* Yellow */
+ sub.colour = Colour(1, 1, 0);
+ break;
+ case 0x4:
+ /* Blue */
+ sub.colour = Colour(0, 0, 1);
+ break;
+ case 0x5:
+ /* Magenta */
+ sub.colour = Colour(1, 0, 1);
+ break;
+ case 0x6:
+ /* Cyan */
+ sub.colour = Colour(0, 1, 1);
+ break;
+ case 0x7:
+ /* White */
+ sub.colour = Colour(1, 1, 1);
+ break;
case 0x80:
italic = true;
break;
*/
+
#include "stl_binary_reader.h"
#include "subtitle.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
#include <fstream>
+
using std::ifstream;
+using std::make_shared;
using std::ofstream;
using std::shared_ptr;
-using std::make_shared;
+using std::vector;
+
/* Test reading of a binary STL file */
BOOST_AUTO_TEST_CASE (stl_binary_reader_test1)
}
}
+
+BOOST_AUTO_TEST_CASE(stl_binary_reader_with_colour)
+{
+ auto path = private_test / "at.stl";
+ ifstream in(path.string().c_str());
+ auto reader = make_shared<sub::STLBinaryReader>(in);
+
+ vector<sub::Colour> reference = {
+ { 1, 1, 1 },
+ { 1, 0, 1 },
+ { 1, 1, 1 },
+ { 1, 0, 1 },
+ { 1, 1, 1 },
+ { 1, 1, 0 },
+ { 1, 1, 1 },
+ { 1, 1, 0 },
+ { 1, 1, 1 },
+ { 1, 1, 0 },
+ { 1, 1, 1 },
+ { 1, 1, 0 },
+ { 1, 1, 1 },
+ { 1, 1, 0 }
+ };
+
+ /* Check the first few lines */
+ auto subs = reader->subtitles();
+ BOOST_REQUIRE(subs.size() >= reference.size());
+
+ for (size_t i = 0; i < reference.size(); ++i) {
+ BOOST_CHECK(subs[i].colour == reference[i]);
+ }
+}
+