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.
This commit is contained in:
Kirill Chibisov 2020-02-23 02:09:23 +03:00 committed by GitHub
parent 71dd1bc386
commit 73641d0367
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 6 deletions

View File

@ -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

View File

@ -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 {