mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-01-08 18:25:30 +00:00
textwrap: do not insert spaces before punctuation
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/474>
This commit is contained in:
parent
1cd5d5ef45
commit
ab251ec573
1 changed files with 5 additions and 1 deletions
|
@ -91,6 +91,10 @@ pub struct TextWrap {
|
|||
state: Mutex<State>,
|
||||
}
|
||||
|
||||
fn is_punctuation(word: &str) -> bool {
|
||||
word == "." || word == "," || word == "?" || word == "!" || word == ";" || word == ":"
|
||||
}
|
||||
|
||||
impl TextWrap {
|
||||
fn update_wrapper(&self, element: &super::TextWrap) {
|
||||
let settings = self.settings.lock().unwrap();
|
||||
|
@ -205,7 +209,7 @@ impl TextWrap {
|
|||
let mut current_text = state.current_text.to_string();
|
||||
|
||||
for word in words {
|
||||
if !current_text.is_empty() {
|
||||
if !current_text.is_empty() && !is_punctuation(word) {
|
||||
current_text.push(' ');
|
||||
}
|
||||
current_text.push_str(word);
|
||||
|
|
Loading…
Reference in a new issue