tttocea608: be more conservative when inserting spaces

We don't need to insert a space when starting a new line,
or before punctuation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/474>
This commit is contained in:
Mathieu Duponchelle 2021-02-10 21:19:51 +01:00 committed by GStreamer Merge Bot
parent 20607fe346
commit 19611f0ebe

View file

@ -29,6 +29,10 @@ use std::sync::Mutex;
use crate::ttutils::{Cea608Mode, Chunk, Line, Lines, TextStyle};
fn is_punctuation(word: &str) -> bool {
word == "." || word == "," || word == "?" || word == "!" || word == ";" || word == ":"
}
fn is_basicna(cc_data: u16) -> bool {
0x0000 != (0x6000 & cc_data)
}
@ -525,6 +529,8 @@ impl TtToCea608 {
state.underline = chunk.underline;
state.send_roll_up_preamble = false;
ret = false;
} else if *col == self.settings.lock().unwrap().origin_column {
ret = false;
}
if self.open_chunk(element, state, chunk, bufferlist, *col) {
@ -657,6 +663,10 @@ impl TtToCea608 {
col += 1;
}
if is_punctuation(&chunk.text) {
prepend_space = false;
}
let text = {
if prepend_space {
let mut text = " ".to_string();