layout: Turn on synthetic small-caps for layout 2020 (#31435)

Synthetic small caps is supported by the font subsystem, but this is
disabled in Layout 2020. We can turn this on to bring support to parity
with the old layout system.

In addition to turning on synthetic small-caps this change also improves
the way that they work. Before, synthetic small caps meant that every
character was a small version of capitalized character. After this
change, capital letters are larger than small caps versions of small
letters -- matching other browsers and the common expectation of how
small caps works.
This commit is contained in:
Martin Robinson 2024-02-28 16:09:26 +01:00 committed by GitHub
parent 98bd306816
commit 5ba29c20ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
48 changed files with 214 additions and 176 deletions

View file

@ -146,7 +146,7 @@ impl Shaper {
let hb_font: *mut hb_font_t = hb_font_create(hb_face);
// Set points-per-em. if zero, performs no hinting in that direction.
let pt_size = (*font).actual_pt_size.to_f64_px();
let pt_size = (*font).descriptor.pt_size.to_f64_px();
hb_font_set_ppem(hb_font, pt_size as c_uint, pt_size as c_uint);
// Set scaling. Note that this takes 16.16 fixed point.

View file

@ -31,7 +31,7 @@ pub struct TextRun {
/// The UTF-8 string represented by this text run.
pub text: Arc<String>,
pub font_template: Arc<FontTemplateData>,
pub actual_pt_size: Au,
pub pt_size: Au,
pub font_metrics: FontMetrics,
pub font_key: FontInstanceKey,
/// The glyph runs that make up this text run.
@ -195,7 +195,7 @@ impl<'a> TextRun {
font_metrics: font.metrics.clone(),
font_template: font.handle.template(),
font_key: font.font_key,
actual_pt_size: font.actual_pt_size,
pt_size: font.descriptor.pt_size,
glyphs: Arc::new(glyphs),
bidi_level: bidi_level,
extra_word_spacing: Au(0),