linebender / norad

Rust crate for working with Unified Font Object files
Apache License 2.0
43 stars 12 forks source link

Float serialization: option to limit precision #189

Open madig opened 3 years ago

madig commented 3 years ago

ufonormalizer by default truncates floats to 10 decimal places, leading to diffs between norad and ufonormalizer on e.g. guideline angles.

chrissimpkins commented 3 years ago

+1 to anything that limits unnecessary / uninformative diffs

madig commented 3 years ago

I found an annoying behavior in ufonormalizer: if you try to work around the truncation and give e.g. 20 decimal places, it also changes color strings from <string>0.6,1,0.604,1</string> into <string>0.5999999999999999778,1,0.60399999999999998135,1</string>. Argh.

chrissimpkins commented 3 years ago

Lol. For those times when you need the exact color that you want.

Do you need to dig into serde to address this here?

madig commented 3 years ago

Hm, I'm not sure yet. For glif serialization, a simple function might work; for serde serialization, I think you can direct it to use a custom function.

chrissimpkins commented 3 years ago

+1 to anything that limits unnecessary / uninformative diffs

I came across this with another serializer today... (╯°□°)╯︵ ┻━┻

2021-11-15_14-35-52
madig commented 3 years ago

Ugh. Which one?

chrissimpkins commented 3 years ago

Ugh. Which one?

Emailed details to you. I didn't make the edits. I think that this is ufolib2?