diff --git a/src/font.rs b/src/font.rs index 3175ce0..c9723c7 100644 --- a/src/font.rs +++ b/src/font.rs @@ -130,7 +130,7 @@ impl Font { self.advance_glyph_with_wmode(glyph, false) } - pub fn outline_glyph_with_ctm(&self, glyph: i32, ctm: &Matrix) -> Result { + pub fn outline_glyph_with_ctm(&self, glyph: i32, ctm: &Matrix) -> Result, Error> { unsafe { let inner = ffi_try!(mupdf_outline_glyph( context(), @@ -138,11 +138,14 @@ impl Font { glyph, ctm.into() )); - Ok(Path::from_raw(inner)) + if inner.is_null() { + return Ok(None); + } + Ok(Some(Path::from_raw(inner))) } } - pub fn outline_glyph(&self, glyph: i32) -> Result { + pub fn outline_glyph(&self, glyph: i32) -> Result, Error> { self.outline_glyph_with_ctm(glyph, &Matrix::IDENTITY) } }