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/darwin/mod.rs | |
parent | 9ffaac8ee7c5586f0faa62401b9de76cff81130f (diff) | |
download | alacritty-7275ecc282d29d1c67f700c01a399582ba052853.tar.gz 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/darwin/mod.rs')
-rw-r--r-- | font/src/darwin/mod.rs | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/font/src/darwin/mod.rs b/font/src/darwin/mod.rs index ca784ae6..0e694f16 100644 --- a/font/src/darwin/mod.rs +++ b/font/src/darwin/mod.rs @@ -430,21 +430,17 @@ impl Font { let leading = self.ct_font.leading() as f64; let line_height = (ascent + descent + leading + 0.5).floor(); - // Strikeout and underline metrics - // CoreText doesn't provide strikeout so we provide our own - let underline_position = - (self.ct_font.underline_position() - descent) - .round() as f32; - let underline_thickness = self.ct_font.underline_thickness() - .round() - .max(1.) as f32; - let strikeout_position = (line_height as f32 / 2. - descent as f32).round(); + // Strikeout and underline metrics. + // CoreText doesn't provide strikeout so we provide our own. + let underline_position = (self.ct_font.underline_position() - descent) as f32; + let underline_thickness = self.ct_font.underline_thickness() as f32; + let strikeout_position = (line_height / 2. - descent) as f32; let strikeout_thickness = underline_thickness; Metrics { average_advance, line_height, - descent: -(self.ct_font.descent() as f32), + descent: -(descent as f32), underline_position, underline_thickness, strikeout_position, |