servo / pathfinder

A fast, practical GPU rasterizer for fonts and vector graphics

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

jocke-l opened this issue · comments

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.

this.font_source
.select_by_postscript_name(postscript_name)
.expect("Couldn't find a font with that PostScript name!")
.load()
.expect("Failed to load the font!")

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.