diff options
author | Martin Robinson <mrobinson@igalia.com> | 2024-05-27 12:02:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-27 10:02:26 +0000 |
commit | 43a3c9c319e6406c92254031cd05ca23609102ef (patch) | |
tree | 257e45934118b6be3833a5f03f0b50596f12c186 /components/gfx/tests | |
parent | 5f0866379a731628c535593d0022b91cfabfb868 (diff) | |
download | servo-43a3c9c319e6406c92254031cd05ca23609102ef.tar.gz servo-43a3c9c319e6406c92254031cd05ca23609102ef.zip |
fonts: Improve font fallback (#32286)
- Better detect situations where emoji is necessary by looking ahead one
character while laying out. This allow processing Unicode presentation
selectors. When detecting emoji, put emoji fonts at the front of
fallback lists for all platforms.
This enables monochrome emoji on Windows. Full-color emoji on Windows
probably needs full support for processing the COLR table and drawing
separate glyph color layers.
- Improve the font fallback list on FreeType platforms. Ideally, Servo
would be able to look through the entire font list to find the best
font for a certain character, but until that time we can make sure the
font list contains the "Noto Sans" fonts which cover most situations.
Fixes #31664.
Fixes #12944.
Diffstat (limited to 'components/gfx/tests')
-rw-r--r-- | components/gfx/tests/font_context.rs | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/components/gfx/tests/font_context.rs b/components/gfx/tests/font_context.rs index dc61775db18..85f3159bbd5 100644 --- a/components/gfx/tests/font_context.rs +++ b/components/gfx/tests/font_context.rs @@ -17,6 +17,7 @@ use gfx::font_cache_thread::{CSSFontFaceDescriptors, FontIdentifier, FontSource} use gfx::font_context::FontContext; use gfx::font_store::FontTemplates; use gfx::font_template::{FontTemplate, FontTemplateRef}; +use gfx::text::FallbackFontSelectionOptions; use ipc_channel::ipc; use net_traits::ResourceThreads; use servo_arc::Arc; @@ -53,7 +54,10 @@ impl MockFontCacheThread { let mut families = HashMap::new(); families.insert("CSSTest ASCII".to_owned(), csstest_ascii); families.insert("CSSTest Basic".to_owned(), csstest_basic); - families.insert(fallback_font_families(None)[0].to_owned(), fallback); + families.insert( + fallback_font_families(FallbackFontSelectionOptions::default())[0].to_owned(), + fallback, + ); MockFontCacheThread { families: RefCell::new(families), @@ -211,7 +215,10 @@ fn test_font_group_find_by_codepoint() { let group = context.font_group(Arc::new(style)); - let font = group.write().find_by_codepoint(&mut context, 'a').unwrap(); + let font = group + .write() + .find_by_codepoint(&mut context, 'a', None) + .unwrap(); assert_eq!( font.identifier(), MockFontCacheThread::identifier_for_font_name("csstest-ascii") @@ -222,7 +229,10 @@ fn test_font_group_find_by_codepoint() { "only the first font in the list should have been loaded" ); - let font = group.write().find_by_codepoint(&mut context, 'a').unwrap(); + let font = group + .write() + .find_by_codepoint(&mut context, 'a', None) + .unwrap(); assert_eq!( font.identifier(), MockFontCacheThread::identifier_for_font_name("csstest-ascii") @@ -233,7 +243,10 @@ fn test_font_group_find_by_codepoint() { "we shouldn't load the same font a second time" ); - let font = group.write().find_by_codepoint(&mut context, 'á').unwrap(); + let font = group + .write() + .find_by_codepoint(&mut context, 'á', None) + .unwrap(); assert_eq!( font.identifier(), MockFontCacheThread::identifier_for_font_name("csstest-basic-regular") @@ -251,14 +264,20 @@ fn test_font_fallback() { let group = context.font_group(Arc::new(style)); - let font = group.write().find_by_codepoint(&mut context, 'a').unwrap(); + let font = group + .write() + .find_by_codepoint(&mut context, 'a', None) + .unwrap(); assert_eq!( font.identifier(), MockFontCacheThread::identifier_for_font_name("csstest-ascii"), "a family in the group should be used if there is a matching glyph" ); - let font = group.write().find_by_codepoint(&mut context, 'á').unwrap(); + let font = group + .write() + .find_by_codepoint(&mut context, 'á', None) + .unwrap(); assert_eq!( font.identifier(), MockFontCacheThread::identifier_for_font_name("csstest-basic-regular"), |