mirror of
https://github.com/servo/servo.git
synced 2025-06-18 13:24:29 +00:00
Lazy load fonts in a FontGroup The first commit message explains this so I'll just copy it here: --- 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. --- I've added some tests in the second commit, but it required quite a bit of gymnastics to make it possible to write such a test. I'm not sure if the added complexity to the production code is worth it? On the other hand, having this infrastructure in place may be useful for testing future changes in this area, and also possibly brings us a step closer to extracting a library as discussed in #4901. (What I mean by that is: it reduces coupling between `FontCacheThread` and `FontContext` -- the latter would have a place in such a library, the former wouldn't.) <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20021) <!-- Reviewable:end --> |
||
---|---|---|
.. | ||
display_list | ||
tests | ||
animation.rs | ||
block.rs | ||
Cargo.toml | ||
construct.rs | ||
context.rs | ||
data.rs | ||
flex.rs | ||
floats.rs | ||
flow.rs | ||
flow_list.rs | ||
flow_ref.rs | ||
fragment.rs | ||
generated_content.rs | ||
incremental.rs | ||
inline.rs | ||
layout_debug.rs | ||
lib.rs | ||
linked_list.rs | ||
list_item.rs | ||
model.rs | ||
multicol.rs | ||
opaque_node.rs | ||
parallel.rs | ||
persistent_list.rs | ||
query.rs | ||
sequential.rs | ||
table.rs | ||
table_caption.rs | ||
table_cell.rs | ||
table_colgroup.rs | ||
table_row.rs | ||
table_rowgroup.rs | ||
table_wrapper.rs | ||
text.rs | ||
traversal.rs | ||
wrapper.rs |