Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/text
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu@centricular.com>2021-02-10 18:58:09 +0300
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>2021-02-15 22:25:18 +0300
commitab251ec5736620efbed67d87f90410719a160eb1 (patch)
tree8b27eabe8b32856390a720cf2b80754473276b2c /text
parent1cd5d5ef45a9df8fe7f5c98ca60cc591bced60bd (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.rs6
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);