mirror of
https://github.com/servo/servo.git
synced 2025-08-12 08:55:32 +01:00
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:
parent
60613e77c5
commit
928214518c
12 changed files with 471 additions and 38 deletions
|
@ -20,6 +20,7 @@ use log::debug;
|
|||
use style::computed_values::font_stretch::T as FontStretch;
|
||||
use style::computed_values::font_weight::T as FontWeight;
|
||||
use style::values::computed::font::FontStyle;
|
||||
use webrender_api::FontInstanceFlags;
|
||||
|
||||
use super::library_handle::FreeTypeLibraryHandle;
|
||||
use crate::font::{
|
||||
|
@ -313,6 +314,10 @@ impl PlatformFontMethods for PlatformFont {
|
|||
Some(FontTable { buffer: buf })
|
||||
}
|
||||
}
|
||||
|
||||
fn webrender_font_instance_flags(&self) -> FontInstanceFlags {
|
||||
FontInstanceFlags::empty()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> PlatformFont {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -20,6 +20,7 @@ use style::computed_values::font_weight::T as StyleFontWeight;
|
|||
use style::values::computed::font::FontStyle as StyleFontStyle;
|
||||
use truetype::tables::WindowsMetrics;
|
||||
use truetype::value::Read;
|
||||
use webrender_api::FontInstanceFlags;
|
||||
|
||||
use crate::font::{
|
||||
FontMetrics, FontTableMethods, FontTableTag, FractionalPixel, PlatformFontMethods,
|
||||
|
@ -254,4 +255,8 @@ impl PlatformFontMethods for PlatformFont {
|
|||
.get_font_table(tag)
|
||||
.map(|bytes| FontTable { data: bytes })
|
||||
}
|
||||
|
||||
fn webrender_font_instance_flags(&self) -> FontInstanceFlags {
|
||||
FontInstanceFlags::empty()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue