mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
fonts: Remove the per-FontGroup cached fallback font (#35705)
Instead of keeping a per-FontGroup cache of the previously used fallback font, cache this value in the caller of `FontGroup::find_by_codepoint`. The problem with caching this value in the `FontGroup` is that it can make one layout different from the next. Still, it is important to cache the value somewhere so that, for instance, Chinese character don't have to continuously walk through the entire fallback list when laying out. The heuristic here is to try to last used font first if the `Script`s match. At the very least this should make one layout consistent with the next. Fixes #35704. Fixes #35697. Fixes #35689. Fixes #35679. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
06d4272462
commit
f949d2adc8
13 changed files with 43 additions and 38 deletions
|
@ -568,8 +568,6 @@ pub type FontRef = Arc<Font>;
|
|||
pub struct FontGroup {
|
||||
descriptor: FontDescriptor,
|
||||
families: SmallVec<[FontGroupFamily; 8]>,
|
||||
#[ignore_malloc_size_of = "This measured in the FontContext font cache."]
|
||||
last_matching_fallback: Option<FontRef>,
|
||||
}
|
||||
|
||||
impl FontGroup {
|
||||
|
@ -584,7 +582,6 @@ impl FontGroup {
|
|||
FontGroup {
|
||||
descriptor,
|
||||
families,
|
||||
last_matching_fallback: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -597,6 +594,7 @@ impl FontGroup {
|
|||
font_context: &FontContext,
|
||||
codepoint: char,
|
||||
next_codepoint: Option<char>,
|
||||
first_fallback: Option<FontRef>,
|
||||
) -> Option<FontRef> {
|
||||
// Tab characters are converted into spaces when rendering.
|
||||
// TODO: We should not render a tab character. Instead they should be converted into tab stops
|
||||
|
@ -642,11 +640,11 @@ impl FontGroup {
|
|||
return font_or_synthesized_small_caps(font);
|
||||
}
|
||||
|
||||
if let Some(ref last_matching_fallback) = self.last_matching_fallback {
|
||||
if char_in_template(last_matching_fallback.template.clone()) &&
|
||||
font_has_glyph_and_presentation(last_matching_fallback)
|
||||
if let Some(ref first_fallback) = first_fallback {
|
||||
if char_in_template(first_fallback.template.clone()) &&
|
||||
font_has_glyph_and_presentation(first_fallback)
|
||||
{
|
||||
return font_or_synthesized_small_caps(last_matching_fallback.clone());
|
||||
return font_or_synthesized_small_caps(first_fallback.clone());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -656,7 +654,6 @@ impl FontGroup {
|
|||
char_in_template,
|
||||
font_has_glyph_and_presentation,
|
||||
) {
|
||||
self.last_matching_fallback = Some(font.clone());
|
||||
return font_or_synthesized_small_caps(font);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue