gecko-dev/servo/components/gfx/platform
Jon Leighton 62986df7ba servo: Merge #20021 - Lazy load fonts in a FontGroup (from jonleighton:lazy-font-group); r=mbrubeck,glennw
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.)

Source-Repo: https://github.com/servo/servo
Source-Revision: f48dce120dddd8e3d585cfc8bc221faa2726bf6b

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : fb8733e63bb69d941051bf4aff8a86c396c85f8e
2018-02-22 10:49:52 -05:00
..
freetype servo: Merge #20021 - Lazy load fonts in a FontGroup (from jonleighton:lazy-font-group); r=mbrubeck,glennw 2018-02-22 10:49:52 -05:00
macos servo: Merge #20021 - Lazy load fonts in a FontGroup (from jonleighton:lazy-font-group); r=mbrubeck,glennw 2018-02-22 10:49:52 -05:00
windows servo: Merge #20021 - Lazy load fonts in a FontGroup (from jonleighton:lazy-font-group); r=mbrubeck,glennw 2018-02-22 10:49:52 -05:00
mod.rs servo: Merge #17141 - Ged rid of libfontconfig in Android (from MortimerGoro:android_fonts); r=mbrubeck 2017-06-06 13:29:05 -07:00