servo / pathfinder

A fast, practical GPU rasterizer for fonts and vector graphics
Apache License 2.0
3.52k stars 198 forks source link

Panicking when font is not found or can't be loaded #553

Closed jocke-l closed 3 months ago

jocke-l commented 4 months ago

I'm using the Pathfinder C-binding to render text in my application, and I noticed that the program crashed irrecoverably when the selected font wasn't found or couldn't be loaded. I initially thought this was just a minor problem in the C-binding code, but when I investigated it further, it seems to be a deeper design issue.

https://github.com/servo/pathfinder/blob/e4fcda0d5259d0acf902aee6de7d2501f2bd6629/canvas/src/text.rs#L232-L236

I'm not a Rust expert so I don't know the reason for these panics, but I think Pathfinder should propagate these error conditions so that they can be handled further up by the caller, including from C.