mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Don't panic when no font is found for a TextRun (#30581)
Instead of panicking when no found is found for a TextRun, instead print a warning. This prevents panics on pages with very large font sizes.
This commit is contained in:
parent
fd31da9102
commit
d7207122c0
4 changed files with 56 additions and 28 deletions
|
@ -14,7 +14,7 @@ use gfx::font::{self, FontMetrics, FontRef, RunMetrics, ShapingFlags, ShapingOpt
|
|||
use gfx::text::glyph::ByteIndex;
|
||||
use gfx::text::text_run::TextRun;
|
||||
use gfx::text::util::{self, CompressionMode};
|
||||
use log::debug;
|
||||
use log::{debug, warn};
|
||||
use range::Range;
|
||||
use servo_atoms::Atom;
|
||||
use style::computed_values::text_rendering::T as TextRendering;
|
||||
|
@ -368,10 +368,16 @@ impl TextRunScanner {
|
|||
}
|
||||
|
||||
// If no font is found (including fallbacks), there's no way we can render.
|
||||
let font = run_info
|
||||
let font = match run_info
|
||||
.font
|
||||
.or_else(|| font_group.borrow_mut().first(&mut font_context))
|
||||
.expect("No font found for text run!");
|
||||
{
|
||||
Some(font) => font,
|
||||
None => {
|
||||
result.push(None);
|
||||
continue;
|
||||
},
|
||||
};
|
||||
|
||||
let (run, break_at_zero) = TextRun::new(
|
||||
&mut *font.borrow_mut(),
|
||||
|
@ -380,13 +386,13 @@ impl TextRunScanner {
|
|||
run_info.bidi_level,
|
||||
linebreaker,
|
||||
);
|
||||
result.push((
|
||||
result.push(Some((
|
||||
ScannedTextRun {
|
||||
run: Arc::new(run),
|
||||
insertion_point: run_info.insertion_point,
|
||||
},
|
||||
break_at_zero,
|
||||
))
|
||||
)))
|
||||
}
|
||||
result
|
||||
};
|
||||
|
@ -417,7 +423,14 @@ impl TextRunScanner {
|
|||
},
|
||||
};
|
||||
let mapping = mappings.next().unwrap();
|
||||
let (scanned_run, break_at_zero) = runs[mapping.text_run_index].clone();
|
||||
let run = runs[mapping.text_run_index].clone();
|
||||
let (scanned_run, break_at_zero) = match run {
|
||||
Some(run) => run,
|
||||
None => {
|
||||
warn!("Could not find found for TextRun!");
|
||||
continue;
|
||||
},
|
||||
};
|
||||
|
||||
let mut byte_range = Range::new(
|
||||
ByteIndex(mapping.byte_range.begin() as isize),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue