diff options
author | Mathieu Duponchelle <mathieu@centricular.com> | 2021-02-10 18:58:09 +0300 |
---|---|---|
committer | GStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2021-02-15 22:25:18 +0300 |
commit | ab251ec5736620efbed67d87f90410719a160eb1 (patch) | |
tree | 8b27eabe8b32856390a720cf2b80754473276b2c /text | |
parent | 1cd5d5ef45a9df8fe7f5c98ca60cc591bced60bd (diff) |
textwrap: do not insert spaces before punctuation
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/474>
Diffstat (limited to 'text')
-rw-r--r-- | text/wrap/src/gsttextwrap/imp.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/text/wrap/src/gsttextwrap/imp.rs b/text/wrap/src/gsttextwrap/imp.rs index 0d62fd37e..9c381cfdd 100644 --- a/text/wrap/src/gsttextwrap/imp.rs +++ b/text/wrap/src/gsttextwrap/imp.rs @@ -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); |