Improve heuristic for splitting up whitespace
This commit is contained in:
parent
8b57e23906
commit
92634bf720
1 changed files with 8 additions and 7 deletions
|
|
@ -179,15 +179,16 @@ impl<'a> FontMatches<'a> {
|
||||||
let mut start_word = 0;
|
let mut start_word = 0;
|
||||||
for (end_lb, _) in unicode_linebreak::linebreaks(span) {
|
for (end_lb, _) in unicode_linebreak::linebreaks(span) {
|
||||||
let mut start_lb = end_lb;
|
let mut start_lb = end_lb;
|
||||||
if end_lb != span.len() {
|
for (i, c) in span[start_word..end_lb].char_indices() {
|
||||||
while start_lb > 1 {
|
if start_word + i == end_lb {
|
||||||
start_lb -= 1;
|
break;
|
||||||
if span.is_char_boundary(start_lb) {
|
} else if c.is_whitespace() {
|
||||||
break;
|
start_lb = start_word + i;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
words.push(self.shape_word(0, line, start_span + start_word, start_span + start_lb, span_rtl, false));
|
if start_word < start_lb {
|
||||||
|
words.push(self.shape_word(0, line, start_span + start_word, start_span + start_lb, span_rtl, false));
|
||||||
|
}
|
||||||
if start_lb < end_lb {
|
if start_lb < end_lb {
|
||||||
words.push(self.shape_word(0, line, start_span + start_lb, start_span + end_lb, span_rtl, true));
|
words.push(self.shape_word(0, line, start_span + start_lb, start_span + end_lb, span_rtl, true));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue