Don't perform font matching for control characters

We can encounter control characters here, for example when processing a
<pre> element which contains newlines. Control characters are inherently
non-printing, therefore if we try to call find_by_codepoint for these
characters we will end up triggering an unnecessary font fallback
search.
This commit is contained in:
Jon Leighton 2018-04-06 10:54:13 +10:00
parent 691c6c6f1a
commit 4403bcddfe

View file

@ -215,6 +215,7 @@ impl TextRunScanner {
let (mut start_position, mut end_position) = (0, 0);
for (byte_index, character) in text.char_indices() {
if !character.is_control() {
let font = font_group.borrow_mut().find_by_codepoint(&mut font_context, character);
let bidi_level = match bidi_levels {
@ -271,6 +272,7 @@ impl TextRunScanner {
run_info.script = script;
mapping.selected = selected;
}
}
// Consume this character.
end_position += character.len_utf8();