Skip to content

Commit

Permalink
Don't allow inserting empty codepoints
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenzV committed Dec 18, 2024
1 parent 326f159 commit 2bf0c5a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion crates/krilla/src/object/font/cid_font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ impl CIDFont {

#[inline]
pub(crate) fn set_codepoints(&mut self, cid: Cid, text: String) {
self.cmap_entries.insert(cid, text);
if !text.is_empty() {
self.cmap_entries.insert(cid, text);
}
}

#[inline]
Expand Down Expand Up @@ -254,6 +256,7 @@ impl CIDFont {
// For the .notdef glyph, it's fine if no mapping exists, since it is included
// even if it was not referenced in the text.
for g in 1..self.glyph_remapper.num_gids() {
println!("{:?}", self.cmap_entries.get(&g));
match self.cmap_entries.get(&g) {
None => sc.register_validation_error(ValidationError::InvalidCodepointMapping(
self.font.clone(),
Expand Down
4 changes: 3 additions & 1 deletion crates/krilla/src/object/font/type3_font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ impl Type3Font {

#[inline]
pub(crate) fn set_codepoints(&mut self, gid: Gid, text: String) {
self.cmap_entries.insert(gid, text);
if !text.is_empty() {
self.cmap_entries.insert(gid, text);
}
}

#[inline]
Expand Down

0 comments on commit 2bf0c5a

Please sign in to comment.