Tweak ISO6937 mapping to put $ sign on 0xa4 (164) (from master).
[libsub.git] / src / ssa_reader.cc
index 05c908e2c86b3c1bbfef35d940116eea57342298..147f1bad75691a7c2bddd9caee6b9da2b3a27e0d 100644 (file)
 #include "sub_assert.h"
 #include "raw_convert.h"
 #include "subtitle.h"
+#include <locked_sstream.h>
 #include <boost/algorithm/string.hpp>
 #include <boost/bind.hpp>
 #include <boost/foreach.hpp>
-#include <sstream>
 #include <iostream>
 #include <vector>
 
 using std::string;
-using std::stringstream;
 using std::vector;
 using std::map;
 using std::cout;
@@ -43,7 +42,7 @@ using namespace sub;
 /** @param s Subtitle string encoded in UTF-8 */
 SSAReader::SSAReader (string const & s)
 {
-       stringstream str (s);
+       locked_stringstream str (s);
        this->read (boost::bind (&get_line_stringstream, &str));
 }
 
@@ -61,6 +60,7 @@ public:
                , primary_colour (255, 255, 255)
                , bold (false)
                , italic (false)
+               , underline (false)
                , vertical_reference (BOTTOM_OF_SCREEN)
                , vertical_margin (0)
        {}
@@ -70,6 +70,7 @@ public:
                , primary_colour (255, 255, 255)
                , bold (false)
                , italic (false)
+               , underline (false)
                , vertical_reference (BOTTOM_OF_SCREEN)
                , vertical_margin (0)
        {
@@ -99,6 +100,8 @@ public:
                                bold = style[i] == "-1";
                        } else if (keys[i] == "Italic") {
                                italic = style[i] == "-1";
+                       } else if (keys[i] == "Underline") {
+                               underline = style[i] == "-1";
                        } else if (keys[i] == "BorderStyle") {
                                if (style[i] == "1") {
                                        effect = SHADOW;
@@ -130,6 +133,7 @@ public:
        optional<Colour> back_colour;
        bool bold;
        bool italic;
+       bool underline;
        optional<Effect> effect;
        VerticalReference vertical_reference;
        int vertical_margin;
@@ -243,6 +247,10 @@ SSAReader::parse_line (RawSubtitle base, string line)
                                        current.bold = true;
                                } else if (style == "\\b0") {
                                        current.bold = false;
+                               } else if (style == "\\u1") {
+                                       current.underline = true;
+                               } else if (style == "\\u0") {
+                                       current.underline = false;
                                } else if (style == "\\an1" || style == "\\an2" || style == "\\an3") {
                                        current.vertical_position.reference = sub::BOTTOM_OF_SCREEN;
                                } else if (style == "\\an4" || style == "\\an5" || style == "\\an6") {
@@ -389,6 +397,7 @@ SSAReader::read (function<optional<string> ()> get_line)
                                                sub.effect_colour = style.back_colour;
                                                sub.bold = style.bold;
                                                sub.italic = style.italic;
+                                               sub.underline = style.underline;
                                                sub.effect = style.effect;
                                                sub.vertical_position.reference = style.vertical_reference;
                                                sub.vertical_position.proportional = float(style.vertical_margin) / play_res_y;