servo/components/gfx
Martin Robinson 77b2e88fb7
gfx: Do not apply scale to CoreText font metrics (#31996)
Since the original version of the CoreText font code, it has scaled the
metrics from CoreText by an unusual scale:

```
    let scale = px_to_pt(self.ctfont.pt_size()) / (ascent + descent);
```

It's unclear what this scale was trying to accomplish. Note that it's
passing the return value of `pt_size()` to `px_to_pt` which seems
backward. This scale seems bogus, but perhaps it's based on a
misconception about what its returned from CoreText. Unlike the return
values of `CGFont` methods, which are returned in font units, the ones
from `CTFont` are "scaled according to the point size and matrix of the
font reference."

Indeed, when just interpreting these values as pixel values, the results
more or less match Firefox and Chrome. This becomes much more obvious
now that we have support for `ex` units. Even when not using `ex`, you
can sometimes see the top parts of glyphs cut off due to this scaling.

This change removes the scaling and simply interpets the return values
of `CTFont` methods as pixels. It addresses all of the issues mentioned
above. Note that this path will eventually just be a fallback path and
metrics will come from sfnt tables in the future.
2024-04-05 10:22:36 +00:00
..
platform gfx: Do not apply scale to CoreText font metrics (#31996) 2024-04-05 10:22:36 +00:00
tests Update Stylo to 2023-10-16 (#31932) 2024-03-30 13:30:13 +00:00
text fonts: Consider Tertiary Ideographic Plane to be CJK (#31670) 2024-03-18 11:45:52 +00:00
Cargo.toml Move Stylo to its own repo (#31350) 2024-02-27 15:39:06 +00:00
font.rs clippy: Fix remaining warnings in gfx for MacOS (#31669) 2024-03-15 12:14:36 +00:00
font_cache_thread.rs fonts: Add support for WOFF2 and properly load web fonts from @imports (#31879) 2024-03-26 20:31:52 +00:00
font_context.rs layout: Add a FontMetricsProvider for resolving font-relative units (#31966) 2024-04-04 12:35:15 +00:00
font_template.rs clippy: Fix remaining warnings in gfx for MacOS (#31669) 2024-03-15 12:14:36 +00:00
lib.rs gfx: Rename WebrenderSurfman to RenderingContext and move to gfx (#31184) 2024-01-27 17:58:34 +00:00
rendering_context.rs clippy: Fix remaining warnings in gfx for MacOS (#31669) 2024-03-15 12:14:36 +00:00