alexheretic / ab-glyph

Rust API for loading, scaling, positioning and rasterizing OpenType font glyphs
Apache License 2.0
372 stars 24 forks source link

Font::units_per_em should not return Option #64

Open alexheretic opened 2 years ago

alexheretic commented 2 years ago

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