From 7f079a70d0ff79f4174a3a928bcf5c2a153c7d7a Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Thu, 28 Dec 2023 10:29:12 -0500 Subject: [PATCH] Handle unknown fontawesome glyph names We put an empty string into the unicode map for these situations. Fixes #76 --- src/lib.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index d4347c2..a77fe2d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -463,6 +463,22 @@ impl<'a> PdfSimpleFont<'a> { } } } + } else { + match unicode_map { + Some(ref mut unicode_map) if base_name.contains("FontAwesome") => { + // the fontawesome tex package will use glyph names that don't have a corresponding unicode + // code point, so we'll use an empty string instead. See issue #76 + match unicode_map.entry(code as u32) { + Entry::Vacant(v) => { v.insert("".to_owned()); } + Entry::Occupied(e) => { + panic!("unexpected entry in unicode map") + } + } + } + _ => { + println!("unknown glyph name '{}' for font {}", name, base_name); + } + } } dlog!("{} = {} ({:?})", code, name, unicode); if let Some(ref mut unicode_map) = unicode_map {