mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-23 02:26:35 +00:00
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:
parent
20607fe346
commit
19611f0ebe
1 changed files with 10 additions and 0 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue