fonts: Use FontInstanceFlags::EMBEDDED_BITMAPS for color fonts on MacOS (#32203)

This flag ensures that these fonts are rendered full color in WebRender,
allowing for full color emoji.
This commit is contained in:
Martin Robinson 2024-05-02 08:50:59 +02:00 committed by GitHub
parent 60613e77c5
commit 928214518c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 471 additions and 38 deletions

View file

@ -19,11 +19,12 @@ use core_text::font_descriptor::{
};
use log::debug;
use style::values::computed::font::{FontStretch, FontStyle, FontWeight};
use webrender_api::FontInstanceFlags;
use super::core_text_font_cache::CoreTextFontCache;
use crate::font::{
map_platform_values_to_style_values, FontMetrics, FontTableMethods, FontTableTag,
FractionalPixel, PlatformFontMethods, GPOS, GSUB, KERN,
FractionalPixel, PlatformFontMethods, CBDT, COLR, GPOS, GSUB, KERN, SBIX,
};
use crate::font_cache_thread::FontIdentifier;
use crate::font_template::FontTemplateDescriptor;
@ -298,6 +299,18 @@ impl PlatformFontMethods for PlatformFont {
let result: Option<CFData> = self.ctfont.get_font_table(tag);
result.map(FontTable::wrap)
}
/// Get the necessary [`FontInstanceFlags`]` for this font.
fn webrender_font_instance_flags(&self) -> FontInstanceFlags {
// TODO: Should this also validate these tables?
if self.table_for_tag(COLR).is_some() ||
self.table_for_tag(CBDT).is_some() ||
self.table_for_tag(SBIX).is_some()
{
return FontInstanceFlags::EMBEDDED_BITMAPS;
}
FontInstanceFlags::empty()
}
}
pub(super) trait CoreTextFontTraitsMapping {