mirror of
https://github.com/servo/servo.git
synced 2025-08-11 08:25:32 +01:00
fonts: Add support for more @font-face features (#32164)
There are a couple major changes here: 1. Support is added for the `weight`, `style`, `stretch` and `unicode-range` declarations in `@font-face`. 2. Font matching in the font cache can return templates and `FontGroupFamily` can own mulitple templates. This is due to needing support for "composite fonts". These are `@font-face` declarations that only differ in their `unicode-range` definition. This fixes a lot of non-determinism in font selection especially when dealing with pages that define "composite faces." A notable example of such a page is servo.org, which now consistently displays the correct web font. One test starts to fail due to an uncovered bug, but this will be fixed in a followup change. Fixes #20686. Fixes #20684. Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This commit is contained in:
parent
628e33bfa9
commit
4732da3477
56 changed files with 613 additions and 593 deletions
|
@ -485,11 +485,7 @@ where
|
|||
},
|
||||
None => StyleFontStyle::NORMAL,
|
||||
};
|
||||
let descriptor = FontTemplateDescriptor {
|
||||
weight,
|
||||
stretch,
|
||||
style,
|
||||
};
|
||||
let descriptor = FontTemplateDescriptor::new(weight, stretch, style);
|
||||
callback(FontTemplate::new_local(local_font_identifier, descriptor));
|
||||
};
|
||||
|
||||
|
|
|
@ -173,11 +173,7 @@ impl PlatformFontMethods for PlatformFont {
|
|||
})
|
||||
.unwrap_or(FontStretch::NORMAL);
|
||||
|
||||
FontTemplateDescriptor {
|
||||
weight,
|
||||
stretch,
|
||||
style,
|
||||
}
|
||||
FontTemplateDescriptor::new(weight, stretch, style)
|
||||
}
|
||||
|
||||
fn glyph_index(&self, codepoint: char) -> Option<GlyphId> {
|
||||
|
|
|
@ -148,11 +148,7 @@ where
|
|||
path: Atom::from(c_str_to_string(path as *const c_char)),
|
||||
variation_index: index as i32,
|
||||
};
|
||||
let descriptor = FontTemplateDescriptor {
|
||||
weight,
|
||||
stretch,
|
||||
style,
|
||||
};
|
||||
let descriptor = FontTemplateDescriptor::new(weight, stretch, style);
|
||||
|
||||
callback(FontTemplate::new_local(local_font_identifier, descriptor))
|
||||
}
|
||||
|
|
|
@ -190,11 +190,7 @@ impl PlatformFontMethods for PlatformFont {
|
|||
|
||||
fn descriptor(&self) -> FontTemplateDescriptor {
|
||||
let traits = self.ctfont.all_traits();
|
||||
FontTemplateDescriptor {
|
||||
weight: traits.weight(),
|
||||
stretch: traits.stretch(),
|
||||
style: traits.style(),
|
||||
}
|
||||
FontTemplateDescriptor::new(traits.weight(), traits.stretch(), traits.style())
|
||||
}
|
||||
|
||||
fn glyph_index(&self, codepoint: char) -> Option<GlyphId> {
|
||||
|
|
|
@ -74,11 +74,8 @@ where
|
|||
};
|
||||
|
||||
let traits = family_descriptor.traits();
|
||||
let descriptor = FontTemplateDescriptor {
|
||||
weight: traits.weight(),
|
||||
stretch: traits.stretch(),
|
||||
style: traits.style(),
|
||||
};
|
||||
let descriptor =
|
||||
FontTemplateDescriptor::new(traits.weight(), traits.stretch(), traits.style());
|
||||
let identifier = LocalFontIdentifier {
|
||||
postscript_name: Atom::from(family_descriptor.font_name()),
|
||||
path: Atom::from(path),
|
||||
|
|
|
@ -186,11 +186,7 @@ impl PlatformFontMethods for PlatformFont {
|
|||
StyleFontStyle::NORMAL
|
||||
};
|
||||
|
||||
FontTemplateDescriptor {
|
||||
weight,
|
||||
stretch,
|
||||
style,
|
||||
}
|
||||
FontTemplateDescriptor::new(weight, stretch, style)
|
||||
}
|
||||
|
||||
fn glyph_index(&self, codepoint: char) -> Option<GlyphId> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue