Use f32 instead of i32 for lengths

This allows users to use logical coordinates instead of physical ones.
This commit is contained in:
Héctor Ramón Jiménez 2023-02-04 11:13:53 +01:00
parent f08bea22ed
commit 4320ae6329
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
15 changed files with 203 additions and 155 deletions

View file

@ -7,8 +7,8 @@ pub struct CacheKey {
pub font_id: fontdb::ID,
/// Glyph ID
pub glyph_id: u16,
/// Font size in pixels
pub font_size: i32,
/// `f32` bits of font size
pub font_size_bits: u32,
/// Binning of fractional X offset
pub x_bin: SubpixelBin,
/// Binning of fractional Y offset
@ -19,7 +19,7 @@ impl CacheKey {
pub fn new(
font_id: fontdb::ID,
glyph_id: u16,
font_size: i32,
font_size: f32,
pos: (f32, f32),
) -> (Self, i32, i32) {
let (x, x_bin) = SubpixelBin::new(pos.0);
@ -28,7 +28,7 @@ impl CacheKey {
Self {
font_id,
glyph_id,
font_size,
font_size_bits: font_size.to_bits(),
x_bin,
y_bin,
},