canvas: Remove as much usage of font-kit as possible (#32758)

Do font selection using Servo's font backend, which is shared with the
rest of layout. In addition, delay the creation of the `font-kit` font
until just before rendering with `raqote`. The idea is that when
`raqote` is no longer used, we can drop the `font-kit` dependency.

This change has the side-effect of fixing text rendering in canvas,
adding support for font fallback in canvas, and also correcting a bug in
font selection with size overrides.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This commit is contained in:
Martin Robinson 2024-07-11 06:25:38 +02:00 committed by GitHub
parent c6cb7ee981
commit 4907e89656
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 261 additions and 209 deletions

View file

@ -681,7 +681,11 @@ impl<FCT: FontSource> CachingFontSource<FCT> {
if let Some(font_group) = self.resolved_font_groups.read().get(&cache_key) {
return font_group.clone();
}
let font_group = Arc::new(RwLock::new(FontGroup::new(&cache_key.style)));
let mut descriptor = FontDescriptor::from(&*cache_key.style);
descriptor.pt_size = size;
let font_group = Arc::new(RwLock::new(FontGroup::new(&cache_key.style, descriptor)));
self.resolved_font_groups
.write()
.insert(cache_key, font_group.clone());