fontdue
fontdue copied to clipboard
Add nighly support for constant floating point arithmetic
Make functions const, which use floating point arithmetic
Example Proposal
https://github.com/mooman219/fontdue/blob/master/src/font.rs#L45-L53
Before
#[inline(always)]
pub fn scale(&self, scale: f32) -> OutlineBounds {
OutlineBounds {
xmin: self.xmin * scale,
ymin: self.ymin * scale,
width: self.width * scale,
height: self.height * scale,
}
}
After
#![feature(const_fn_floating_point_arithmetic)]
// ...
pub const fn scale(&self, scale: f32) -> OutlineBounds {
OutlineBounds {
xmin: self.xmin * scale,
ymin: self.ymin * scale,
width: self.width * scale,
height: self.height * scale,
}
}
Something to keep an eye on, but I'm not interested in nightly only features in Fontdue, even if there was a PR for it. Looks promising for when it hits stable.
There are still a few things to do in the associated tracking issue (https://github.com/rust-lang/rust/issues/57241), but guess it won't be long before this becomes stable.