Skip to content

Commit

Permalink
Switch Size::from_px constructor to f32
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
chrisduerr authored Dec 10, 2023
1 parent 1f8e5db commit 2be0ea2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 2be0ea2

Please sign in to comment.