diff options
| author | Carl Hetherington <cth@carlh.net> | 2023-02-24 22:32:13 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2023-02-24 22:32:13 +0100 |
| commit | 5be50d30b8c5360e0b197b708133165095feefc4 (patch) | |
| tree | 11732e8db03bba9a963e1f7638ea7ecf55f693a5 /src | |
| parent | a67eacd9def1b85e7dd79ec192bb975369567bd6 (diff) | |
Support font color attributes with alpha channel (even if it's ignored).v1.6.43
Diffstat (limited to 'src')
| -rw-r--r-- | src/subrip_reader.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/subrip_reader.cc b/src/subrip_reader.cc index a59b43f..268582d 100644 --- a/src/subrip_reader.cc +++ b/src/subrip_reader.cc @@ -269,9 +269,16 @@ SubripReader::convert_line (string t, RawSubtitle& p) ++i; } ++i; - if (boost::regex_search (tag, match, re) && string (match[1]).size() == 6) { - p.colour = Colour::from_rgb_hex (match[1]); - colours.push_back (p.colour); + if (boost::regex_search(tag, match, re)) { + if (string(match[1]).size() == 6) { + p.colour = Colour::from_rgb_hex(match[1]); + colours.push_back(p.colour); + } else if (string(match[1]).size() == 8) { + p.colour = Colour::from_rgba_hex(match[1]); + colours.push_back(p.colour); + } else { + throw SubripError(tag, "a colour in the format #rrggbb #rrggbbaa or rgba(rr,gg,bb,aa)", _context); + } } else { re = boost::regex ( ".*color=\"rgba\\(" @@ -287,7 +294,7 @@ SubripReader::convert_line (string t, RawSubtitle& p) p.colour.b = raw_convert<int>(string(match[3])) / 255.0; colours.push_back (p.colour); } else { - throw SubripError (tag, "a colour in the format #rrggbb or rgba(rr,gg,bb,aa)", _context); + throw SubripError (tag, "a colour in the format #rrggbb #rrggbbaa or rgba(rr,gg,bb,aa)", _context); } } } else if (has_next(t, i, "</font>")) { |
