This will allow reporting of memory usage by FreeType instances, which
are measured in the MiBs for LayoutWorker threads.
This change also makes FreeType allocations happen with jemalloc instead
of the system malloc, which is a good thing.
Finally, the change documents some dubiousness involving
FontContextHandle.
The util component specified fnv and smallvec as dependencies and publicly
reexported both of them. Several other components utilized these reexports,
presumably because fnv and smallvec used to live in the tree so reexporting
made the transition easier.
These indirect dependencies through the util component are unnecessary.
This commit removes the fnv & smallvec crate reexports in the util component.
It exchange, it adds fnv & smallvec as dependencies to non-util components
wherever needed. Finally, it removes the fnv dependency from util as it is not
utilized anywhere in the util component.
`FontContext::get_layout_font_group_for_style()`.
There are several optimizations here:
* We make font families atoms, to allow for quicker comparisons.
* We precalculate an FNV hash of the relevant fields of the font style
structure.
* When obtaining a platform font group, we first check pointer equality
for the font style. If there's no match, we go to the FNV hash. Only
if both caches miss do we construct and cache a font group. Note that
individual fonts are *also* cached; thus there are two layers of
caching here.
15% improvement in total layout thread time for Facebook Timeline.
Thread font load errors from platform font loading code to
FontContext::get_layout_font_group_for_style, and cache the failure
result, instead of panicing the thread when a font fails to load.
Before this patch, a failed font load would panic a LayoutTask,
causing a cascade of panics, eventually aborting the whole engine
during a panic within panic.
This used to conflict with the util crate from the standard library, which
has long since been removed.
The import in layout has not been changed because of a conflict with the
util mod there.
'oblique' font-style is not supported now.
When I checked freetype.h, same macro is used for italic and oblique.
/* FT_STYLE_FLAG_ITALIC :: */
/* Indicates that a given face style is italic or oblique. */
So, when font style is 'oblique', enable flag for italic.
With tests/html/test_italic_bold.html, it works well.
Previously, any font template that could not be found would return
an item from the last resort font family. Now, the last resort font
family is only searched if the entire list of supplied font families
is empty.
The font cache previously kept weak references to the fonts,
however in layout these fonts are dropped before they are
referenced again, so no caching was being used.
For now, just hold a strong reference in the cache, which means
that fonts will never be thrown out (this will need to be fixed
in the future).