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:
parent
71dd1bc386
commit
73641d0367
|
@ -53,6 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Parser reset between DCS escapes
|
- Parser reset between DCS escapes
|
||||||
- Parser stopping at unknown DEC private modes/SGR character attributes
|
- Parser stopping at unknown DEC private modes/SGR character attributes
|
||||||
- Block selection appending duplicate newlines when last column is selected
|
- Block selection appending duplicate newlines when last column is selected
|
||||||
|
- Bitmap fonts being a bit smaller than they should be in some cases
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,6 @@ pub struct FreeTypeRasterizer {
|
||||||
keys: HashMap<FontID, FontKey>,
|
keys: HashMap<FontID, FontKey>,
|
||||||
fallback_lists: HashMap<FontKey, FallbackList>,
|
fallback_lists: HashMap<FontKey, FallbackList>,
|
||||||
device_pixel_ratio: f32,
|
device_pixel_ratio: f32,
|
||||||
pixel_size: f64,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -120,7 +119,6 @@ impl Rasterize for FreeTypeRasterizer {
|
||||||
fallback_lists: HashMap::new(),
|
fallback_lists: HashMap::new(),
|
||||||
library,
|
library,
|
||||||
device_pixel_ratio,
|
device_pixel_ratio,
|
||||||
pixel_size: 0.0,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,13 +217,12 @@ impl FreeTypeRasterizer {
|
||||||
/// Load a font face according to `FontDesc`
|
/// Load a font face according to `FontDesc`
|
||||||
fn get_face(&mut self, desc: &FontDesc, size: Size) -> Result<FontKey, Error> {
|
fn get_face(&mut self, desc: &FontDesc, size: Size) -> Result<FontKey, Error> {
|
||||||
// Adjust for DPI
|
// Adjust for DPI
|
||||||
let size = Size::new(size.as_f32_pts() * self.device_pixel_ratio * 96. / 72.);
|
let size = f64::from(size.as_f32_pts() * self.device_pixel_ratio * 96. / 72.);
|
||||||
self.pixel_size = f64::from(size.as_f32_pts());
|
|
||||||
|
|
||||||
let config = fc::Config::get_current();
|
let config = fc::Config::get_current();
|
||||||
let mut pattern = Pattern::new();
|
let mut pattern = Pattern::new();
|
||||||
pattern.add_family(&desc.name);
|
pattern.add_family(&desc.name);
|
||||||
pattern.add_pixelsize(self.pixel_size);
|
pattern.add_pixelsize(size);
|
||||||
let hash = pattern.hash();
|
let hash = pattern.hash();
|
||||||
|
|
||||||
// Add style to a pattern
|
// Add style to a pattern
|
||||||
|
@ -473,7 +470,7 @@ impl FreeTypeRasterizer {
|
||||||
} else {
|
} else {
|
||||||
// Fallback if user has bitmap scaling disabled
|
// Fallback if user has bitmap scaling disabled
|
||||||
let metrics = face.ft_face.size_metrics().ok_or(Error::MissingSizeMetrics)?;
|
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))
|
Ok(downsample_bitmap(rasterized_glyph, fixup_factor))
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue