summaryrefslogtreecommitdiff
path: root/modules/text_server_fb
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2021-11-04 14:33:37 +0200
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2022-04-28 14:35:41 +0300
commit6ab672d1ef7ece5c3019d46aeb98df3686f37e26 (patch)
treebe10d088e90c6a9e60efef823f54f9aa0d70aa07 /modules/text_server_fb
parent3e1b824c050b765095285c67b3e4c8092e1f88c6 (diff)
Implement text-to-speech support on Android, iOS, HTML5, Linux, macOS and Windows.
Implement TextServer word break method.
Diffstat (limited to 'modules/text_server_fb')
-rw-r--r--modules/text_server_fb/text_server_fb.cpp25
-rw-r--r--modules/text_server_fb/text_server_fb.h2
2 files changed, 26 insertions, 1 deletions
diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp
index 1251aaf2b9..d84e9e581a 100644
--- a/modules/text_server_fb/text_server_fb.cpp
+++ b/modules/text_server_fb/text_server_fb.cpp
@@ -3079,7 +3079,7 @@ bool TextServerFallback::shaped_text_update_breaks(const RID &p_shaped) {
if (sd_glyphs[i].count > 0) {
char32_t c = sd->text[sd_glyphs[i].start - sd->start];
if (c_punct_size == 0) {
- if (is_punct(c)) {
+ if (is_punct(c) && c != 0x005F) {
sd_glyphs[i].flags |= GRAPHEME_IS_PUNCTUATION;
}
} else {
@@ -3623,6 +3623,29 @@ String TextServerFallback::string_to_lower(const String &p_string, const String
return lower;
}
+PackedInt32Array TextServerFallback::string_get_word_breaks(const String &p_string, const String &p_language) const {
+ PackedInt32Array ret;
+ for (int i = 0; i < p_string.length(); i++) {
+ char32_t c = p_string[i];
+ if (c == 0xfffc) {
+ continue;
+ }
+ if (is_punct(c) && c != 0x005F) {
+ ret.push_back(i);
+ continue;
+ }
+ if (is_underscore(c)) {
+ ret.push_back(i);
+ continue;
+ }
+ if (is_whitespace(c) || is_linebreak(c)) {
+ ret.push_back(i);
+ continue;
+ }
+ }
+ return ret;
+}
+
TextServerFallback::TextServerFallback() {
_insert_feature_sets();
};
diff --git a/modules/text_server_fb/text_server_fb.h b/modules/text_server_fb/text_server_fb.h
index d6f61e02f8..c837029623 100644
--- a/modules/text_server_fb/text_server_fb.h
+++ b/modules/text_server_fb/text_server_fb.h
@@ -573,6 +573,8 @@ public:
virtual double shaped_text_get_underline_position(const RID &p_shaped) const override;
virtual double shaped_text_get_underline_thickness(const RID &p_shaped) const override;
+ virtual PackedInt32Array string_get_word_breaks(const String &p_string, const String &p_language = "") const override;
+
virtual String string_to_upper(const String &p_string, const String &p_language = "") const override;
virtual String string_to_lower(const String &p_string, const String &p_language = "") const override;