diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2020-02-23 02:09:23 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-23 02:09:23 +0300 |
commit | 73641d03673638e361b0254ce400c02b1b65e6ed (patch) | |
tree | da44828023839662389edd9f73552e69fe4a8673 | |
parent | 71dd1bc386d70e42d5e40c6e1d9d6b430dc70b75 (diff) | |
download | alacritty-73641d03673638e361b0254ce400c02b1b65e6ed.tar.gz alacritty-73641d03673638e361b0254ce400c02b1b65e6ed.zip |
Fix Fontconfig's font size query
Previously we were rounding pattern's `pixelsize` before `fc_sort`, however we were using not rounded one in `get_glyph`, so bitmap fonts could look a bit smaller when used in a mix with scalable fonts.
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | font/src/ft/mod.rs | 9 |
2 files changed, 4 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bf47af2..fabcf11c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Parser reset between DCS escapes - Parser stopping at unknown DEC private modes/SGR character attributes - Block selection appending duplicate newlines when last column is selected +- Bitmap fonts being a bit smaller than they should be in some cases ### Removed diff --git a/font/src/ft/mod.rs b/font/src/ft/mod.rs index 3e43a29f..385c66d6 100644 --- a/font/src/ft/mod.rs +++ b/font/src/ft/mod.rs @@ -100,7 +100,6 @@ pub struct FreeTypeRasterizer { keys: HashMap<FontID, FontKey>, fallback_lists: HashMap<FontKey, FallbackList>, device_pixel_ratio: f32, - pixel_size: f64, } #[inline] @@ -120,7 +119,6 @@ impl Rasterize for FreeTypeRasterizer { fallback_lists: HashMap::new(), library, device_pixel_ratio, - pixel_size: 0.0, }) } @@ -219,13 +217,12 @@ impl FreeTypeRasterizer { /// Load a font face according to `FontDesc` fn get_face(&mut self, desc: &FontDesc, size: Size) -> Result<FontKey, Error> { // Adjust for DPI - let size = Size::new(size.as_f32_pts() * self.device_pixel_ratio * 96. / 72.); - self.pixel_size = f64::from(size.as_f32_pts()); + let size = f64::from(size.as_f32_pts() * self.device_pixel_ratio * 96. / 72.); let config = fc::Config::get_current(); let mut pattern = Pattern::new(); pattern.add_family(&desc.name); - pattern.add_pixelsize(self.pixel_size); + pattern.add_pixelsize(size); let hash = pattern.hash(); // Add style to a pattern @@ -473,7 +470,7 @@ impl FreeTypeRasterizer { } else { // Fallback if user has bitmap scaling disabled let metrics = face.ft_face.size_metrics().ok_or(Error::MissingSizeMetrics)?; - self.pixel_size as f64 / metrics.y_ppem as f64 + size as f64 / metrics.y_ppem as f64 }; Ok(downsample_bitmap(rasterized_glyph, fixup_factor)) } else { |