fschutt / printpdf

An easy-to-use library for writing PDF in Rust
https://docs.rs/printpdf/
MIT License
777 stars 95 forks source link

Clarify function input units using Pt or Mm struct #140

Open SadCl0wn opened 1 year ago

SadCl0wn commented 1 year ago

Hello, I've noticed that some functions like set_outline_thickness takes a f64 argument for the outline thickness. It's not clear whether the input is in points or millimeters. I propose to use Pt or Mm struct (could be an enum?) to clarify the input units, like so:

pub fn set_outline_thickness(&self, outline_thickness: Pt)

I believe that this change would make the library clearer and reduce potential errors caused by unit confusion. I understand that this is a breaking change, but I think it would be worth it eventually. What do you think?

If you're okay with the proposal, I'd be happy to create a pull request with the necessary changes thanks for your lib ^^

OlivierLemoine commented 1 year ago

Or in a less breaking manner:

pub fn set_outline_thickness<T: Into<Pt>>(&self, outline_thickness: T)