diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2020-12-14 10:30:32 +0200 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2020-12-14 11:36:13 +0200 |
commit | 06ae77a320ba7b83616e4a30b1f40152bd1d3a82 (patch) | |
tree | 1d94965bd74e8a703dbea10109672ddbeea53bc8 /modules/text_server_adv | |
parent | 06314c1b0e8100546a53cf2786fa244c5d19af6f (diff) |
Add word breaks on punctuation characters.
Diffstat (limited to 'modules/text_server_adv')
-rw-r--r-- | modules/text_server_adv/text_server_adv.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index 803004f93f..3a706286e5 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -1645,13 +1645,18 @@ bool TextServerAdvanced::shaped_text_update_breaks(RID p_shaped) { if (c == 0x0009 || c == 0x000b) { sd_glyphs[i].flags |= GRAPHEME_IS_TAB; } + if (is_whitespace(c)) { + sd_glyphs[i].flags |= GRAPHEME_IS_SPACE; + } + if (u_ispunct(c)) { + sd_glyphs[i].flags |= GRAPHEME_IS_PUNCTUATION; + } if (breaks.has(sd->glyphs[i].start)) { if (breaks[sd->glyphs[i].start]) { sd_glyphs[i].flags |= GRAPHEME_IS_BREAK_HARD; } else { if (is_whitespace(c)) { sd_glyphs[i].flags |= GRAPHEME_IS_BREAK_SOFT; - sd_glyphs[i].flags |= GRAPHEME_IS_SPACE; } else { TextServer::Glyph gl; gl.start = sd_glyphs[i].start; @@ -1766,6 +1771,10 @@ bool TextServerAdvanced::shaped_text_update_justification_ops(RID p_shaped) { shaped_text_update_breaks(p_shaped); } + if (sd->justification_ops_valid) { + return true; // Noting to do. + } + const UChar *data = sd->utf16.ptr(); int32_t data_size = sd->utf16.length(); @@ -1796,9 +1805,9 @@ bool TextServerAdvanced::shaped_text_update_justification_ops(RID p_shaped) { if (ubrk_getRuleStatus(bi) != UBRK_WORD_NONE) { int i = _convert_pos(sd, ubrk_current(bi)); jstops[i + sd->start] = false; - int ks = _generate_kashida_justification_opportunies(sd->text, limit, i) + sd->start; + int ks = _generate_kashida_justification_opportunies(sd->text, limit, i); if (ks != -1) { - jstops[ks] = true; + jstops[ks + sd->start] = true; } limit = i; } |