Skip to content

Commit

Permalink
Return an Result<Option> from outline_glyph (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
ginnyTheCat authored Jan 30, 2025
1 parent a55cda7 commit 7d01aa4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,22 @@ impl Font {
self.advance_glyph_with_wmode(glyph, false)
}

pub fn outline_glyph_with_ctm(&self, glyph: i32, ctm: &Matrix) -> Result<Path, Error> {
pub fn outline_glyph_with_ctm(&self, glyph: i32, ctm: &Matrix) -> Result<Option<Path>, Error> {
unsafe {
let inner = ffi_try!(mupdf_outline_glyph(
context(),
self.inner,
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<Path, Error> {
pub fn outline_glyph(&self, glyph: i32) -> Result<Option<Path>, Error> {
self.outline_glyph_with_ctm(glyph, &Matrix::IDENTITY)
}
}
Expand Down

0 comments on commit 7d01aa4

Please sign in to comment.