This method returns None in the case of an invalid font, currently in the same way ttf-parser provides this. This also means Font::pt_to_px_scale returns Option.
However, I don't think there is much of a way to handle invalid fonts at the point of using this method. I think it would be better to either just panic for invalid fonts in the method call, or check when initializing a font and return an Err if units_per_em is none immediately, which will allow us to unwrap it later.
Having to handle the option makes using point sizes harder than it should be, related #15
This method returns
None
in the case of an invalid font, currently in the same way ttf-parser provides this. This also meansFont::pt_to_px_scale
returns Option.However, I don't think there is much of a way to handle invalid fonts at the point of using this method. I think it would be better to either just panic for invalid fonts in the method call, or check when initializing a font and return an
Err
ifunits_per_em
is none immediately, which will allow us to unwrap it later.Having to handle the option makes using point sizes harder than it should be, related #15