From 3dd63dcb93d7b7b70f4e3d97812f8af437dd6e0b Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sat, 9 Dec 2023 18:43:39 +0100 Subject: [PATCH 1/2] Switch `Size::from_px` constructor to `f32` 1f8e5db changed the `Size::as_px` method to return a floating point value instead of an integer. This patch ensures the constructor is consistent with that. --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 786f629..806b879 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -121,8 +121,8 @@ impl Size { /// Create a new `Size` from px. /// /// The value will be clamped to the pt range of [`Size::new`]. - pub fn from_px(size: u16) -> Self { - let pt = size as f32 * 72. / 96.; + pub fn from_px(size: f32) -> Self { + let pt = size * 72. / 96.; Size::new(pt) } From 75e21ebe9c9f713d8a4c77411749ddef3bf547d5 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sun, 10 Dec 2023 00:44:41 +0100 Subject: [PATCH 2/2] Add changelog entry --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 724257c..ce85661 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,15 +10,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- `Size::as_px` now returns `f32`. +- `Size::as_px` and `Size::from_px` now use `f32` type ## 0.6.0 ### Changed -- `Size` now uses 6 floating point digits precision instead of rounding to 0.5. -- Add `Size::from_px`, `Size::as_px`, `Size::as_pt`, and `Size::scale`. -- Remove `Rasterizer::update_dpr`; users should scale fonts themselves. +- `Size` now uses 6 floating point digits precision instead of rounding to 0.5 +- Add `Size::from_px`, `Size::as_px`, `Size::as_pt`, and `Size::scale` +- Remove `Rasterizer::update_dpr`; users should scale fonts themselves ## 0.5.2