mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Lazy load fonts in a FontGroup
This is a step towards fixing #17267. To fix that, we need to be able to try various different fallback fonts in turn, which would become unweildy with the prior eager-loading strategy. Prior to this change, FontGroup loaded up all Font instances, including the fallback font, before any of them were checked for the presence of the glyphs we're trying to render. So for the following CSS: font-family: Helvetica, Arial; The FontGroup would contain a Font instance for Helvetica, and a Font instance for Arial, and a Font instance for the fallback font. It may be that Helvetica contains glyphs for every character in the document, and therefore Arial and the fallback font are not needed at all. This change makes the strategy lazy, so that we'll only create a Font for Arial if we cannot find a glyph within Helvetica. I've also substantially refactored the existing code in the process and added some documentation along the way.
This commit is contained in:
parent
691f3be24a
commit
f22e5ef3bd
7 changed files with 345 additions and 211 deletions
|
@ -18,6 +18,7 @@ use font::{FontHandleMethods, FontMetrics, FontTableMethods, FontTableTag, Fract
|
|||
use font::{GPOS, GSUB, KERN};
|
||||
use platform::font_template::FontTemplateData;
|
||||
use platform::macos::font_context::FontContextHandle;
|
||||
use servo_atoms::Atom;
|
||||
use std::{fmt, ptr};
|
||||
use std::ops::Range;
|
||||
use std::sync::Arc;
|
||||
|
@ -318,4 +319,8 @@ impl FontHandleMethods for FontHandle {
|
|||
Some(FontTable::wrap(data))
|
||||
})
|
||||
}
|
||||
|
||||
fn identifier(&self) -> Atom {
|
||||
self.font_data.identifier.clone()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue