mirror of
https://github.com/servo/servo.git
synced 2025-08-01 19:50:30 +01:00
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. |
||
---|---|---|
.. | ||
platform | ||
tests | ||
text | ||
Cargo.toml | ||
font.rs | ||
font_cache_thread.rs | ||
font_context.rs | ||
font_template.rs | ||
lib.rs | ||
rendering_context.rs |