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

@ -25,7 +25,9 @@ use script_traits::{
};
use style_traits::CSSPixel;
use webrender_api::units::{DeviceIntPoint, DeviceIntSize, DeviceRect};
use webrender_api::{self, FontInstanceKey, FontKey, ImageKey, NativeFontHandle};
use webrender_api::{
self, FontInstanceFlags, FontInstanceKey, FontKey, ImageKey, NativeFontHandle,
};
/// Sends messages to the compositor.
pub struct CompositorProxy {
@ -139,7 +141,7 @@ pub struct CompositionPipeline {
}
pub enum FontToCompositorMsg {
AddFontInstance(FontKey, f32, Sender<FontInstanceKey>),
AddFontInstance(FontKey, f32, FontInstanceFlags, Sender<FontInstanceKey>),
AddFont(Sender<FontKey>, u32, ipc_channel::ipc::IpcBytesReceiver),
AddSystemFont(Sender<FontKey>, NativeFontHandle),
}

View file

@ -14,7 +14,9 @@ use std::sync::Arc;
use malloc_size_of_derive::MallocSizeOf;
use range::{int_range_index, RangeIndex};
use serde::{Deserialize, Serialize};
use webrender_api::{Epoch as WebRenderEpoch, FontInstanceKey, FontKey, NativeFontHandle};
use webrender_api::{
Epoch as WebRenderEpoch, FontInstanceFlags, FontInstanceKey, FontKey, NativeFontHandle,
};
/// A newtype struct for denoting the age of messages; prevents race conditions.
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
@ -121,7 +123,12 @@ pub fn node_id_from_scroll_id(id: usize) -> Option<usize> {
}
pub trait WebrenderApi {
fn add_font_instance(&self, font_key: FontKey, size: f32) -> FontInstanceKey;
fn add_font_instance(
&self,
font_key: FontKey,
size: f32,
flags: FontInstanceFlags,
) -> FontInstanceKey;
fn add_font(&self, data: Arc<Vec<u8>>, index: u32) -> FontKey;
fn add_system_font(&self, handle: NativeFontHandle) -> FontKey;
}