diff options
| author | Christian Duerr <chrisduerr@users.noreply.github.com> | 2018-12-31 17:01:06 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-31 17:01:06 +0000 |
| commit | 7275ecc282d29d1c67f700c01a399582ba052853 (patch) | |
| tree | 836ccd5bc47c7f40cd22816f6a5b3376dd371661 /font/src/rusttype | |
| parent | 9ffaac8ee7c5586f0faa62401b9de76cff81130f (diff) | |
| download | r-alacritty-7275ecc282d29d1c67f700c01a399582ba052853.tar.gz r-alacritty-7275ecc282d29d1c67f700c01a399582ba052853.tar.bz2 r-alacritty-7275ecc282d29d1c67f700c01a399582ba052853.zip | |
Fix line metrics
Since bitmap fonts do not provide their own underline metrics, the
self-calculated metrics which have been used for rusttype are now also
used for bitmap fonts with freetype.
The rusttype and bitmap fallback metrics have incorrectly offset the
underline by the underline height. Since the position is already defined
as the center point, that is not necessary.
All rounding and clamping has also been removed from the font library,
so that the raw values are reported now. The clamping and rounding is
now done in the line renderer.
Diffstat (limited to 'font/src/rusttype')
| -rw-r--r-- | font/src/rusttype/mod.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/font/src/rusttype/mod.rs b/font/src/rusttype/mod.rs index 2d28a8bd..bd4b8df1 100644 --- a/font/src/rusttype/mod.rs +++ b/font/src/rusttype/mod.rs @@ -38,11 +38,11 @@ impl crate::Rasterize for RustTypeRasterizer { let average_advance = f64::from(hmetrics.advance_width); let descent = vmetrics.descent; - // Strikeout and underline metrics - // RustType doesn't support these, so we make up our own + // Strikeout and underline metrics. + // RustType doesn't support these, so we make up our own. let thickness = (descent / 5.).round(); - let underline_position = descent / 2. + thickness / 2.; - let strikeout_position = (line_height as f32 / 2. - descent).round(); + let underline_position = descent / 2.; + let strikeout_position = line_height as f32 / 2. - descent; Ok(Metrics { descent, |